55import httpx
66
77from ..._types import Body , Omit , Query , Headers , NotGiven , omit , not_given
8- from ..._utils import path_template , strip_not_given
8+ from ..._utils import path_template , maybe_transform , strip_not_given , async_maybe_transform
99from ..._compat import cached_property
1010from ..._resource import SyncAPIResource , AsyncAPIResource
1111from ..._response import (
1616)
1717from ..._streaming import Stream , AsyncStream
1818from ..._base_client import make_request_options
19+ from ...types .browsers import telemetry_stream_params
1920from ...types .browsers .telemetry_stream_response import TelemetryStreamResponse
2021
2122__all__ = ["TelemetryResource" , "AsyncTelemetryResource" ]
@@ -47,6 +48,7 @@ def stream(
4748 self ,
4849 id : str ,
4950 * ,
51+ replay : str | Omit = omit ,
5052 last_event_id : str | Omit = omit ,
5153 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5254 # The extra values given here take precedence over values defined on the client or passed to this method.
@@ -64,9 +66,14 @@ def stream(
6466 set; all frames carry JSON in the data: field. A keepalive comment frame is sent
6567 every 15 seconds when no events arrive. Returns 404 if the browser session does
6668 not exist. If telemetry was not enabled on the session, the stream opens but no
67- events are delivered.
69+ events are delivered. Fresh connections only see new events; pass replay=all to
70+ start from the oldest retained event instead.
6871
6972 Args:
73+ replay: Pass `all` to start from the oldest retained event instead of only new events;
74+ any other value is treated as from-now. The buffer is bounded, so the first
75+ event id may be greater than 1 if older events were evicted.
76+
7077 extra_headers: Send extra headers
7178
7279 extra_query: Add additional query parameters to the request
@@ -82,7 +89,11 @@ def stream(
8289 return self ._get (
8390 path_template ("/browsers/{id}/telemetry/stream" , id = id ),
8491 options = make_request_options (
85- extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
92+ extra_headers = extra_headers ,
93+ extra_query = extra_query ,
94+ extra_body = extra_body ,
95+ timeout = timeout ,
96+ query = maybe_transform ({"replay" : replay }, telemetry_stream_params .TelemetryStreamParams ),
8697 ),
8798 cast_to = TelemetryStreamResponse ,
8899 stream = True ,
@@ -116,6 +127,7 @@ async def stream(
116127 self ,
117128 id : str ,
118129 * ,
130+ replay : str | Omit = omit ,
119131 last_event_id : str | Omit = omit ,
120132 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
121133 # The extra values given here take precedence over values defined on the client or passed to this method.
@@ -133,9 +145,14 @@ async def stream(
133145 set; all frames carry JSON in the data: field. A keepalive comment frame is sent
134146 every 15 seconds when no events arrive. Returns 404 if the browser session does
135147 not exist. If telemetry was not enabled on the session, the stream opens but no
136- events are delivered.
148+ events are delivered. Fresh connections only see new events; pass replay=all to
149+ start from the oldest retained event instead.
137150
138151 Args:
152+ replay: Pass `all` to start from the oldest retained event instead of only new events;
153+ any other value is treated as from-now. The buffer is bounded, so the first
154+ event id may be greater than 1 if older events were evicted.
155+
139156 extra_headers: Send extra headers
140157
141158 extra_query: Add additional query parameters to the request
@@ -151,7 +168,11 @@ async def stream(
151168 return await self ._get (
152169 path_template ("/browsers/{id}/telemetry/stream" , id = id ),
153170 options = make_request_options (
154- extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
171+ extra_headers = extra_headers ,
172+ extra_query = extra_query ,
173+ extra_body = extra_body ,
174+ timeout = timeout ,
175+ query = await async_maybe_transform ({"replay" : replay }, telemetry_stream_params .TelemetryStreamParams ),
155176 ),
156177 cast_to = TelemetryStreamResponse ,
157178 stream = True ,
0 commit comments