Skip to content

Commit 2630d8e

Browse files
feat: Add browser telemetry to managed auth connections
1 parent 24435d7 commit 2630d8e

7 files changed

Lines changed: 297 additions & 6 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-477bd1ff6f7053f2bd4687d7c5fc9a6a1d56a584be42f927abc6fc858ff35718.yml
3-
openapi_spec_hash: 3bf4cc824f6497c4ad109abd3187eede
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-a4b8f40deaf572d0dab92ebe0cafa865e1357a18f8720c3f003810da89aa4203.yml
3+
openapi_spec_hash: d06e9bf804151f7d9f7fab77f2e1669c
44
config_hash: 77ee715aa17061166f9a02b264a21b8d

src/kernel/resources/auth/connections.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Any, Dict, cast
5+
from typing import Any, Dict, Optional, cast
66
from typing_extensions import Literal
77

88
import httpx
@@ -66,6 +66,7 @@ def create(
6666
profile_name: str,
6767
allowed_domains: SequenceNotStr[str] | Omit = omit,
6868
auto_reauth: bool | Omit = omit,
69+
browser_telemetry: Optional[connection_create_params.BrowserTelemetry] | Omit = omit,
6970
credential: connection_create_params.Credential | Omit = omit,
7071
health_check_interval: int | Omit = omit,
7172
health_checks: bool | Omit = omit,
@@ -119,6 +120,10 @@ def create(
119120
false, expired sessions are marked as `NEEDS_AUTH` instead of attempting
120121
re-auth. Defaults to true.
121122
123+
browser_telemetry: Browser telemetry configuration used by this connection's browser sessions by
124+
default. Uses the exact create-browser configuration. Can be overridden
125+
per-login.
126+
122127
credential:
123128
Reference to credentials for the auth connection. Use one of:
124129
@@ -166,6 +171,7 @@ def create(
166171
"profile_name": profile_name,
167172
"allowed_domains": allowed_domains,
168173
"auto_reauth": auto_reauth,
174+
"browser_telemetry": browser_telemetry,
169175
"credential": credential,
170176
"health_check_interval": health_check_interval,
171177
"health_checks": health_checks,
@@ -223,6 +229,7 @@ def update(
223229
*,
224230
allowed_domains: SequenceNotStr[str] | Omit = omit,
225231
auto_reauth: bool | Omit = omit,
232+
browser_telemetry: Optional[connection_update_params.BrowserTelemetry] | Omit = omit,
226233
credential: connection_update_params.Credential | Omit = omit,
227234
health_check_interval: int | Omit = omit,
228235
health_checks: bool | Omit = omit,
@@ -253,6 +260,10 @@ def update(
253260
when `health_checks` is false. When false, expired sessions detected by a health
254261
check are marked as `NEEDS_AUTH` instead of attempting re-auth.
255262
263+
browser_telemetry: Browser telemetry configuration used by future browser sessions for this
264+
connection. Uses the exact create-browser configuration. Set enabled to false to
265+
disable telemetry.
266+
256267
credential:
257268
Reference to credentials for the auth connection. Use one of:
258269
@@ -294,6 +305,7 @@ def update(
294305
{
295306
"allowed_domains": allowed_domains,
296307
"auto_reauth": auto_reauth,
308+
"browser_telemetry": browser_telemetry,
297309
"credential": credential,
298310
"health_check_interval": health_check_interval,
299311
"health_checks": health_checks,
@@ -452,6 +464,7 @@ def login(
452464
self,
453465
id: str,
454466
*,
467+
browser_telemetry: Optional[connection_login_params.BrowserTelemetry] | Omit = omit,
455468
proxy: connection_login_params.Proxy | Omit = omit,
456469
record_session: bool | Omit = omit,
457470
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -468,6 +481,10 @@ def login(
468481
credentials are stored.
469482
470483
Args:
484+
browser_telemetry: Override the connection's default browser telemetry configuration for this
485+
login. When omitted, the connection's browser_telemetry default is used. Uses
486+
the exact create-browser configuration.
487+
471488
proxy: Proxy selection. Provide either id or name. The proxy must be in the same
472489
project as the resource referencing it. When selecting by name, the name must
473490
match exactly one active proxy in the project. Ambiguous names return a 400; use
@@ -490,6 +507,7 @@ def login(
490507
path_template("/auth/connections/{id}/login", id=id),
491508
body=maybe_transform(
492509
{
510+
"browser_telemetry": browser_telemetry,
493511
"proxy": proxy,
494512
"record_session": record_session,
495513
},
@@ -657,6 +675,7 @@ async def create(
657675
profile_name: str,
658676
allowed_domains: SequenceNotStr[str] | Omit = omit,
659677
auto_reauth: bool | Omit = omit,
678+
browser_telemetry: Optional[connection_create_params.BrowserTelemetry] | Omit = omit,
660679
credential: connection_create_params.Credential | Omit = omit,
661680
health_check_interval: int | Omit = omit,
662681
health_checks: bool | Omit = omit,
@@ -710,6 +729,10 @@ async def create(
710729
false, expired sessions are marked as `NEEDS_AUTH` instead of attempting
711730
re-auth. Defaults to true.
712731
732+
browser_telemetry: Browser telemetry configuration used by this connection's browser sessions by
733+
default. Uses the exact create-browser configuration. Can be overridden
734+
per-login.
735+
713736
credential:
714737
Reference to credentials for the auth connection. Use one of:
715738
@@ -757,6 +780,7 @@ async def create(
757780
"profile_name": profile_name,
758781
"allowed_domains": allowed_domains,
759782
"auto_reauth": auto_reauth,
783+
"browser_telemetry": browser_telemetry,
760784
"credential": credential,
761785
"health_check_interval": health_check_interval,
762786
"health_checks": health_checks,
@@ -814,6 +838,7 @@ async def update(
814838
*,
815839
allowed_domains: SequenceNotStr[str] | Omit = omit,
816840
auto_reauth: bool | Omit = omit,
841+
browser_telemetry: Optional[connection_update_params.BrowserTelemetry] | Omit = omit,
817842
credential: connection_update_params.Credential | Omit = omit,
818843
health_check_interval: int | Omit = omit,
819844
health_checks: bool | Omit = omit,
@@ -844,6 +869,10 @@ async def update(
844869
when `health_checks` is false. When false, expired sessions detected by a health
845870
check are marked as `NEEDS_AUTH` instead of attempting re-auth.
846871
872+
browser_telemetry: Browser telemetry configuration used by future browser sessions for this
873+
connection. Uses the exact create-browser configuration. Set enabled to false to
874+
disable telemetry.
875+
847876
credential:
848877
Reference to credentials for the auth connection. Use one of:
849878
@@ -885,6 +914,7 @@ async def update(
885914
{
886915
"allowed_domains": allowed_domains,
887916
"auto_reauth": auto_reauth,
917+
"browser_telemetry": browser_telemetry,
888918
"credential": credential,
889919
"health_check_interval": health_check_interval,
890920
"health_checks": health_checks,
@@ -1043,6 +1073,7 @@ async def login(
10431073
self,
10441074
id: str,
10451075
*,
1076+
browser_telemetry: Optional[connection_login_params.BrowserTelemetry] | Omit = omit,
10461077
proxy: connection_login_params.Proxy | Omit = omit,
10471078
record_session: bool | Omit = omit,
10481079
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -1059,6 +1090,10 @@ async def login(
10591090
credentials are stored.
10601091
10611092
Args:
1093+
browser_telemetry: Override the connection's default browser telemetry configuration for this
1094+
login. When omitted, the connection's browser_telemetry default is used. Uses
1095+
the exact create-browser configuration.
1096+
10621097
proxy: Proxy selection. Provide either id or name. The proxy must be in the same
10631098
project as the resource referencing it. When selecting by name, the name must
10641099
match exactly one active proxy in the project. Ambiguous names return a 400; use
@@ -1081,6 +1116,7 @@ async def login(
10811116
path_template("/auth/connections/{id}/login", id=id),
10821117
body=await async_maybe_transform(
10831118
{
1119+
"browser_telemetry": browser_telemetry,
10841120
"proxy": proxy,
10851121
"record_session": record_session,
10861122
},

src/kernel/types/auth/connection_create_params.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
from __future__ import annotations
44

5+
from typing import Optional
56
from typing_extensions import Required, TypedDict
67

78
from ..._types import SequenceNotStr
9+
from ..browsers.browser_telemetry_categories_config_param import BrowserTelemetryCategoriesConfigParam
810

9-
__all__ = ["ConnectionCreateParams", "Credential", "Proxy"]
11+
__all__ = ["ConnectionCreateParams", "BrowserTelemetry", "Credential", "Proxy"]
1012

1113

1214
class ConnectionCreateParams(TypedDict, total=False):
@@ -52,6 +54,13 @@ class ConnectionCreateParams(TypedDict, total=False):
5254
re-auth. Defaults to true.
5355
"""
5456

57+
browser_telemetry: Optional[BrowserTelemetry]
58+
"""
59+
Browser telemetry configuration used by this connection's browser sessions by
60+
default. Uses the exact create-browser configuration. Can be overridden
61+
per-login.
62+
"""
63+
5564
credential: Credential
5665
"""Reference to credentials for the auth connection. Use one of:
5766
@@ -102,6 +111,39 @@ class ConnectionCreateParams(TypedDict, total=False):
102111
"""
103112

104113

114+
class BrowserTelemetry(TypedDict, total=False):
115+
"""
116+
Browser telemetry configuration used by this connection's browser sessions by default. Uses the exact create-browser configuration. Can be overridden per-login.
117+
"""
118+
119+
browser: BrowserTelemetryCategoriesConfigParam
120+
"""Per-category capture flags.
121+
122+
The operational categories (control, connection, system, captcha) are captured
123+
whenever telemetry is enabled; set one to enabled=false to opt out. The CDP
124+
categories (console, network, page, interaction) and screenshot are off by
125+
default; set enabled=true to opt in. On create, provided categories layer onto
126+
the default set. On update, provided categories merge onto the session's current
127+
config; when no telemetry is active this falls back to the default set (matching
128+
create). If browser is omitted or empty, the default set is used. A browser
129+
config that disables every category stops capture on update and starts no
130+
capture on create.
131+
"""
132+
133+
enabled: bool
134+
"""Request shortcut for browser telemetry capture.
135+
136+
True enables capture; with no browser category settings it captures the default
137+
set (control, connection, system, captcha), and any browser category settings
138+
are layered onto that default set. On update, enabled=true resolves the config
139+
fresh from the default set plus any provided categories, replacing the session's
140+
current selection rather than merging onto it; omit enabled to merge categories
141+
onto the current selection instead. False stops capture on update and starts no
142+
capture on create. enabled=false cannot be combined with browser category
143+
settings.
144+
"""
145+
146+
105147
class Credential(TypedDict, total=False):
106148
"""Reference to credentials for the auth connection.
107149

src/kernel/types/auth/connection_login_params.py

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,23 @@
22

33
from __future__ import annotations
44

5+
from typing import Optional
56
from typing_extensions import TypedDict
67

7-
__all__ = ["ConnectionLoginParams", "Proxy"]
8+
from ..browsers.browser_telemetry_categories_config_param import BrowserTelemetryCategoriesConfigParam
9+
10+
__all__ = ["ConnectionLoginParams", "BrowserTelemetry", "Proxy"]
811

912

1013
class ConnectionLoginParams(TypedDict, total=False):
14+
browser_telemetry: Optional[BrowserTelemetry]
15+
"""Override the connection's default browser telemetry configuration for this
16+
login.
17+
18+
When omitted, the connection's browser_telemetry default is used. Uses the exact
19+
create-browser configuration.
20+
"""
21+
1122
proxy: Proxy
1223
"""Proxy selection.
1324
@@ -24,6 +35,40 @@ class ConnectionLoginParams(TypedDict, total=False):
2435
"""
2536

2637

38+
class BrowserTelemetry(TypedDict, total=False):
39+
"""Override the connection's default browser telemetry configuration for this login.
40+
41+
When omitted, the connection's browser_telemetry default is used. Uses the exact create-browser configuration.
42+
"""
43+
44+
browser: BrowserTelemetryCategoriesConfigParam
45+
"""Per-category capture flags.
46+
47+
The operational categories (control, connection, system, captcha) are captured
48+
whenever telemetry is enabled; set one to enabled=false to opt out. The CDP
49+
categories (console, network, page, interaction) and screenshot are off by
50+
default; set enabled=true to opt in. On create, provided categories layer onto
51+
the default set. On update, provided categories merge onto the session's current
52+
config; when no telemetry is active this falls back to the default set (matching
53+
create). If browser is omitted or empty, the default set is used. A browser
54+
config that disables every category stops capture on update and starts no
55+
capture on create.
56+
"""
57+
58+
enabled: bool
59+
"""Request shortcut for browser telemetry capture.
60+
61+
True enables capture; with no browser category settings it captures the default
62+
set (control, connection, system, captcha), and any browser category settings
63+
are layered onto that default set. On update, enabled=true resolves the config
64+
fresh from the default set plus any provided categories, replacing the session's
65+
current selection rather than merging onto it; omit enabled to merge categories
66+
onto the current selection instead. False stops capture on update and starts no
67+
capture on create. enabled=false cannot be combined with browser category
68+
settings.
69+
"""
70+
71+
2772
class Proxy(TypedDict, total=False):
2873
"""Proxy selection.
2974

src/kernel/types/auth/connection_update_params.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
from __future__ import annotations
44

5+
from typing import Optional
56
from typing_extensions import TypedDict
67

78
from ..._types import SequenceNotStr
9+
from ..browsers.browser_telemetry_categories_config_param import BrowserTelemetryCategoriesConfigParam
810

9-
__all__ = ["ConnectionUpdateParams", "Credential", "Proxy"]
11+
__all__ = ["ConnectionUpdateParams", "BrowserTelemetry", "Credential", "Proxy"]
1012

1113

1214
class ConnectionUpdateParams(TypedDict, total=False):
@@ -25,6 +27,13 @@ class ConnectionUpdateParams(TypedDict, total=False):
2527
re-auth.
2628
"""
2729

30+
browser_telemetry: Optional[BrowserTelemetry]
31+
"""
32+
Browser telemetry configuration used by future browser sessions for this
33+
connection. Uses the exact create-browser configuration. Set enabled to false to
34+
disable telemetry.
35+
"""
36+
2837
credential: Credential
2938
"""Reference to credentials for the auth connection. Use one of:
3039
@@ -63,6 +72,39 @@ class ConnectionUpdateParams(TypedDict, total=False):
6372
"""Whether to save credentials after every successful login"""
6473

6574

75+
class BrowserTelemetry(TypedDict, total=False):
76+
"""
77+
Browser telemetry configuration used by future browser sessions for this connection. Uses the exact create-browser configuration. Set enabled to false to disable telemetry.
78+
"""
79+
80+
browser: BrowserTelemetryCategoriesConfigParam
81+
"""Per-category capture flags.
82+
83+
The operational categories (control, connection, system, captcha) are captured
84+
whenever telemetry is enabled; set one to enabled=false to opt out. The CDP
85+
categories (console, network, page, interaction) and screenshot are off by
86+
default; set enabled=true to opt in. On create, provided categories layer onto
87+
the default set. On update, provided categories merge onto the session's current
88+
config; when no telemetry is active this falls back to the default set (matching
89+
create). If browser is omitted or empty, the default set is used. A browser
90+
config that disables every category stops capture on update and starts no
91+
capture on create.
92+
"""
93+
94+
enabled: bool
95+
"""Request shortcut for browser telemetry capture.
96+
97+
True enables capture; with no browser category settings it captures the default
98+
set (control, connection, system, captcha), and any browser category settings
99+
are layered onto that default set. On update, enabled=true resolves the config
100+
fresh from the default set plus any provided categories, replacing the session's
101+
current selection rather than merging onto it; omit enabled to merge categories
102+
onto the current selection instead. False stops capture on update and starts no
103+
capture on create. enabled=false cannot be combined with browser category
104+
settings.
105+
"""
106+
107+
66108
class Credential(TypedDict, total=False):
67109
"""Reference to credentials for the auth connection.
68110

0 commit comments

Comments
 (0)