Skip to content

Commit 1fdfce2

Browse files
feat: Filter archived telemetry events by type
Stainless-Generated-From: 2a917c5ccb5838e9bdd96775019f433535c381e8
1 parent 2b637f5 commit 1fdfce2

3 files changed

Lines changed: 33 additions & 14 deletions

File tree

‎src/kernel/resources/browsers/telemetry.py‎

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import httpx
99

10-
from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
10+
from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
1111
from ..._utils import path_template, maybe_transform, strip_not_given, async_maybe_transform
1212
from ..._compat import cached_property
1313
from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -75,6 +75,7 @@ def events(
7575
offset: int | Omit = omit,
7676
order: str | Omit = omit,
7777
since: str | Omit = omit,
78+
type: SequenceNotStr[str] | Omit = omit,
7879
until: str | Omit = omit,
7980
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
8081
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -87,8 +88,9 @@ def events(
8788
8889
To page through
8990
results, pass the X-Next-Offset value from the previous response as offset and
90-
repeat while X-Has-More is true. Returns an empty list when telemetry data is
91-
unavailable.
91+
repeat while X-Has-More is true. The category and type filters apply within each
92+
page, so a filtered page may be empty while X-Has-More is true. Returns an empty
93+
list when telemetry data is unavailable.
9294
9395
Args:
9496
category: Restrict results to these event categories. Repeat the parameter for multiple
@@ -104,13 +106,15 @@ def events(
104106
order: Read direction. asc (default) reads oldest first, starting from since or the
105107
offset cursor. desc reads newest first: each request returns one page of up to
106108
limit records ending at the offset cursor (or until, or the newest archived
107-
event); combining desc with since is rejected with a 400. In either direction
108-
the category filter applies within the page, so a filtered page may be empty
109-
while X-Has-More is true.
109+
event); combining desc with since is rejected with a 400.
110110
111111
since: Start of the window: an RFC-3339 timestamp, or a duration like 5m meaning that
112112
long ago. Defaults to 5m. Ignored when offset is set.
113113
114+
type: Restrict results to these event types, such as page_crashed or
115+
captcha_challenge_result. Repeat the parameter for multiple values. Combines
116+
with category: when both are set an event must match both.
117+
114118
until: End of the window (exclusive): an RFC-3339 timestamp, or a duration like 5m
115119
meaning that long ago.
116120
@@ -139,6 +143,7 @@ def events(
139143
"offset": offset,
140144
"order": order,
141145
"since": since,
146+
"type": type,
142147
"until": until,
143148
},
144149
telemetry_events_params.TelemetryEventsParams,
@@ -252,6 +257,7 @@ def events(
252257
offset: int | Omit = omit,
253258
order: str | Omit = omit,
254259
since: str | Omit = omit,
260+
type: SequenceNotStr[str] | Omit = omit,
255261
until: str | Omit = omit,
256262
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
257263
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -264,8 +270,9 @@ def events(
264270
265271
To page through
266272
results, pass the X-Next-Offset value from the previous response as offset and
267-
repeat while X-Has-More is true. Returns an empty list when telemetry data is
268-
unavailable.
273+
repeat while X-Has-More is true. The category and type filters apply within each
274+
page, so a filtered page may be empty while X-Has-More is true. Returns an empty
275+
list when telemetry data is unavailable.
269276
270277
Args:
271278
category: Restrict results to these event categories. Repeat the parameter for multiple
@@ -281,13 +288,15 @@ def events(
281288
order: Read direction. asc (default) reads oldest first, starting from since or the
282289
offset cursor. desc reads newest first: each request returns one page of up to
283290
limit records ending at the offset cursor (or until, or the newest archived
284-
event); combining desc with since is rejected with a 400. In either direction
285-
the category filter applies within the page, so a filtered page may be empty
286-
while X-Has-More is true.
291+
event); combining desc with since is rejected with a 400.
287292
288293
since: Start of the window: an RFC-3339 timestamp, or a duration like 5m meaning that
289294
long ago. Defaults to 5m. Ignored when offset is set.
290295
296+
type: Restrict results to these event types, such as page_crashed or
297+
captcha_challenge_result. Repeat the parameter for multiple values. Combines
298+
with category: when both are set an event must match both.
299+
291300
until: End of the window (exclusive): an RFC-3339 timestamp, or a duration like 5m
292301
meaning that long ago.
293302
@@ -316,6 +325,7 @@ def events(
316325
"offset": offset,
317326
"order": order,
318327
"since": since,
328+
"type": type,
319329
"until": until,
320330
},
321331
telemetry_events_params.TelemetryEventsParams,

‎src/kernel/types/browsers/telemetry_events_params.py‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from typing import List
66
from typing_extensions import Literal, TypedDict
77

8+
from ..._types import SequenceNotStr
9+
810
__all__ = ["TelemetryEventsParams"]
911

1012

@@ -46,9 +48,7 @@ class TelemetryEventsParams(TypedDict, total=False):
4648
asc (default) reads oldest first, starting from since or the offset cursor. desc
4749
reads newest first: each request returns one page of up to limit records ending
4850
at the offset cursor (or until, or the newest archived event); combining desc
49-
with since is rejected with a 400. In either direction the category filter
50-
applies within the page, so a filtered page may be empty while X-Has-More is
51-
true.
51+
with since is rejected with a 400.
5252
"""
5353

5454
since: str
@@ -57,6 +57,13 @@ class TelemetryEventsParams(TypedDict, total=False):
5757
long ago. Defaults to 5m. Ignored when offset is set.
5858
"""
5959

60+
type: SequenceNotStr[str]
61+
"""
62+
Restrict results to these event types, such as page_crashed or
63+
captcha_challenge_result. Repeat the parameter for multiple values. Combines
64+
with category: when both are set an event must match both.
65+
"""
66+
6067
until: str
6168
"""
6269
End of the window (exclusive): an RFC-3339 timestamp, or a duration like 5m

‎tests/api_resources/browsers/test_telemetry.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def test_method_events_with_all_params(self, client: Kernel) -> None:
3636
offset=0,
3737
order="order",
3838
since="since",
39+
type=["string"],
3940
until="until",
4041
)
4142
assert_matches_type(SyncOffsetPagination[TelemetryEventsResponse], telemetry, path=["response"])
@@ -149,6 +150,7 @@ async def test_method_events_with_all_params(self, async_client: AsyncKernel) ->
149150
offset=0,
150151
order="order",
151152
since="since",
153+
type=["string"],
152154
until="until",
153155
)
154156
assert_matches_type(AsyncOffsetPagination[TelemetryEventsResponse], telemetry, path=["response"])

0 commit comments

Comments
 (0)