Skip to content

Commit 66f6eaf

Browse files
feat: Expose captcha task and challenge outcomes
Stainless-Generated-From: e690865cea8183ed670fdd3f7617e0541adfe810
1 parent 40d5209 commit 66f6eaf

4 files changed

Lines changed: 210 additions & 7 deletions

File tree

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ Types:
130130

131131
- <code><a href="./src/resources/browsers/telemetry.ts">BrowserAPICallEvent</a></code>
132132
- <code><a href="./src/resources/browsers/telemetry.ts">BrowserCallStack</a></code>
133+
- <code><a href="./src/resources/browsers/telemetry.ts">BrowserCaptchaChallengeResultEvent</a></code>
133134
- <code><a href="./src/resources/browsers/telemetry.ts">BrowserCaptchaSolveResultEvent</a></code>
135+
- <code><a href="./src/resources/browsers/telemetry.ts">BrowserCaptchaSolveStartedEvent</a></code>
134136
- <code><a href="./src/resources/browsers/telemetry.ts">BrowserCdpCommandEvent</a></code>
135137
- <code><a href="./src/resources/browsers/telemetry.ts">BrowserCdpCommandMethod</a></code>
136138
- <code><a href="./src/resources/browsers/telemetry.ts">BrowserCdpConnectEvent</a></code>

src/resources/browsers/browsers.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ import * as TelemetryAPI from './telemetry';
5555
import {
5656
BrowserAPICallEvent,
5757
BrowserCallStack,
58+
BrowserCaptchaChallengeResultEvent,
5859
BrowserCaptchaSolveResultEvent,
60+
BrowserCaptchaSolveStartedEvent,
5961
BrowserCdpCommandEvent,
6062
BrowserCdpCommandMethod,
6163
BrowserCdpConnectEvent,
@@ -1650,7 +1652,9 @@ export declare namespace Browsers {
16501652
TelemetryAPITelemetry as Telemetry,
16511653
type BrowserAPICallEvent as BrowserAPICallEvent,
16521654
type BrowserCallStack as BrowserCallStack,
1655+
type BrowserCaptchaChallengeResultEvent as BrowserCaptchaChallengeResultEvent,
16531656
type BrowserCaptchaSolveResultEvent as BrowserCaptchaSolveResultEvent,
1657+
type BrowserCaptchaSolveStartedEvent as BrowserCaptchaSolveStartedEvent,
16541658
type BrowserCdpCommandEvent as BrowserCdpCommandEvent,
16551659
type BrowserCdpCommandMethod as BrowserCdpCommandMethod,
16561660
type BrowserCdpConnectEvent as BrowserCdpConnectEvent,

src/resources/browsers/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ export {
9090
Telemetry,
9191
type BrowserAPICallEvent,
9292
type BrowserCallStack,
93+
type BrowserCaptchaChallengeResultEvent,
9394
type BrowserCaptchaSolveResultEvent,
95+
type BrowserCaptchaSolveStartedEvent,
9496
type BrowserCdpCommandEvent,
9597
type BrowserCdpCommandMethod,
9698
type BrowserCdpConnectEvent,

src/resources/browsers/telemetry.ts

Lines changed: 202 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,99 @@ export namespace BrowserCallStack {
192192
}
193193
}
194194

195+
/**
196+
* A visible captcha challenge reached a terminal outcome.
197+
*/
198+
export interface BrowserCaptchaChallengeResultEvent {
199+
category: 'captcha';
200+
201+
/**
202+
* Per-challenge payload. This event is emitted once per challenge and determines
203+
* its overall outcome; captcha_solve_started and captcha_solve_result describe
204+
* individual tasks and may occur multiple times within the challenge.
205+
*/
206+
data: BrowserCaptchaChallengeResultEvent.Data;
207+
208+
/**
209+
* Provenance metadata identifying which producer emitted the event.
210+
*/
211+
source: BrowserEventSource;
212+
213+
/**
214+
* Event timestamp in Unix microseconds.
215+
*/
216+
ts: number;
217+
218+
type: 'captcha_challenge_result';
219+
220+
/**
221+
* True if the data field was truncated due to size limits.
222+
*/
223+
truncated?: boolean;
224+
}
225+
226+
export namespace BrowserCaptchaChallengeResultEvent {
227+
/**
228+
* Per-challenge payload. This event is emitted once per challenge and determines
229+
* its overall outcome; captcha_solve_started and captcha_solve_result describe
230+
* individual tasks and may occur multiple times within the challenge.
231+
*/
232+
export interface Data {
233+
/**
234+
* Captcha kind. Enterprise reCAPTCHA variants are grouped into their version
235+
* bucket (recaptcha_v2 or recaptcha_v3), press-and-hold challenges use
236+
* press_and_hold, and unlisted kinds use other.
237+
*/
238+
captcha_type:
239+
| 'hcaptcha'
240+
| 'recaptcha_v2'
241+
| 'recaptcha_v3'
242+
| 'turnstile'
243+
| 'geetest'
244+
| 'press_and_hold'
245+
| 'other';
246+
247+
/**
248+
* Opaque identifier shared by events for one visible challenge. An image-grid
249+
* captcha may create multiple task_id values for one challenge_id. The same value
250+
* may continue across a page reload when the challenge episode continues. It does
251+
* not indicate task ordering or challenge completion.
252+
*/
253+
challenge_id: string;
254+
255+
/**
256+
* Wall-clock duration from the challenge appearing to its terminal outcome,
257+
* covering every solver attempt in between.
258+
*/
259+
duration_ms: number;
260+
261+
/**
262+
* Terminal outcome of the visible challenge. solved: the page observed the
263+
* challenge clear after a solver attempt. failure: a terminal solver failure
264+
* occurred, or all attempts ended while the challenge remained. timeout: the
265+
* challenge-level wait budget expired while the challenge remained. abandoned:
266+
* observation ended without an attributable terminal challenge outcome. This
267+
* includes a dismissed widget or page unload without a solved signal or terminal
268+
* solver outcome, and a token appearing while multiple same-provider challenges
269+
* are open, because the producer cannot attribute that token to this visible
270+
* challenge. A captcha_solve_result with the same challenge_id may therefore
271+
* report success while the challenge result reports abandoned. A solved challenge
272+
* does not prove the site accepted the token or that the guarded action succeeded.
273+
*/
274+
status: 'solved' | 'failure' | 'timeout' | 'abandoned';
275+
276+
/**
277+
* Host of the page where the challenge appeared.
278+
*/
279+
website_host?: string;
280+
281+
/**
282+
* Path of the page where the challenge appeared. Query string excluded.
283+
*/
284+
website_path?: string;
285+
}
286+
}
287+
195288
/**
196289
* A captcha solve attempt reached a terminal outcome.
197290
*/
@@ -221,13 +314,23 @@ export interface BrowserCaptchaSolveResultEvent {
221314
export namespace BrowserCaptchaSolveResultEvent {
222315
export interface Data {
223316
/**
224-
* Captcha vendor family. Provider-specific task names are normalized into this
225-
* set; anything not covered is reported as other.
226-
*/
227-
captcha_type: 'hcaptcha' | 'recaptcha_v2' | 'recaptcha_v3' | 'turnstile' | 'geetest' | 'other';
317+
* Captcha kind. Enterprise reCAPTCHA variants are grouped into their version
318+
* bucket (recaptcha_v2 or recaptcha_v3), press-and-hold challenges use
319+
* press_and_hold, and unlisted kinds use other.
320+
*/
321+
captcha_type:
322+
| 'hcaptcha'
323+
| 'recaptcha_v2'
324+
| 'recaptcha_v3'
325+
| 'turnstile'
326+
| 'geetest'
327+
| 'press_and_hold'
328+
| 'other';
228329

229330
/**
230-
* Wall-clock duration from solve start to terminal outcome.
331+
* Wall-clock duration from solve start to terminal outcome. Authoritative solve
332+
* timing; do not derive it from the gap to a captcha_solve_started event, whose
333+
* delivery and ordering are not guaranteed.
231334
*/
232335
duration_ms: number;
233336

@@ -239,14 +342,22 @@ export namespace BrowserCaptchaSolveResultEvent {
239342
*/
240343
status: 'success' | 'failure' | 'timeout' | 'abandoned';
241344

345+
/**
346+
* Opaque identifier shared by events for one visible challenge. An image-grid
347+
* captcha may create multiple task_id values for one challenge_id. The same value
348+
* may continue across a page reload when the challenge episode continues. It does
349+
* not indicate task ordering or challenge completion.
350+
*/
351+
challenge_id?: string;
352+
242353
/**
243354
* Solver-specific error code on failure (e.g. ERROR_CAPTCHA_UNSOLVABLE). Absent on
244355
* success.
245356
*/
246357
error_code?: string;
247358

248359
/**
249-
* Solver-assigned identifier. Opaque, useful for support cross-references.
360+
* Opaque identifier shared with the matching captcha_solve_started.
250361
*/
251362
task_id?: string;
252363

@@ -262,6 +373,86 @@ export namespace BrowserCaptchaSolveResultEvent {
262373
}
263374
}
264375

376+
/**
377+
* A captcha solver accepted a task.
378+
*/
379+
export interface BrowserCaptchaSolveStartedEvent {
380+
category: 'captcha';
381+
382+
/**
383+
* Per-task payload. A visible challenge may create multiple tasks. When present,
384+
* task_id correlates this event with a captcha_solve_result, while challenge_id
385+
* groups tasks from the same challenge. Events may arrive out of order or be
386+
* absent, so their arrival does not indicate current solve state.
387+
*/
388+
data: BrowserCaptchaSolveStartedEvent.Data;
389+
390+
/**
391+
* Provenance metadata identifying which producer emitted the event.
392+
*/
393+
source: BrowserEventSource;
394+
395+
/**
396+
* Event timestamp in Unix microseconds.
397+
*/
398+
ts: number;
399+
400+
type: 'captcha_solve_started';
401+
402+
/**
403+
* True if the data field was truncated due to size limits.
404+
*/
405+
truncated?: boolean;
406+
}
407+
408+
export namespace BrowserCaptchaSolveStartedEvent {
409+
/**
410+
* Per-task payload. A visible challenge may create multiple tasks. When present,
411+
* task_id correlates this event with a captcha_solve_result, while challenge_id
412+
* groups tasks from the same challenge. Events may arrive out of order or be
413+
* absent, so their arrival does not indicate current solve state.
414+
*/
415+
export interface Data {
416+
/**
417+
* Captcha kind. Enterprise reCAPTCHA variants are grouped into their version
418+
* bucket (recaptcha_v2 or recaptcha_v3), press-and-hold challenges use
419+
* press_and_hold, and unlisted kinds use other.
420+
*/
421+
captcha_type:
422+
| 'hcaptcha'
423+
| 'recaptcha_v2'
424+
| 'recaptcha_v3'
425+
| 'turnstile'
426+
| 'geetest'
427+
| 'press_and_hold'
428+
| 'other';
429+
430+
/**
431+
* Opaque identifier shared by events for one visible challenge. An image-grid
432+
* captcha may create multiple task_id values for one challenge_id. The same value
433+
* may continue across a page reload when the challenge episode continues. It does
434+
* not indicate task ordering or challenge completion.
435+
*/
436+
challenge_id?: string;
437+
438+
/**
439+
* Opaque identifier shared with the matching captcha_solve_result.
440+
*/
441+
task_id?: string;
442+
443+
/**
444+
* Host of the page where the captcha is being solved. May be empty for solver
445+
* tasks that carry no page URL.
446+
*/
447+
website_host?: string;
448+
449+
/**
450+
* Path of the page where the captcha is being solved. Query string excluded.
451+
*/
452+
website_path?: string;
453+
}
454+
}
455+
265456
/**
266457
* A browser-control command a client sent over the CDP WebSocket proxy: input
267458
* gestures, navigation, dialog handling, file selection and screenshots.
@@ -4346,7 +4537,7 @@ export namespace BrowserSystemOomKillEvent {
43464537
*/
43474538
export interface BrowserTelemetryCategoriesConfig {
43484539
/**
4349-
* Captcha solve attempt outcomes. On by default.
4540+
* Captcha solver tasks and visible challenge outcomes. On by default.
43504541
*/
43514542
captcha?: BrowserTelemetryCategoryConfig;
43524543

@@ -4516,7 +4707,9 @@ export type BrowserTelemetryEvent =
45164707
| BrowserCdpDisconnectEvent
45174708
| BrowserLiveViewConnectEvent
45184709
| BrowserLiveViewDisconnectEvent
4710+
| BrowserCaptchaSolveStartedEvent
45194711
| BrowserCaptchaSolveResultEvent
4712+
| BrowserCaptchaChallengeResultEvent
45204713
| BrowserSystemOomKillEvent
45214714
| BrowserServiceCrashedEvent;
45224715

@@ -4660,7 +4853,9 @@ export declare namespace Telemetry {
46604853
export {
46614854
type BrowserAPICallEvent as BrowserAPICallEvent,
46624855
type BrowserCallStack as BrowserCallStack,
4856+
type BrowserCaptchaChallengeResultEvent as BrowserCaptchaChallengeResultEvent,
46634857
type BrowserCaptchaSolveResultEvent as BrowserCaptchaSolveResultEvent,
4858+
type BrowserCaptchaSolveStartedEvent as BrowserCaptchaSolveStartedEvent,
46644859
type BrowserCdpCommandEvent as BrowserCdpCommandEvent,
46654860
type BrowserCdpCommandMethod as BrowserCdpCommandMethod,
46664861
type BrowserCdpConnectEvent as BrowserCdpConnectEvent,

0 commit comments

Comments
 (0)