Skip to content

Commit 20bce96

Browse files
feat: Add telemetry support for browser pools with BAA enforcement
1 parent 137b7a1 commit 20bce96

3 files changed

Lines changed: 165 additions & 2 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: 127
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-92c776855f978ae03a778fbbac49bf1edc65852530644772c382838b6eab9fe5.yml
3-
openapi_spec_hash: 4a9fbcb607be408ad646e207fe90687f
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-e04362b2c82b88f4f7fb43209c764fa9fdf37fe98932e142547be43a1e99c50b.yml
3+
openapi_spec_hash: b16e79bfd6cac36090c815a8184b9e09
44
config_hash: 77ee715aa17061166f9a02b264a21b8d

‎src/resources/browser-pools.ts‎

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,12 @@ export namespace BrowserPool {
295295
*/
296296
stealth?: boolean;
297297

298+
/**
299+
* Active telemetry configuration applied to browsers warmed into this pool, if
300+
* any.
301+
*/
302+
telemetry?: TelemetryAPI.BrowserTelemetryConfig | null;
303+
298304
/**
299305
* Default idle timeout in seconds for browsers acquired from this pool before they
300306
* are destroyed. Minimum 10, maximum 259200 (72 hours).
@@ -555,6 +561,16 @@ export interface BrowserPoolCreateParams {
555561
*/
556562
stealth?: boolean;
557563

564+
/**
565+
* Telemetry configuration applied to browsers warmed into this pool. Set enabled
566+
* to true to start capture using the default set, or provide browser category
567+
* settings. If omitted, null, set to an empty object ({}), set to enabled: false
568+
* without browser category settings, or all four CDP categories are explicitly
569+
* disabled, no telemetry is configured on the pool. Only applied to newly-warmed
570+
* browsers.
571+
*/
572+
telemetry?: BrowserPoolCreateParams.Telemetry | null;
573+
558574
/**
559575
* Default idle timeout in seconds for browsers acquired from this pool before they
560576
* are destroyed. Defaults to 600 seconds. Minimum 10, maximum 259200 (72 hours).
@@ -598,6 +614,41 @@ export namespace BrowserPoolCreateParams {
598614
*/
599615
name?: string;
600616
}
617+
618+
/**
619+
* Telemetry configuration applied to browsers warmed into this pool. Set enabled
620+
* to true to start capture using the default set, or provide browser category
621+
* settings. If omitted, null, set to an empty object ({}), set to enabled: false
622+
* without browser category settings, or all four CDP categories are explicitly
623+
* disabled, no telemetry is configured on the pool. Only applied to newly-warmed
624+
* browsers.
625+
*/
626+
export interface Telemetry {
627+
/**
628+
* Per-category capture flags. The operational categories (control, connection,
629+
* system, captcha) are captured whenever telemetry is enabled; set one to
630+
* enabled=false to opt out. The CDP categories (console, network, page,
631+
* interaction) and screenshot are off by default; set enabled=true to opt in. On
632+
* create, provided categories layer onto the default set. On update, provided
633+
* categories merge onto the session's current config; when no telemetry is active
634+
* this falls back to the default set (matching create). If browser is omitted or
635+
* empty, the default set is used. A browser config that disables every category
636+
* stops capture on update and starts no capture on create.
637+
*/
638+
browser?: TelemetryAPI.BrowserTelemetryCategoriesConfig;
639+
640+
/**
641+
* Request shortcut for browser telemetry capture. True enables capture; with no
642+
* browser category settings it captures the default set (control, connection,
643+
* system, captcha), and any browser category settings are layered onto that
644+
* default set. On update, enabled=true resolves the config fresh from the default
645+
* set plus any provided categories, replacing the session's current selection
646+
* rather than merging onto it; omit enabled to merge categories onto the current
647+
* selection instead. False stops capture on update and starts no capture on
648+
* create. enabled=false cannot be combined with browser category settings.
649+
*/
650+
enabled?: boolean;
651+
}
601652
}
602653

603654
export interface BrowserPoolUpdateParams {
@@ -693,6 +744,17 @@ export interface BrowserPoolUpdateParams {
693744
*/
694745
stealth?: boolean;
695746

747+
/**
748+
* If provided, updates the pool's telemetry configuration. Omit, set to null, or
749+
* set to an empty object ({}) to leave the existing configuration unchanged. Set
750+
* enabled to true to enable capture using the default set. Set enabled to false to
751+
* clear the pool's telemetry. Provide browser category settings for per-category
752+
* updates, merged onto the pool's current configuration. Only applied to browsers
753+
* warmed after the update; browsers already in the pool keep their configuration
754+
* until discarded.
755+
*/
756+
telemetry?: BrowserPoolUpdateParams.Telemetry | null;
757+
696758
/**
697759
* If provided, replaces the default idle timeout in seconds for browsers acquired
698760
* from this pool before they are destroyed. Minimum 10, maximum 259200 (72 hours).
@@ -736,6 +798,42 @@ export namespace BrowserPoolUpdateParams {
736798
*/
737799
name?: string;
738800
}
801+
802+
/**
803+
* If provided, updates the pool's telemetry configuration. Omit, set to null, or
804+
* set to an empty object ({}) to leave the existing configuration unchanged. Set
805+
* enabled to true to enable capture using the default set. Set enabled to false to
806+
* clear the pool's telemetry. Provide browser category settings for per-category
807+
* updates, merged onto the pool's current configuration. Only applied to browsers
808+
* warmed after the update; browsers already in the pool keep their configuration
809+
* until discarded.
810+
*/
811+
export interface Telemetry {
812+
/**
813+
* Per-category capture flags. The operational categories (control, connection,
814+
* system, captcha) are captured whenever telemetry is enabled; set one to
815+
* enabled=false to opt out. The CDP categories (console, network, page,
816+
* interaction) and screenshot are off by default; set enabled=true to opt in. On
817+
* create, provided categories layer onto the default set. On update, provided
818+
* categories merge onto the session's current config; when no telemetry is active
819+
* this falls back to the default set (matching create). If browser is omitted or
820+
* empty, the default set is used. A browser config that disables every category
821+
* stops capture on update and starts no capture on create.
822+
*/
823+
browser?: TelemetryAPI.BrowserTelemetryCategoriesConfig;
824+
825+
/**
826+
* Request shortcut for browser telemetry capture. True enables capture; with no
827+
* browser category settings it captures the default set (control, connection,
828+
* system, captcha), and any browser category settings are layered onto that
829+
* default set. On update, enabled=true resolves the config fresh from the default
830+
* set plus any provided categories, replacing the session's current selection
831+
* rather than merging onto it; omit enabled to merge categories onto the current
832+
* selection instead. False stops capture on update and starts no capture on
833+
* create. enabled=false cannot be combined with browser category settings.
834+
*/
835+
enabled?: boolean;
836+
}
739837
}
740838

741839
export interface BrowserPoolListParams extends OffsetPaginationParams {
@@ -791,6 +889,57 @@ export interface BrowserPoolAcquireParams {
791889
* the browser is released back to the pool. Up to 50 pairs.
792890
*/
793891
tags?: BrowsersAPI.Tags;
892+
893+
/**
894+
* Telemetry override for the acquired browser, applied to this lease only. Merges
895+
* onto the browser's current (pool-inherited) telemetry using the same
896+
* per-category semantics as PATCH /browsers: provided categories override the
897+
* current configuration, omitted categories are inherited. Set enabled to true to
898+
* resolve the config fresh from the default set, or enabled to false to stop
899+
* capture. When the browser is released back to the pool with reuse, its telemetry
900+
* is reset to the pool's baseline, so the override does not carry over to the next
901+
* lease.
902+
*/
903+
telemetry?: BrowserPoolAcquireParams.Telemetry | null;
904+
}
905+
906+
export namespace BrowserPoolAcquireParams {
907+
/**
908+
* Telemetry override for the acquired browser, applied to this lease only. Merges
909+
* onto the browser's current (pool-inherited) telemetry using the same
910+
* per-category semantics as PATCH /browsers: provided categories override the
911+
* current configuration, omitted categories are inherited. Set enabled to true to
912+
* resolve the config fresh from the default set, or enabled to false to stop
913+
* capture. When the browser is released back to the pool with reuse, its telemetry
914+
* is reset to the pool's baseline, so the override does not carry over to the next
915+
* lease.
916+
*/
917+
export interface Telemetry {
918+
/**
919+
* Per-category capture flags. The operational categories (control, connection,
920+
* system, captcha) are captured whenever telemetry is enabled; set one to
921+
* enabled=false to opt out. The CDP categories (console, network, page,
922+
* interaction) and screenshot are off by default; set enabled=true to opt in. On
923+
* create, provided categories layer onto the default set. On update, provided
924+
* categories merge onto the session's current config; when no telemetry is active
925+
* this falls back to the default set (matching create). If browser is omitted or
926+
* empty, the default set is used. A browser config that disables every category
927+
* stops capture on update and starts no capture on create.
928+
*/
929+
browser?: TelemetryAPI.BrowserTelemetryCategoriesConfig;
930+
931+
/**
932+
* Request shortcut for browser telemetry capture. True enables capture; with no
933+
* browser category settings it captures the default set (control, connection,
934+
* system, captcha), and any browser category settings are layered onto that
935+
* default set. On update, enabled=true resolves the config fresh from the default
936+
* set plus any provided categories, replacing the session's current selection
937+
* rather than merging onto it; omit enabled to merge categories onto the current
938+
* selection instead. False stops capture on update and starts no capture on
939+
* create. enabled=false cannot be combined with browser category settings.
940+
*/
941+
enabled?: boolean;
942+
}
794943
}
795944

796945
export interface BrowserPoolReleaseParams {

‎tests/api-resources/browser-pools.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ describe('resource browserPools', () => {
3535
refresh_on_profile_update: true,
3636
start_url: 'https://example.com',
3737
stealth: true,
38+
telemetry: {
39+
browser: {
40+
captcha: { enabled: true },
41+
connection: { enabled: true },
42+
console: { enabled: true },
43+
control: { enabled: true },
44+
interaction: { enabled: true },
45+
network: { enabled: true },
46+
page: { enabled: true },
47+
screenshot: { enabled: true },
48+
system: { enabled: true },
49+
},
50+
enabled: true,
51+
},
3852
timeout_seconds: 10,
3953
viewport: {
4054
height: 800,

0 commit comments

Comments
 (0)