Skip to content

Commit feafd18

Browse files
feat: Forward replay param through telemetry stream passthrough
1 parent 8503b01 commit feafd18

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 121
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-7d6d64b3998b55057f21aa5e33096cd5468f2bb2c4fda65190e9f299b50e5908.yml
3-
openapi_spec_hash: aa7d3971d38b16eff41b08cc3cbb549d
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-01f7f21a2fc892da284edf6b7cfd340d2ce5d0a9eb7ad2b39a8daec27b093134.yml
3+
openapi_spec_hash: 21972930082b23d985faf285fd656c31
44
config_hash: 3a50aee540dce69a53bb8942f5086f5e

src/resources/browsers/telemetry.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export class Telemetry extends APIResource {
2020
* set; all frames carry JSON in the data: field. A keepalive comment frame is sent
2121
* every 15 seconds when no events arrive. Returns 404 if the browser session does
2222
* not exist. If telemetry was not enabled on the session, the stream opens but no
23-
* events are delivered.
23+
* events are delivered. Fresh connections only see new events; pass replay=all to
24+
* start from the oldest retained event instead.
2425
*
2526
* @example
2627
* ```ts
@@ -34,8 +35,9 @@ export class Telemetry extends APIResource {
3435
params: TelemetryStreamParams | undefined = {},
3536
options?: RequestOptions,
3637
): APIPromise<Stream<TelemetryStreamResponse>> {
37-
const { 'Last-Event-ID': lastEventID } = params ?? {};
38+
const { 'Last-Event-ID': lastEventID, ...query } = params ?? {};
3839
return this._client.get(path`/browsers/${id}/telemetry/stream`, {
40+
query,
3941
...options,
4042
headers: buildHeaders([
4143
{
@@ -2001,8 +2003,16 @@ export interface TelemetryStreamResponse {
20012003

20022004
export interface TelemetryStreamParams {
20032005
/**
2004-
* Last event sequence number for SSE reconnection (sent by SSE clients on
2005-
* reconnect)
2006+
* Query param: Pass `all` to start from the oldest retained event instead of only
2007+
* new events; any other value is treated as from-now. The buffer is bounded, so
2008+
* the first event id may be greater than 1 if older events were evicted.
2009+
*/
2010+
replay?: string;
2011+
2012+
/**
2013+
* Header param: Last event sequence number for SSE reconnection (sent by SSE
2014+
* clients on reconnect). Takes precedence over replay when both are present, so
2015+
* reconnect resumes instead of re-replaying.
20062016
*/
20072017
'Last-Event-ID'?: string;
20082018
}

tests/api-resources/browsers/telemetry.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('resource telemetry', () => {
2626
await expect(
2727
client.browsers.telemetry.stream(
2828
'id',
29-
{ 'Last-Event-ID': 'Last-Event-ID' },
29+
{ replay: 'replay', 'Last-Event-ID': 'Last-Event-ID' },
3030
{ path: '/_stainless_unknown_path' },
3131
),
3232
).rejects.toThrow(Kernel.NotFoundError);

0 commit comments

Comments
 (0)