@corbado/observe 0.13.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/script.global.js +1 -1
- package/dist/index.d.mts +266 -102
- package/dist/index.d.ts +266 -102
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ declare enum AuthEventName {
|
|
|
24
24
|
SubflowError = "subflow_error",
|
|
25
25
|
SubflowStarted = "subflow_started",
|
|
26
26
|
SubflowFinished = "subflow_finished",
|
|
27
|
+
/** Client-side flow enrichment (the server accepts `session_enriched` as a legacy alias). */
|
|
28
|
+
FlowEnriched = "flow_enriched",
|
|
27
29
|
Conversion = "conversion"
|
|
28
30
|
}
|
|
29
31
|
interface BaseEvent {
|
|
@@ -51,6 +53,15 @@ interface BaseEvent {
|
|
|
51
53
|
type UserReference = {
|
|
52
54
|
userId?: string;
|
|
53
55
|
identifier?: string;
|
|
56
|
+
/** Shared UUID used to link sessions across environments. */
|
|
57
|
+
crossEnvironmentTransactionID?: string;
|
|
58
|
+
};
|
|
59
|
+
type LegacyUserReference = {
|
|
60
|
+
/** @deprecated Use tracker.setUser() within the active flow instead. */
|
|
61
|
+
userId?: string;
|
|
62
|
+
/** @deprecated Use tracker.setUser() within the active flow instead. */
|
|
63
|
+
identifier?: string;
|
|
64
|
+
/** @deprecated Use tracker.setUser() within the active flow instead. */
|
|
54
65
|
crossEnvironmentTransactionID?: string;
|
|
55
66
|
};
|
|
56
67
|
/**
|
|
@@ -83,11 +94,11 @@ type Conversion = {
|
|
|
83
94
|
name: string;
|
|
84
95
|
/** Where the conversion happened, e.g. `"checkout"` or `"product-page"`. */
|
|
85
96
|
touchpoint?: string;
|
|
86
|
-
} &
|
|
97
|
+
} & LegacyUserReference;
|
|
87
98
|
type FlowFinished = {
|
|
88
99
|
flowName: FlowType;
|
|
89
100
|
explicitOutcome?: "skipped" | "visible-auto-skip" | "invisible";
|
|
90
|
-
} &
|
|
101
|
+
} & LegacyUserReference;
|
|
91
102
|
type FlowReset = {
|
|
92
103
|
flowName?: FlowType;
|
|
93
104
|
};
|
|
@@ -97,7 +108,7 @@ type MultiFlowReset = {
|
|
|
97
108
|
type FlowAutoFinished = {
|
|
98
109
|
flowName: FlowType;
|
|
99
110
|
finishedByFlowName: FlowType;
|
|
100
|
-
} &
|
|
111
|
+
} & LegacyUserReference;
|
|
101
112
|
type AuthMethodDecisionStarted = {
|
|
102
113
|
decisionName: string;
|
|
103
114
|
options: (AuthMethodType | (string & {}))[];
|
|
@@ -105,15 +116,16 @@ type AuthMethodDecisionStarted = {
|
|
|
105
116
|
};
|
|
106
117
|
type AuthMethodDecisionFinished = {
|
|
107
118
|
decisionName: string;
|
|
108
|
-
|
|
119
|
+
/** Optional — when omitted, the backend completes the open decision of the same name using its declared options (classifier follow-up). */
|
|
120
|
+
options?: (AuthMethodType | (string & {}))[];
|
|
109
121
|
explicitDecisionValue?: string;
|
|
110
122
|
};
|
|
111
123
|
type ProvideIdentifierStart = {};
|
|
112
|
-
type ProvideIdentifierError =
|
|
124
|
+
type ProvideIdentifierError = LegacyUserReference & {
|
|
113
125
|
errorCode?: string;
|
|
114
126
|
error?: any;
|
|
115
127
|
};
|
|
116
|
-
type ProvideIdentifierFinish =
|
|
128
|
+
type ProvideIdentifierFinish = LegacyUserReference & {
|
|
117
129
|
identifierPrefillingCreated?: boolean;
|
|
118
130
|
};
|
|
119
131
|
type PasskeyLoginClientError = {
|
|
@@ -125,7 +137,7 @@ type PasskeyLoginStartable = {
|
|
|
125
137
|
type PasskeyLoginSubmitted = {
|
|
126
138
|
assertionResponse: string;
|
|
127
139
|
};
|
|
128
|
-
type PasskeyLoginFinish =
|
|
140
|
+
type PasskeyLoginFinish = LegacyUserReference & {};
|
|
129
141
|
type AuthDecisionStarted = {
|
|
130
142
|
decisionName: string;
|
|
131
143
|
options: string[];
|
|
@@ -136,6 +148,13 @@ type AuthDecisionFinished = {
|
|
|
136
148
|
explicitDecisionValue?: string;
|
|
137
149
|
};
|
|
138
150
|
type StepOptions = {
|
|
151
|
+
/** Semantic control that explicitly initiated this step; omitted when unknown. */
|
|
152
|
+
initiator?: LowEventInitiator;
|
|
153
|
+
/** @internal Session captured with the operation start; never sent as event metadata. */
|
|
154
|
+
captureSessionId?: string;
|
|
155
|
+
/** @internal Capture anchor supplied by operation helpers. */
|
|
156
|
+
subflowStartEventId?: string;
|
|
157
|
+
/** @deprecated Use tracker.setUser() within the active flow instead. */
|
|
139
158
|
userReference?: UserReference;
|
|
140
159
|
explicitTimestamp?: number;
|
|
141
160
|
/** Per-call experiment override (experiment key → variant), merged over the persistent assignments. */
|
|
@@ -165,7 +184,22 @@ interface CustomEvent extends BaseEvent {
|
|
|
165
184
|
data?: Record<string, unknown>;
|
|
166
185
|
}
|
|
167
186
|
type Event = PredefinedEvent | CustomEvent;
|
|
187
|
+
type LowEventSourceKind = "input" | "input-group" | "ceremony" | "window";
|
|
188
|
+
type LowEventFieldRole = "password" | "identifier" | "otp" | "data";
|
|
189
|
+
type LowEventInitiator = `input-${LowEventFieldRole}` | "passkey-button" | "automatic" | "unknown";
|
|
190
|
+
type LowEventInputEffect = "fill" | "modify" | "clear";
|
|
168
191
|
interface LowEvent {
|
|
192
|
+
/** Per-page uint32 observation order; reserved before batching and retained on retry. */
|
|
193
|
+
captureSeq?: number;
|
|
194
|
+
captureVersion?: number;
|
|
195
|
+
pageId?: string;
|
|
196
|
+
initiator?: LowEventInitiator;
|
|
197
|
+
inputEffect?: LowEventInputEffect;
|
|
198
|
+
/** Immutable delivery identity; absent on legacy records. */
|
|
199
|
+
id?: string;
|
|
200
|
+
subflowStartEventId?: string;
|
|
201
|
+
sourceKind?: LowEventSourceKind;
|
|
202
|
+
fieldRole?: LowEventFieldRole;
|
|
169
203
|
lowType: string;
|
|
170
204
|
ts: number;
|
|
171
205
|
durationMs?: number;
|
|
@@ -220,6 +254,10 @@ interface EventBatchMeta {
|
|
|
220
254
|
configVersion?: string;
|
|
221
255
|
}
|
|
222
256
|
interface EventMeta {
|
|
257
|
+
initiator?: LowEventInitiator;
|
|
258
|
+
captureVersion?: number;
|
|
259
|
+
pageId?: string;
|
|
260
|
+
subflowStartEventId?: string;
|
|
223
261
|
trackingSourcePath: string;
|
|
224
262
|
/**
|
|
225
263
|
* Per-tab id (uuidv7, `sessionStorage`-scoped) of the tab that CREATED this event, stamped at
|
|
@@ -229,6 +267,8 @@ interface EventMeta {
|
|
|
229
267
|
tabId?: string;
|
|
230
268
|
}
|
|
231
269
|
interface EventBatch {
|
|
270
|
+
/** Request durable acceptance for replayable lows. */
|
|
271
|
+
deliveryAck?: boolean;
|
|
232
272
|
sessionId: string;
|
|
233
273
|
events: Event[];
|
|
234
274
|
sdk: SdkInfo;
|
|
@@ -324,6 +364,8 @@ interface SdkReliabilityConfig {
|
|
|
324
364
|
flushIntervalMs: number;
|
|
325
365
|
/** Persist queued events to a durable outbox so they survive reloads, redirects and context switches. */
|
|
326
366
|
durableOutbox: boolean;
|
|
367
|
+
/** Persist lows in a separate bounded outbox; defaults to disabled for older configs. */
|
|
368
|
+
durableLowOutbox?: boolean;
|
|
327
369
|
/** Use keepalive/sendBeacon transport for flushes triggered during page unload. */
|
|
328
370
|
beaconKeepalive: boolean;
|
|
329
371
|
/** Maintain session continuity across reloads/tabs by persisting the session id in localStorage. */
|
|
@@ -427,6 +469,41 @@ interface CreateLoggerOptions {
|
|
|
427
469
|
}
|
|
428
470
|
declare function createLogger(options: CreateLoggerOptions): Logger;
|
|
429
471
|
|
|
472
|
+
type WindowCaptureContext = Pick<LowEvent, "subflowStartEventId" | "fieldRole" | "initiator"> & {
|
|
473
|
+
sessionId?: string;
|
|
474
|
+
};
|
|
475
|
+
/** One passive observer per tracker. Field/ceremony collectors register context, not DOM listeners. */
|
|
476
|
+
declare class SharedWindowObserver {
|
|
477
|
+
private logger;
|
|
478
|
+
private enqueue;
|
|
479
|
+
private flushKeepalive;
|
|
480
|
+
private inputs;
|
|
481
|
+
private ceremonies;
|
|
482
|
+
private removers;
|
|
483
|
+
private lastBlur?;
|
|
484
|
+
private bracket?;
|
|
485
|
+
private unrelatedPointerAt;
|
|
486
|
+
private destroyed;
|
|
487
|
+
private viewportContext;
|
|
488
|
+
private resize;
|
|
489
|
+
private scroll;
|
|
490
|
+
constructor(logger: Logger, enqueue: (low: LowEvent, sessionId?: string) => void, flushKeepalive: () => void);
|
|
491
|
+
registerInputs(fields: readonly HTMLInputElement[], context: () => WindowCaptureContext, flush: () => void): () => void;
|
|
492
|
+
beginCeremony(context: WindowCaptureContext): {
|
|
493
|
+
settle: (tailMs: number) => void;
|
|
494
|
+
destroy: () => void;
|
|
495
|
+
};
|
|
496
|
+
private context;
|
|
497
|
+
private findInput;
|
|
498
|
+
/** Flush all registered input batches before a high-level lifecycle boundary. */
|
|
499
|
+
flushInputs(): void;
|
|
500
|
+
private emit;
|
|
501
|
+
private listen;
|
|
502
|
+
private extendViewport;
|
|
503
|
+
private observeNavigation;
|
|
504
|
+
destroy(): void;
|
|
505
|
+
}
|
|
506
|
+
|
|
430
507
|
/**
|
|
431
508
|
* Where low events go. `flushKeepalive` is requested on `pagehide` teardown so lows batched after
|
|
432
509
|
* the queue's own lifecycle flush still get out; operations wire it to the client's
|
|
@@ -434,49 +511,27 @@ declare function createLogger(options: CreateLoggerOptions): Logger;
|
|
|
434
511
|
* (default true = historical behavior, can be disabled remotely).
|
|
435
512
|
*/
|
|
436
513
|
interface LowEventSink {
|
|
514
|
+
reserveCaptureSeq?(): number;
|
|
437
515
|
enqueueLowEvent(low: LowEvent): void;
|
|
438
516
|
flushKeepalive(): void;
|
|
517
|
+
registerInputs?(fields: readonly HTMLInputElement[], flush: () => void): () => void;
|
|
518
|
+
beginCeremony?(initiator?: LowEventInitiator): {
|
|
519
|
+
settle(tailMs: number): void;
|
|
520
|
+
destroy(): void;
|
|
521
|
+
};
|
|
439
522
|
}
|
|
440
523
|
|
|
441
|
-
/**
|
|
442
|
-
* Collects window-scoped "low" events around a WebAuthn ceremony: window focus/blur, document
|
|
443
|
-
* visibility changes and visualviewport resize/scroll (batched). The listener set mirrors
|
|
444
|
-
* connect-react's `installLowEventWindowListeners`; the event names match
|
|
445
|
-
* {@link LowEventInputTracker}'s vocabulary.
|
|
446
|
-
*
|
|
447
|
-
* Unlike {@link LowEventInputTracker} (anchored to an input field, active for the owning
|
|
448
|
-
* operation's lifetime), this tracker is armed only for the ceremony window: the owning operation
|
|
449
|
-
* arms it on `ceremony.start()` and schedules disarming shortly after the ceremony settles, so
|
|
450
|
-
* signals from the picker closing (focus return, dismiss animations) are still captured.
|
|
451
|
-
*
|
|
452
|
-
* Never triggers a flush — low events ride along on the queue's existing flush triggers.
|
|
453
|
-
*/
|
|
524
|
+
/** Ceremony context lease on the shared observer. Never installs its own window listeners. */
|
|
454
525
|
declare class LowEventWindowTracker {
|
|
455
526
|
private logger;
|
|
456
527
|
private sink;
|
|
457
|
-
private
|
|
528
|
+
private lease?;
|
|
458
529
|
private destroyed;
|
|
459
|
-
private disarmTimer;
|
|
460
|
-
private resizeBatcher;
|
|
461
|
-
private scrollBatcher;
|
|
462
|
-
private boundHandlers;
|
|
463
530
|
constructor(logger: Logger, sink: LowEventSink);
|
|
464
|
-
|
|
465
|
-
arm(): void;
|
|
466
|
-
/**
|
|
467
|
-
* Disarm after `delayMs`. The tail keeps the listeners alive briefly after the ceremony settles:
|
|
468
|
-
* focus return and picker dismiss animations land after the WebAuthn promise resolves/rejects.
|
|
469
|
-
*/
|
|
531
|
+
arm(initiator?: LowEventInitiator, conditional?: boolean): void;
|
|
470
532
|
scheduleDisarm(delayMs: number): void;
|
|
471
|
-
/** Stop listening and flush the viewport batchers into the queue. Idempotent. */
|
|
472
533
|
disarm(): void;
|
|
473
|
-
/** Disarm and refuse any further arming; for the owning operation's destroy(). */
|
|
474
534
|
destroy(): void;
|
|
475
|
-
private cancelScheduledDisarm;
|
|
476
|
-
private pushLow;
|
|
477
|
-
private handleVisibilityChange;
|
|
478
|
-
private flushBatchers;
|
|
479
|
-
private wrapHandler;
|
|
480
535
|
}
|
|
481
536
|
|
|
482
537
|
/**
|
|
@@ -494,13 +549,34 @@ type StepHelper<TStart = {}, TFinished = {}, TTypedError = never> = {
|
|
|
494
549
|
declare abstract class OperationFull {
|
|
495
550
|
private tracker;
|
|
496
551
|
private operationName;
|
|
552
|
+
private startReference?;
|
|
553
|
+
private captureSpecType?;
|
|
554
|
+
private captureSessionId?;
|
|
555
|
+
private readonly lowFlushers;
|
|
556
|
+
private readonly lowPrefillCapturers;
|
|
557
|
+
protected lowEventSink(sourceKind: LowEventSourceKind, fieldRole?: LowEventFieldRole): LowEventSink;
|
|
558
|
+
protected createLowCollector<T extends {
|
|
559
|
+
capturePrefill(newCapture?: boolean): void;
|
|
560
|
+
}>(create: () => T): T | undefined;
|
|
561
|
+
protected registerLowFlusher(flush: () => void): void;
|
|
562
|
+
private captureOptions;
|
|
497
563
|
constructor(tracker: CorbadoTracker, operationName: SubflowType);
|
|
498
564
|
/**
|
|
499
|
-
* Emits subflow_started
|
|
500
|
-
* `explicitSpecType`, `ignoreAsInteraction`)
|
|
501
|
-
*
|
|
565
|
+
* Emits an additional subflow_started; construction already emits the initial start.
|
|
566
|
+
* `data` supports SubflowTrigger fields (`actor`, `explicitSpecType`, `ignoreAsInteraction`)
|
|
567
|
+
* plus free-form extras; see SubflowTrigger for programmatic interaction suppression.
|
|
502
568
|
*/
|
|
503
569
|
subflowStart(data: any, options?: StepOptions): void;
|
|
570
|
+
/**
|
|
571
|
+
* Capture values initialized by the application after constructing this operation, without
|
|
572
|
+
* dispatching DOM input events. Call immediately after initialization, before user editing.
|
|
573
|
+
* Each field/group emits at most one prefill per subflow start; values are never recorded.
|
|
574
|
+
*/
|
|
575
|
+
capturePrefill(): void;
|
|
576
|
+
private captureInputPrefills;
|
|
577
|
+
/**
|
|
578
|
+
* @deprecated `subflow_trigger` will be removed in the next major version.
|
|
579
|
+
*/
|
|
504
580
|
trigger(data: SubflowTrigger, options?: StepOptions): void;
|
|
505
581
|
customStep<TStart = {}, TFinished = {}>(stepName: string): StepHelper<TStart, TFinished>;
|
|
506
582
|
protected subflowStepStarted(stepName: string, data: any, options?: StepOptions, ignoreAsInteraction?: boolean): void;
|
|
@@ -554,12 +630,16 @@ type PasskeyLoginPostResponseStart = {
|
|
|
554
630
|
*/
|
|
555
631
|
assertionResponse?: string;
|
|
556
632
|
};
|
|
633
|
+
type PasskeyLoginOperationConfig = {
|
|
634
|
+
/** The classifier drops the attempt if no spec type arrives on any of its events — supply it here or on a step's start data as soon as known. */
|
|
635
|
+
explicitSpecType?: PasskeyOperationLoginExplicitSpecType;
|
|
636
|
+
};
|
|
557
637
|
declare class PasskeyLoginOperationFull extends OperationFull {
|
|
558
638
|
readonly getOptions: StepHelper<PasskeyLoginGetOptionsStart, PasskeyLoginGetOptionsFinished>;
|
|
559
639
|
readonly ceremony: StepHelper<PasskeyLoginCeremonyStart, PasskeyLoginCeremonyFinished>;
|
|
560
640
|
readonly postResponse: StepHelper<PasskeyLoginPostResponseStart>;
|
|
561
641
|
private lowEventTracker;
|
|
562
|
-
constructor(tracker: CorbadoTracker);
|
|
642
|
+
constructor(tracker: CorbadoTracker, config?: PasskeyLoginOperationConfig);
|
|
563
643
|
/**
|
|
564
644
|
* @deprecated `subflow_trigger` is not supported for passkey-login and will be removed in the
|
|
565
645
|
* next major version.
|
|
@@ -576,13 +656,22 @@ type EmailOTPOperationPostResponseStart = {
|
|
|
576
656
|
explicitSpecType?: EmailOTPOperationSpecType;
|
|
577
657
|
};
|
|
578
658
|
type EmailOTPOperationConfig = {
|
|
659
|
+
/** Email domain only, no full address. */
|
|
660
|
+
emailDomain?: string;
|
|
661
|
+
/** One real input, or an ordered group representing one OTP. */
|
|
662
|
+
inputHtmlField?: HTMLInputElement;
|
|
663
|
+
inputHtmlFields?: HTMLInputElement[];
|
|
579
664
|
explicitSpecType?: EmailOTPOperationSpecType;
|
|
580
665
|
};
|
|
581
666
|
declare class EmailOtpOperationFull extends OperationFull {
|
|
667
|
+
private lowEventTracker?;
|
|
582
668
|
readonly send: StepHelper<EmailOTPOperationSendOTPStart>;
|
|
583
669
|
readonly postResponse: StepHelper<EmailOTPOperationPostResponseStart>;
|
|
584
670
|
readonly resend: StepHelper;
|
|
585
671
|
constructor(tracker: CorbadoTracker, config?: EmailOTPOperationConfig);
|
|
672
|
+
/** Rebind the ordered OTP group without starting a new subflow. An empty list detaches it. */
|
|
673
|
+
setInputFields(fields: readonly HTMLInputElement[]): void;
|
|
674
|
+
destroy(): void;
|
|
586
675
|
}
|
|
587
676
|
|
|
588
677
|
type SmsOTPOperationSpecType = "sms-otp-login" | "sms-otp-enrollment";
|
|
@@ -590,12 +679,19 @@ type SmsOTPOperationPostResponseStart = {
|
|
|
590
679
|
explicitSpecType?: SmsOTPOperationSpecType;
|
|
591
680
|
};
|
|
592
681
|
type SmsOTPOperationConfig = {
|
|
682
|
+
/** One real input, or an ordered group representing one OTP. */
|
|
683
|
+
inputHtmlField?: HTMLInputElement;
|
|
684
|
+
inputHtmlFields?: HTMLInputElement[];
|
|
593
685
|
explicitSpecType?: SmsOTPOperationSpecType;
|
|
594
686
|
};
|
|
595
687
|
declare class SmsOtpOperationFull extends OperationFull {
|
|
688
|
+
private lowEventTracker?;
|
|
596
689
|
readonly postResponse: StepHelper<SmsOTPOperationPostResponseStart>;
|
|
597
690
|
readonly resend: StepHelper;
|
|
598
691
|
constructor(tracker: CorbadoTracker, config?: SmsOTPOperationConfig);
|
|
692
|
+
/** Rebind the ordered OTP group without starting a new subflow. An empty list detaches it. */
|
|
693
|
+
setInputFields(fields: readonly HTMLInputElement[]): void;
|
|
694
|
+
destroy(): void;
|
|
599
695
|
}
|
|
600
696
|
|
|
601
697
|
type EmailLinkOperationSpecType = "email-link-login" | "email-link-enrollment";
|
|
@@ -605,11 +701,15 @@ type EmailLinkOperationSendStart = {
|
|
|
605
701
|
type EmailLinkOperationPostResponseStart = {
|
|
606
702
|
explicitSpecType?: EmailLinkOperationSpecType;
|
|
607
703
|
};
|
|
704
|
+
type EmailLinkOperationConfig = {
|
|
705
|
+
/** The classifier drops the attempt if no spec type arrives on any of its events — supply it here or on a step's start data as soon as known. */
|
|
706
|
+
explicitSpecType?: EmailLinkOperationSpecType;
|
|
707
|
+
};
|
|
608
708
|
declare class EmailLinkOperationFull extends OperationFull {
|
|
609
709
|
readonly send: StepHelper<EmailLinkOperationSendStart>;
|
|
610
710
|
readonly postResponse: StepHelper<EmailLinkOperationPostResponseStart>;
|
|
611
711
|
readonly resend: StepHelper;
|
|
612
|
-
constructor(tracker: CorbadoTracker);
|
|
712
|
+
constructor(tracker: CorbadoTracker, config?: EmailLinkOperationConfig);
|
|
613
713
|
}
|
|
614
714
|
|
|
615
715
|
/**
|
|
@@ -651,6 +751,7 @@ type PasskeyEnrollmentPostResponseStart = {
|
|
|
651
751
|
attestationResponse?: string;
|
|
652
752
|
};
|
|
653
753
|
type PasskeyEnrollmentOperationConfig = {
|
|
754
|
+
/** The classifier drops the attempt if no spec type arrives on any of its events — supply it here or on a step's start data as soon as known. */
|
|
654
755
|
explicitSpecType?: PasskeyOperationEnrollmentExplicitSpecType;
|
|
655
756
|
/**
|
|
656
757
|
* Marks the auto-emitted `subflow_started` as not user-driven (see SubflowTrigger.ignoreAsInteraction).
|
|
@@ -694,17 +795,13 @@ type PasswordLoginCUIGetOptionsFinished = {
|
|
|
694
795
|
type PasswordLoginCUICeremonyStart = {
|
|
695
796
|
explicitSpecType?: PasswordLoginCUISpecType;
|
|
696
797
|
};
|
|
697
|
-
type
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
explicitSpecType: "password-with-identifier";
|
|
703
|
-
/** The password input field. */
|
|
704
|
-
inputHtmlField: HTMLInputElement;
|
|
798
|
+
type PasswordLoginExplicitSpecType = "password-known-identifier" | "password-with-identifier";
|
|
799
|
+
type PasswordLoginConfig = {
|
|
800
|
+
explicitSpecType?: PasswordLoginExplicitSpecType;
|
|
801
|
+
/** The password input field. When set, low-event input tracking is attached to it. */
|
|
802
|
+
inputHtmlField?: HTMLInputElement;
|
|
705
803
|
/**
|
|
706
|
-
* The identifier (e.g. email) input field.
|
|
707
|
-
* tracking for a second field lands together with per-field attribution.
|
|
804
|
+
* The identifier (e.g. email) input field. Tracked separately from the password field.
|
|
708
805
|
*/
|
|
709
806
|
identifierInputHtmlField?: HTMLInputElement;
|
|
710
807
|
};
|
|
@@ -722,7 +819,8 @@ declare class PasswordLoginOperationFull extends OperationFull {
|
|
|
722
819
|
postResponse: StepHelper;
|
|
723
820
|
};
|
|
724
821
|
private lowEventTracker?;
|
|
725
|
-
|
|
822
|
+
private identifierLowEventTracker?;
|
|
823
|
+
constructor(tracker: CorbadoTracker, config?: PasswordLoginConfig);
|
|
726
824
|
/**
|
|
727
825
|
* @deprecated `subflow_trigger` is not supported for password-login and will be removed in the
|
|
728
826
|
* next major version.
|
|
@@ -736,15 +834,17 @@ type PasswordEnrollmentTypedError = {
|
|
|
736
834
|
};
|
|
737
835
|
type PasswordEnrollmentTypedErrorCode = "requirements_not_fulfilled";
|
|
738
836
|
type PasswordEnrollmentExplicitSpecType = "password-set" | "password-reset";
|
|
739
|
-
type
|
|
837
|
+
type PasswordEnrollmentConfig = {
|
|
838
|
+
/** The classifier drops the attempt if no spec type arrives on any of its events — supply it here or on a step's start data as soon as known. */
|
|
740
839
|
explicitSpecType?: PasswordEnrollmentExplicitSpecType;
|
|
840
|
+
/** The password input field. When set, low-event input tracking is attached to it. */
|
|
741
841
|
inputHtmlField?: HTMLInputElement;
|
|
742
842
|
};
|
|
743
843
|
declare class PasswordEnrollmentOperationFull extends OperationFull {
|
|
744
844
|
readonly clientValidation: StepHelper;
|
|
745
845
|
readonly postResponse: StepHelper<{}, {}, PasswordEnrollmentTypedError>;
|
|
746
846
|
private lowEventTracker?;
|
|
747
|
-
constructor(tracker: CorbadoTracker,
|
|
847
|
+
constructor(tracker: CorbadoTracker, config?: PasswordEnrollmentConfig);
|
|
748
848
|
destroy(): void;
|
|
749
849
|
}
|
|
750
850
|
|
|
@@ -768,16 +868,15 @@ type PasskeyLoginCUIGetOptionsFinished = {
|
|
|
768
868
|
assertionOptions: string;
|
|
769
869
|
};
|
|
770
870
|
type OperationFullProvideIdentifierWithCUIConfig = {
|
|
871
|
+
/** When set, low event collection is enabled for the input field. */
|
|
771
872
|
inputHtmlField?: HTMLInputElement;
|
|
772
873
|
explicitSpecType?: ProvideIdentifierSpecType;
|
|
773
874
|
};
|
|
774
|
-
declare class OperationFullProvideIdentifierWithCUI {
|
|
775
|
-
private tracker;
|
|
875
|
+
declare class OperationFullProvideIdentifierWithCUI extends OperationFull {
|
|
776
876
|
private lowEventTracker?;
|
|
777
877
|
readonly cui: {
|
|
778
878
|
/**
|
|
779
|
-
* @deprecated `subflow_trigger`
|
|
780
|
-
* will be removed in the next major version.
|
|
879
|
+
* @deprecated `subflow_trigger` will be removed in the next major version.
|
|
781
880
|
*/
|
|
782
881
|
trigger: (data: SubflowTrigger, options?: StepOptions) => void;
|
|
783
882
|
getOptions: StepHelper<PasskeyLoginCUIGetOptionsStart, PasskeyLoginCUIGetOptionsFinished>;
|
|
@@ -786,32 +885,34 @@ declare class OperationFullProvideIdentifierWithCUI {
|
|
|
786
885
|
};
|
|
787
886
|
readonly provideIdentifier: {
|
|
788
887
|
/**
|
|
789
|
-
* @deprecated `subflow_trigger`
|
|
790
|
-
* in the next major version.
|
|
888
|
+
* @deprecated `subflow_trigger` will be removed in the next major version.
|
|
791
889
|
*/
|
|
792
890
|
trigger: (data: SubflowTrigger, options?: StepOptions) => void;
|
|
793
891
|
clientValidation: StepHelper;
|
|
794
892
|
postResponse: StepHelper<ProvideIdentifierPostResponseStart>;
|
|
795
893
|
};
|
|
796
894
|
constructor(tracker: CorbadoTracker, config?: OperationFullProvideIdentifierWithCUIConfig);
|
|
797
|
-
private createStep;
|
|
798
895
|
destroy(): void;
|
|
799
896
|
}
|
|
800
897
|
|
|
801
898
|
type SocialLoginSpecType = "pre-identifier" | "post-identifier";
|
|
802
899
|
type SocialLoginGetRedirectUrlStart = {
|
|
803
900
|
provider?: SocialLoginProviderType;
|
|
804
|
-
explicitSpecType
|
|
901
|
+
explicitSpecType?: SocialLoginSpecType;
|
|
805
902
|
};
|
|
806
903
|
type SocialLoginGetRedirectUrlFinished = {};
|
|
807
904
|
type SocialLoginExchangeCodeStart = {
|
|
808
905
|
provider?: SocialLoginProviderType;
|
|
809
906
|
};
|
|
810
907
|
type SocialLoginExchangeCodeFinished = {};
|
|
908
|
+
type SocialLoginOperationConfig = {
|
|
909
|
+
/** The classifier drops the attempt if no spec type arrives on any of its events — supply it here or on a step's start data as soon as known. */
|
|
910
|
+
explicitSpecType?: SocialLoginSpecType;
|
|
911
|
+
};
|
|
811
912
|
declare class SocialLoginOperationFull extends OperationFull {
|
|
812
913
|
readonly getRedirectUrl: StepHelper<SocialLoginGetRedirectUrlStart, SocialLoginGetRedirectUrlFinished>;
|
|
813
914
|
readonly exchangeCode: StepHelper<SocialLoginExchangeCodeStart, SocialLoginExchangeCodeFinished>;
|
|
814
|
-
constructor(tracker: CorbadoTracker);
|
|
915
|
+
constructor(tracker: CorbadoTracker, config?: SocialLoginOperationConfig);
|
|
815
916
|
}
|
|
816
917
|
|
|
817
918
|
type AppConfirmationOperationSpecType = "qr-code";
|
|
@@ -823,11 +924,14 @@ type AppConfirmationOperationCeremonyTypedError = {
|
|
|
823
924
|
};
|
|
824
925
|
type AppConfirmationOperationCeremonyTypedErrorCode = "declined" | "expired";
|
|
825
926
|
type AppConfirmationOperationRetryReason = AppConfirmationOperationCeremonyTypedErrorCode | "technical-error" | "manual";
|
|
927
|
+
type AppConfirmationOperationConfig = {
|
|
928
|
+
explicitSpecType?: AppConfirmationOperationSpecType;
|
|
929
|
+
};
|
|
826
930
|
declare class AppConfirmationOperationFull extends OperationFull {
|
|
827
931
|
readonly ceremony: StepHelper<{}, {}, AppConfirmationOperationCeremonyTypedError>;
|
|
828
932
|
readonly retry: StepHelper;
|
|
829
933
|
readonly postResponse: StepHelper;
|
|
830
|
-
constructor(tracker: CorbadoTracker,
|
|
934
|
+
constructor(tracker: CorbadoTracker, config?: AppConfirmationOperationConfig);
|
|
831
935
|
}
|
|
832
936
|
|
|
833
937
|
/**
|
|
@@ -851,6 +955,7 @@ type ProvideDataOperationSpecType = "signup" | "login" | "recovery" | "enrollmen
|
|
|
851
955
|
type ProvideDataOperationStart = {
|
|
852
956
|
/** Stable name of the data field collected by this subflow, when known. */
|
|
853
957
|
fieldName?: string;
|
|
958
|
+
/** The classifier drops the attempt if no spec type arrives on any of its events — supply it here or on a step's start data as soon as known. */
|
|
854
959
|
explicitSpecType?: ProvideDataOperationSpecType;
|
|
855
960
|
};
|
|
856
961
|
type ProvideDataOperationConfig = ProvideDataOperationStart & {
|
|
@@ -940,6 +1045,9 @@ declare class CorbadoTracker {
|
|
|
940
1045
|
private telemetryReady;
|
|
941
1046
|
private readonly reportedTelemetryKeys;
|
|
942
1047
|
private pendingSelfTelemetry;
|
|
1048
|
+
private windowObserver?;
|
|
1049
|
+
/** @internal Shared passive page observation and per-operation context registration. */
|
|
1050
|
+
getWindowObserver(): SharedWindowObserver;
|
|
943
1051
|
constructor(options: TrackerOptions);
|
|
944
1052
|
/**
|
|
945
1053
|
* Cache fresh server config as last-known so the next page load boots with it. When this load
|
|
@@ -1059,12 +1167,16 @@ declare class CorbadoTracker {
|
|
|
1059
1167
|
* sessionStorage-backed and stable for the whole page lifetime.
|
|
1060
1168
|
*/
|
|
1061
1169
|
private resolveEventTabId;
|
|
1062
|
-
trackSubflowStarted(subflowType: SubflowType, data: Record<string, any>, options?: StepOptions): void;
|
|
1170
|
+
trackSubflowStarted(subflowType: SubflowType, data: Record<string, any>, options?: StepOptions, eventId?: string): void;
|
|
1063
1171
|
trackSubflowTrigger(subflowType: SubflowType, data: Record<string, any>, options?: StepOptions): void;
|
|
1064
1172
|
trackSubflowStepStarted(subflowType: SubflowType, stepName: string, data: Record<string, any>, options?: StepOptions, ignoreAsInteraction?: boolean): void;
|
|
1065
1173
|
trackSubflowStepFinished(subflowType: SubflowType, stepName: string, data: Record<string, any>, options?: StepOptions): void;
|
|
1066
1174
|
trackSubflowStepError(subflowType: SubflowType, stepName: string, data: Record<string, any>, options?: StepOptions): void;
|
|
1067
|
-
|
|
1175
|
+
/**
|
|
1176
|
+
* @remarks
|
|
1177
|
+
* Records an additional error occurrence against the subflow. Carries no outcome semantics —
|
|
1178
|
+
* step errors are the intended channel; not part of a normal integration.
|
|
1179
|
+
*/
|
|
1068
1180
|
trackSubflowError(subflowType: SubflowType, data: Record<string, any>, options?: StepOptions): void;
|
|
1069
1181
|
/**
|
|
1070
1182
|
* Error situations:
|
|
@@ -1073,7 +1185,12 @@ declare class CorbadoTracker {
|
|
|
1073
1185
|
*
|
|
1074
1186
|
* @internal
|
|
1075
1187
|
*/
|
|
1076
|
-
track(name: AuthEventName, data: Record<string, any>, userReference?: UserReference, tags?: Record<string, string>, contexts?: Record<string, any>, explicitTimestamp?: number, experiments?: Record<string, string
|
|
1188
|
+
track(name: AuthEventName, data: Record<string, any>, userReference?: UserReference, tags?: Record<string, string>, contexts?: Record<string, any>, explicitTimestamp?: number, experiments?: Record<string, string>, capture?: {
|
|
1189
|
+
id?: string;
|
|
1190
|
+
subflowStartEventId?: string;
|
|
1191
|
+
sessionId?: string;
|
|
1192
|
+
initiator?: StepOptions["initiator"];
|
|
1193
|
+
}): Promise<void>;
|
|
1077
1194
|
/**
|
|
1078
1195
|
* Track when an authentication flow (or flow selection screen) becomes visible.
|
|
1079
1196
|
*
|
|
@@ -1121,10 +1238,12 @@ declare class CorbadoTracker {
|
|
|
1121
1238
|
* Use this for outcomes you care about beyond auth, such as a completed purchase,
|
|
1122
1239
|
* a started subscription, or a newsletter signup. Provide a stable `name` for the
|
|
1123
1240
|
* conversion and (optionally) the `touchpoint` where it happened so it can be
|
|
1124
|
-
* segmented in the same way as flows.
|
|
1125
|
-
*
|
|
1241
|
+
* segmented in the same way as flows. Record identity separately with `setUser()`
|
|
1242
|
+
* while the relevant flow is still active.
|
|
1243
|
+
*
|
|
1244
|
+
* Legacy identity fields in `data` remain supported but are deprecated.
|
|
1126
1245
|
*
|
|
1127
|
-
* @param data - Conversion name, optional touchpoint, and
|
|
1246
|
+
* @param data - Conversion name, optional touchpoint, and deprecated user reference fields.
|
|
1128
1247
|
* @param tags - Optional key-value tags for filtering and segmentation.
|
|
1129
1248
|
*
|
|
1130
1249
|
* @example
|
|
@@ -1132,7 +1251,6 @@ declare class CorbadoTracker {
|
|
|
1132
1251
|
* tracker.conversion({
|
|
1133
1252
|
* name: "purchase",
|
|
1134
1253
|
* touchpoint: "checkout",
|
|
1135
|
-
* userId: "usr_123",
|
|
1136
1254
|
* });
|
|
1137
1255
|
* ```
|
|
1138
1256
|
*/
|
|
@@ -1142,18 +1260,18 @@ declare class CorbadoTracker {
|
|
|
1142
1260
|
*
|
|
1143
1261
|
* @remarks
|
|
1144
1262
|
* Fire this when the user has finished the target flow end-to-end, such as completed login,
|
|
1145
|
-
* signup, or recovery.
|
|
1146
|
-
*
|
|
1263
|
+
* signup, or recovery. Record identity separately with `setUser()` while the flow
|
|
1264
|
+
* is still active, before calling `flowFinished()`.
|
|
1147
1265
|
*
|
|
1148
|
-
*
|
|
1266
|
+
* Legacy identity fields in `data` remain supported but are deprecated.
|
|
1267
|
+
*
|
|
1268
|
+
* @param data - Finished flow name, optional explicit outcome, and deprecated user reference fields.
|
|
1149
1269
|
* @param tags - Optional key-value tags for filtering and segmentation.
|
|
1150
1270
|
*
|
|
1151
1271
|
* @example
|
|
1152
1272
|
* ```typescript
|
|
1153
1273
|
* tracker.flowFinished({
|
|
1154
1274
|
* flowName: "login",
|
|
1155
|
-
* userId: "usr_123",
|
|
1156
|
-
* identifier: "max@example.com",
|
|
1157
1275
|
* });
|
|
1158
1276
|
* ```
|
|
1159
1277
|
*/
|
|
@@ -1180,9 +1298,12 @@ declare class CorbadoTracker {
|
|
|
1180
1298
|
* @remarks
|
|
1181
1299
|
* Use this for automatic completions where no separate explicit finish action happens in the
|
|
1182
1300
|
* current flow. Set `flowName` to the auto-finished flow and `finishedByFlowName` to the flow
|
|
1183
|
-
* that caused it.
|
|
1301
|
+
* that caused it. Record identity with `setUser()` while the intended flow is still
|
|
1302
|
+
* current, before it is auto-finished.
|
|
1303
|
+
*
|
|
1304
|
+
* Legacy identity fields in `data` remain supported but are deprecated.
|
|
1184
1305
|
*
|
|
1185
|
-
* @param data - Auto-finished flow, finishing flow, and
|
|
1306
|
+
* @param data - Auto-finished flow, finishing flow, and deprecated user reference fields.
|
|
1186
1307
|
* @param tags - Optional key-value tags for filtering and segmentation.
|
|
1187
1308
|
*
|
|
1188
1309
|
* @example
|
|
@@ -1190,11 +1311,32 @@ declare class CorbadoTracker {
|
|
|
1190
1311
|
* tracker.flowAutoFinished({
|
|
1191
1312
|
* flowName: "signup",
|
|
1192
1313
|
* finishedByFlowName: "login",
|
|
1193
|
-
* userId: "usr_123",
|
|
1194
1314
|
* });
|
|
1195
1315
|
* ```
|
|
1196
1316
|
*/
|
|
1197
1317
|
flowAutoFinished(data: FlowAutoFinished, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
1318
|
+
/**
|
|
1319
|
+
* Record a newly known user reference for the current active flow.
|
|
1320
|
+
*
|
|
1321
|
+
* @remarks
|
|
1322
|
+
* Emits one `flow_enriched` with `match: { flowType: "*", at: "during" }` and `expFol: true` in its data.
|
|
1323
|
+
* Call only after the flow starts and before it finishes. The enrichment belongs
|
|
1324
|
+
* to the current flow at emission time.
|
|
1325
|
+
* Calling after `flowFinished()` cannot enrich that finished flow. If a parent or another
|
|
1326
|
+
* flow is current then, the enrichment belongs to that flow instead.
|
|
1327
|
+
* An empty reference does not clear identity. Cross-environment transaction IDs must be UUIDs;
|
|
1328
|
+
* both environments must report the shared ID while their respective flows are active.
|
|
1329
|
+
*
|
|
1330
|
+
* @param user - User ID, identifier, and/or cross-environment transaction UUID.
|
|
1331
|
+
*
|
|
1332
|
+
* @example
|
|
1333
|
+
* ```typescript
|
|
1334
|
+
* tracker.flowStarted({ flowName: "login" });
|
|
1335
|
+
* tracker.setUser({ userId: "usr_123", identifier: "max@example.com" });
|
|
1336
|
+
* tracker.flowFinished({ flowName: "login" });
|
|
1337
|
+
* ```
|
|
1338
|
+
*/
|
|
1339
|
+
setUser(user: UserReference): void;
|
|
1198
1340
|
/**
|
|
1199
1341
|
* Track when you present authentication method choices to the user.
|
|
1200
1342
|
*
|
|
@@ -1219,7 +1361,15 @@ declare class CorbadoTracker {
|
|
|
1219
1361
|
*/
|
|
1220
1362
|
authMethodsDecisionStarted(data: AuthMethodDecisionStarted, tags?: Record<string, string>, experiments?: Record<string, string>, options?: Pick<StepOptions, "explicitTimestamp">): void;
|
|
1221
1363
|
authMethodsDecisionFinished(data: AuthMethodDecisionFinished, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
1364
|
+
/**
|
|
1365
|
+
* @deprecated Use {@link CorbadoTracker.authMethodsDecisionStarted} instead (its `options`
|
|
1366
|
+
* already accept free-form strings).
|
|
1367
|
+
*/
|
|
1222
1368
|
authDecisionStarted(data: AuthDecisionStarted, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
1369
|
+
/**
|
|
1370
|
+
* @deprecated Use {@link CorbadoTracker.authMethodsDecisionFinished} instead (its `options`
|
|
1371
|
+
* already accept free-form strings).
|
|
1372
|
+
*/
|
|
1223
1373
|
authDecisionFinished(data: AuthDecisionFinished, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
1224
1374
|
/**
|
|
1225
1375
|
* Enqueue a "low" event (granular DOM/window/visualviewport/PWM signal) for the current session.
|
|
@@ -1230,7 +1380,7 @@ declare class CorbadoTracker {
|
|
|
1230
1380
|
*
|
|
1231
1381
|
* @internal
|
|
1232
1382
|
*/
|
|
1233
|
-
enqueueLowEvent(low: LowEvent): void;
|
|
1383
|
+
enqueueLowEvent(low: LowEvent, capturedSessionId?: string): void;
|
|
1234
1384
|
/**
|
|
1235
1385
|
* Record a diagnostic telemetry entry (a `level` + free-form `message`) for the current session.
|
|
1236
1386
|
*
|
|
@@ -1278,17 +1428,17 @@ declare class CorbadoTracker {
|
|
|
1278
1428
|
* @internal
|
|
1279
1429
|
*/
|
|
1280
1430
|
lowEventFlushKeepalive(): void;
|
|
1281
|
-
passkeyLoginFullOperation(): PasskeyLoginOperationFull;
|
|
1431
|
+
passkeyLoginFullOperation(config?: PasskeyLoginOperationConfig): PasskeyLoginOperationFull;
|
|
1282
1432
|
passkeyEnrollmentFullOperation(config?: PasskeyEnrollmentOperationConfig): PasskeyEnrollmentOperationFull;
|
|
1283
|
-
passwordLoginFullOperation(autoTrackConfig?:
|
|
1284
|
-
passwordEnrollmentFullOperation(autoTrackConfig?:
|
|
1285
|
-
emailLinkOperationFull(): EmailLinkOperationFull;
|
|
1433
|
+
passwordLoginFullOperation(autoTrackConfig?: PasswordLoginConfig): PasswordLoginOperationFull;
|
|
1434
|
+
passwordEnrollmentFullOperation(autoTrackConfig?: PasswordEnrollmentConfig): PasswordEnrollmentOperationFull;
|
|
1435
|
+
emailLinkOperationFull(config?: EmailLinkOperationConfig): EmailLinkOperationFull;
|
|
1286
1436
|
emailOtpOperationFull(config?: EmailOTPOperationConfig): EmailOtpOperationFull;
|
|
1287
1437
|
smsOtpOperationFull(config?: SmsOTPOperationConfig): SmsOtpOperationFull;
|
|
1288
1438
|
provideIdentifierOperationFull(config?: OperationFullProvideIdentifierWithCUIConfig): OperationFullProvideIdentifierWithCUI;
|
|
1289
1439
|
provideDataOperationFull(config?: ProvideDataOperationConfig): ProvideDataOperationFull;
|
|
1290
|
-
socialLoginOperationFull(): SocialLoginOperationFull;
|
|
1291
|
-
appConfirmationOperationFull(
|
|
1440
|
+
socialLoginOperationFull(config?: SocialLoginOperationConfig): SocialLoginOperationFull;
|
|
1441
|
+
appConfirmationOperationFull(config?: AppConfirmationOperationConfig): AppConfirmationOperationFull;
|
|
1292
1442
|
captchaOperationFull(config?: CaptchaOperationConfig): CaptchaOperationFull;
|
|
1293
1443
|
/**
|
|
1294
1444
|
* Flush any pending events and release all resources (timers, event listeners).
|
|
@@ -1341,6 +1491,7 @@ declare const SDK_NAME = "@corbado/observe";
|
|
|
1341
1491
|
declare const SDK_VERSION: string;
|
|
1342
1492
|
|
|
1343
1493
|
interface TransportMakeRequestResponse {
|
|
1494
|
+
deliveryAccepted?: boolean;
|
|
1344
1495
|
statusCode?: number;
|
|
1345
1496
|
headers?: Record<string, string | null>;
|
|
1346
1497
|
/** Parsed SDK reliability config, present only when the server returns it (HTTP 200). */
|
|
@@ -1501,7 +1652,7 @@ interface QueueOptions {
|
|
|
1501
1652
|
* Pending events are held as {@link OutboxEntry} records. When `config.durableOutbox` is enabled they are
|
|
1502
1653
|
* additionally persisted to a localStorage-backed {@link EventStore} and recovered on the next load.
|
|
1503
1654
|
* Delivery removes an entry only on a 2xx response; retryable failures back off (honoring `Retry-After`)
|
|
1504
|
-
* up to `config.retry.maxAttempts`. Low events
|
|
1655
|
+
* up to `config.retry.maxAttempts`. Low events have a separately bounded outbox when durableLowOutbox is enabled.
|
|
1505
1656
|
*
|
|
1506
1657
|
* Flushing is timer-driven only (the flush interval); `batchSize` caps the events per request, and a
|
|
1507
1658
|
* flush drains all due work in sequential capped batches, stopping at the first failed send.
|
|
@@ -1517,14 +1668,16 @@ declare class RequestQueue {
|
|
|
1517
1668
|
private readonly storage?;
|
|
1518
1669
|
private pending;
|
|
1519
1670
|
private lowsQueue;
|
|
1671
|
+
private lowPending;
|
|
1672
|
+
private lowStore?;
|
|
1520
1673
|
/**
|
|
1521
|
-
* Diagnostic telemetry buffered for the current session. Best-effort and never persisted
|
|
1522
|
-
* lows). Attached to the next outgoing batch for this session; a telemetry entry alone never arms
|
|
1674
|
+
* Diagnostic telemetry buffered for the current session. Best-effort and never persisted. Attached to the next outgoing batch for this session; a telemetry entry alone never arms
|
|
1523
1675
|
* the flush timer (it piggybacks), unless `config.flushOnTelemetry` escalates to an immediate flush.
|
|
1524
1676
|
*/
|
|
1525
1677
|
private telemetryQueue;
|
|
1526
1678
|
private timer;
|
|
1527
1679
|
private isFlushing;
|
|
1680
|
+
private flushingDone?;
|
|
1528
1681
|
private destroyed;
|
|
1529
1682
|
/**
|
|
1530
1683
|
* True when something was enqueued (or recovered) since the last sync flush. visibilitychange,
|
|
@@ -1566,12 +1719,12 @@ declare class RequestQueue {
|
|
|
1566
1719
|
* Error situations:
|
|
1567
1720
|
* - Any error while enqueueing or scheduling the flush timer: log "Failed to enqueue event"
|
|
1568
1721
|
*/
|
|
1569
|
-
enqueue(event: Event): void;
|
|
1722
|
+
enqueue(event: Event, capturedSessionId?: string): void;
|
|
1570
1723
|
/**
|
|
1571
1724
|
* Error situations:
|
|
1572
1725
|
* - Any error while enqueueing or scheduling the flush timer: log "Failed to enqueue low event"
|
|
1573
1726
|
*/
|
|
1574
|
-
enqueueLow(low: LowEvent): void;
|
|
1727
|
+
enqueueLow(low: LowEvent, capturedSessionId?: string): void;
|
|
1575
1728
|
/**
|
|
1576
1729
|
* Buffer a diagnostic telemetry entry for delivery with the next event batch.
|
|
1577
1730
|
*
|
|
@@ -1619,6 +1772,10 @@ declare class RequestQueue {
|
|
|
1619
1772
|
private attachBatchMeta;
|
|
1620
1773
|
private getDuePending;
|
|
1621
1774
|
private takeLows;
|
|
1775
|
+
private validPendingLow;
|
|
1776
|
+
private removeLowEntries;
|
|
1777
|
+
private handleLowSendResult;
|
|
1778
|
+
private deferLowEntries;
|
|
1622
1779
|
private takeTelemetry;
|
|
1623
1780
|
private shouldRequestConfig;
|
|
1624
1781
|
/**
|
|
@@ -1754,7 +1911,7 @@ declare function loadCachedConfig(storage: StorageEngine): SdkReliabilityConfig
|
|
|
1754
1911
|
declare function cacheConfig(storage: StorageEngine, config: SdkReliabilityConfig): void;
|
|
1755
1912
|
|
|
1756
1913
|
/** A persisted, not-yet-acknowledged event awaiting delivery. */
|
|
1757
|
-
interface OutboxEntry {
|
|
1914
|
+
interface OutboxEntry<T = Event> {
|
|
1758
1915
|
/** Event idempotency id; primary key of the entry. */
|
|
1759
1916
|
id: string;
|
|
1760
1917
|
/** Session id snapshot taken at enqueue time (so session rotation never relabels old entries). */
|
|
@@ -1764,7 +1921,7 @@ interface OutboxEntry {
|
|
|
1764
1921
|
/** Number of completed send attempts so far. */
|
|
1765
1922
|
attempts: number;
|
|
1766
1923
|
/** The event payload. */
|
|
1767
|
-
event:
|
|
1924
|
+
event: T;
|
|
1768
1925
|
}
|
|
1769
1926
|
/** localStorage key under which the durable outbox is persisted. */
|
|
1770
1927
|
declare const OUTBOX_STORAGE_KEY = "cbo_outbox";
|
|
@@ -1790,7 +1947,7 @@ declare const DEFAULT_MAX_SERIALIZED_LENGTH: number;
|
|
|
1790
1947
|
* behavior. Mutations never reject; failures are logged.
|
|
1791
1948
|
* The store is size-capped; overflow evicts the oldest entries and logs the count.
|
|
1792
1949
|
*/
|
|
1793
|
-
declare class EventStore {
|
|
1950
|
+
declare class EventStore<T = Event> {
|
|
1794
1951
|
private readonly storage;
|
|
1795
1952
|
private readonly logger;
|
|
1796
1953
|
private readonly maxEntries;
|
|
@@ -1801,6 +1958,7 @@ declare class EventStore {
|
|
|
1801
1958
|
* and a shared key guarded by scoped locks would lose the cross-tab atomicity guarantee.
|
|
1802
1959
|
*/
|
|
1803
1960
|
private readonly lockName;
|
|
1961
|
+
private readonly storageKey;
|
|
1804
1962
|
private entries;
|
|
1805
1963
|
/** Malformed entries are dropped on every read; report only once per instance to avoid log spam. */
|
|
1806
1964
|
private reportedMalformed;
|
|
@@ -1810,21 +1968,21 @@ declare class EventStore {
|
|
|
1810
1968
|
* to: a project-scoped outbox key guarded by the shared lock would serialize unrelated trackers,
|
|
1811
1969
|
* and a shared key guarded by scoped locks would lose the cross-tab atomicity guarantee.
|
|
1812
1970
|
*/
|
|
1813
|
-
lockName?: string);
|
|
1971
|
+
lockName?: string, storageKey?: string);
|
|
1814
1972
|
private read;
|
|
1815
1973
|
private mutate;
|
|
1816
1974
|
/** Evict oldest entries until the serialized outbox fits {@link maxSerializedLength}. */
|
|
1817
1975
|
private enforceSizeBudget;
|
|
1818
1976
|
/** Append an entry. No-op if an entry with the same id already exists. */
|
|
1819
|
-
add(entry: OutboxEntry): Promise<void>;
|
|
1977
|
+
add(entry: OutboxEntry<T>): Promise<void>;
|
|
1820
1978
|
/** Re-read from storage and return all entries (memory mirror refreshed). */
|
|
1821
|
-
all(): OutboxEntry[];
|
|
1979
|
+
all(): OutboxEntry<T>[];
|
|
1822
1980
|
/** Entries whose `flushAfter` has elapsed, in insertion order. */
|
|
1823
|
-
getDue(now: number): OutboxEntry[];
|
|
1981
|
+
getDue(now: number): OutboxEntry<T>[];
|
|
1824
1982
|
/** Remove entries by id (acknowledged or permanently dropped). */
|
|
1825
1983
|
remove(ids: string[]): Promise<void>;
|
|
1826
1984
|
/** Replace existing entries (matched by id) with updated copies, e.g. after bumping backoff. */
|
|
1827
|
-
update(updated: OutboxEntry[]): Promise<void>;
|
|
1985
|
+
update(updated: OutboxEntry<T>[]): Promise<void>;
|
|
1828
1986
|
size(): number;
|
|
1829
1987
|
}
|
|
1830
1988
|
|
|
@@ -1842,6 +2000,12 @@ declare function resetSession(): string | undefined;
|
|
|
1842
2000
|
* could be established. See {@link CorbadoTracker.getSessionId}.
|
|
1843
2001
|
*/
|
|
1844
2002
|
declare function getSessionId(): string | undefined;
|
|
2003
|
+
/**
|
|
2004
|
+
* Record a user reference for the global tracker's current active flow.
|
|
2005
|
+
* Call after the flow starts and before it finishes; matching has no grace period.
|
|
2006
|
+
* See {@link CorbadoTracker.setUser}.
|
|
2007
|
+
*/
|
|
2008
|
+
declare function setUser(user: UserReference): void;
|
|
1845
2009
|
declare function setExperiment(key: string, variant: string): void;
|
|
1846
2010
|
declare function setExperiments(assignments: Record<string, string>): void;
|
|
1847
2011
|
declare function clearExperiment(key: string): void;
|
|
@@ -1852,4 +2016,4 @@ declare function logInfo(message: string): void;
|
|
|
1852
2016
|
declare function logError(message: string): void;
|
|
1853
2017
|
declare function destroy(): Promise<void>;
|
|
1854
2018
|
|
|
1855
|
-
export { type AppConfirmationOperationCeremonyTypedError, AppConfirmationOperationFull, type AppConfirmationOperationRetryReason, type AppConfirmationOperationSpecType, type AppConfirmationOperationStart, type AuthDecisionFinished, type AuthDecisionStarted, AuthEventName, type AuthMethodDecisionFinished, type AuthMethodDecisionStarted, type AuthMethodType, type BaseEvent, CEREMONY_LOW_EVENT_TAIL_MS, CONFIG_BOUNDS, CONFIG_REQUEST_HEADER, CONFIG_STORAGE_KEY, type CaptchaOperationConfig, CaptchaOperationFull, type CaptchaOperationSpecType, type ClientCapabilities, type ClientEnvHandleMeta, type ClientEnvHandleMetaSource, type Conversion, CookieStorage, CorbadoTracker, type CreateLoggerOptions, type CustomEvent, DEFAULT_DEVICE_INFO_COLLECTOR_TIMEOUT_MS, DEFAULT_FLUSH_INTERVAL_MS, DEFAULT_MAX_ENTRIES, DEFAULT_MAX_SERIALIZED_LENGTH, DEFAULT_RELIABILITY_CONFIG, DEFAULT_SEQ_LOCK_TIMEOUT_MS, DEFAULT_SESSION_INACTIVITY_MS, type DeviceInfo, type DeviceInfoCollectionError, type DeviceInfoDataWeb, type DeviceType, EmailLinkOperationFull, type EmailLinkOperationPostResponseStart, type EmailLinkOperationSendStart, type EmailLinkOperationSpecType, type EmailOTPOperationConfig, type EmailOTPOperationPostResponseStart, type EmailOTPOperationSendOTPStart, type EmailOTPOperationSpecType, EmailOtpOperationFull, type Event, type EventBatch, type EventBatchMeta, type EventMeta, EventStore, type EventType, type FlowAutoFinished, type FlowDecided, type FlowFinished, type FlowReset, type FlowStarted, type FlowType, type FlushReason, type JavaScriptHighEntropy, LocalStorage, type Logger, type LowEvent, type MultiFlowReset, type MultiFlowStarted, NamespacedStorage, type NormalizedError, OUTBOX_LOCK_NAME, OUTBOX_STORAGE_KEY, type ObserveSdkConfigSnapshot, OperationFull, OperationFullProvideIdentifierWithCUI, type OperationFullProvideIdentifierWithCUIConfig, type OutboxEntry, type PasskeyEnrollmentCeremonyFinished, type PasskeyEnrollmentCeremonyStart, type PasskeyEnrollmentGetOptionsFinished, type PasskeyEnrollmentGetOptionsStart, type PasskeyEnrollmentOperationConfig, PasskeyEnrollmentOperationFull, type PasskeyEnrollmentPostResponseStart, type PasskeyLoginCUIGetOptionsFinished, type PasskeyLoginCUIGetOptionsStart, type PasskeyLoginCUISpecType, type PasskeyLoginCeremonyFinished, type PasskeyLoginCeremonyStart, type PasskeyLoginClientError, type PasskeyLoginFinish, type PasskeyLoginGetOptionsFinished, type PasskeyLoginGetOptionsStart, PasskeyLoginOperationFull, type PasskeyLoginPostResponseStart, type PasskeyLoginStartable, type PasskeyLoginSubmitted, type PasskeyOperationEnrollmentExplicitSpecType, type PasskeyOperationLoginExplicitSpecType, type
|
|
2019
|
+
export { type AppConfirmationOperationCeremonyTypedError, type AppConfirmationOperationConfig, AppConfirmationOperationFull, type AppConfirmationOperationRetryReason, type AppConfirmationOperationSpecType, type AppConfirmationOperationStart, type AuthDecisionFinished, type AuthDecisionStarted, AuthEventName, type AuthMethodDecisionFinished, type AuthMethodDecisionStarted, type AuthMethodType, type BaseEvent, CEREMONY_LOW_EVENT_TAIL_MS, CONFIG_BOUNDS, CONFIG_REQUEST_HEADER, CONFIG_STORAGE_KEY, type CaptchaOperationConfig, CaptchaOperationFull, type CaptchaOperationSpecType, type ClientCapabilities, type ClientEnvHandleMeta, type ClientEnvHandleMetaSource, type Conversion, CookieStorage, CorbadoTracker, type CreateLoggerOptions, type CustomEvent, DEFAULT_DEVICE_INFO_COLLECTOR_TIMEOUT_MS, DEFAULT_FLUSH_INTERVAL_MS, DEFAULT_MAX_ENTRIES, DEFAULT_MAX_SERIALIZED_LENGTH, DEFAULT_RELIABILITY_CONFIG, DEFAULT_SEQ_LOCK_TIMEOUT_MS, DEFAULT_SESSION_INACTIVITY_MS, type DeviceInfo, type DeviceInfoCollectionError, type DeviceInfoDataWeb, type DeviceType, type EmailLinkOperationConfig, EmailLinkOperationFull, type EmailLinkOperationPostResponseStart, type EmailLinkOperationSendStart, type EmailLinkOperationSpecType, type EmailOTPOperationConfig, type EmailOTPOperationPostResponseStart, type EmailOTPOperationSendOTPStart, type EmailOTPOperationSpecType, EmailOtpOperationFull, type Event, type EventBatch, type EventBatchMeta, type EventMeta, EventStore, type EventType, type FlowAutoFinished, type FlowDecided, type FlowFinished, type FlowReset, type FlowStarted, type FlowType, type FlushReason, type JavaScriptHighEntropy, LocalStorage, type Logger, type LowEvent, type LowEventFieldRole, type LowEventInitiator, type LowEventInputEffect, type LowEventSourceKind, type MultiFlowReset, type MultiFlowStarted, NamespacedStorage, type NormalizedError, OUTBOX_LOCK_NAME, OUTBOX_STORAGE_KEY, type ObserveSdkConfigSnapshot, OperationFull, OperationFullProvideIdentifierWithCUI, type OperationFullProvideIdentifierWithCUIConfig, type OutboxEntry, type PasskeyEnrollmentCeremonyFinished, type PasskeyEnrollmentCeremonyStart, type PasskeyEnrollmentGetOptionsFinished, type PasskeyEnrollmentGetOptionsStart, type PasskeyEnrollmentOperationConfig, PasskeyEnrollmentOperationFull, type PasskeyEnrollmentPostResponseStart, type PasskeyLoginCUIGetOptionsFinished, type PasskeyLoginCUIGetOptionsStart, type PasskeyLoginCUISpecType, type PasskeyLoginCeremonyFinished, type PasskeyLoginCeremonyStart, type PasskeyLoginClientError, type PasskeyLoginFinish, type PasskeyLoginGetOptionsFinished, type PasskeyLoginGetOptionsStart, type PasskeyLoginOperationConfig, PasskeyLoginOperationFull, type PasskeyLoginPostResponseStart, type PasskeyLoginStartable, type PasskeyLoginSubmitted, type PasskeyOperationEnrollmentExplicitSpecType, type PasskeyOperationLoginExplicitSpecType, type PasswordEnrollmentConfig, PasswordEnrollmentOperationFull, type PasswordEnrollmentTypedError, type PasswordLoginCUICeremonyStart, type PasswordLoginCUIGetOptionsFinished, type PasswordLoginCUIGetOptionsStart, type PasswordLoginCUISpecType, type PasswordLoginCUITypedError, type PasswordLoginConfig, type PasswordLoginExplicitSpecType, PasswordLoginOperationFull, type PasswordLoginTypedError, type PredefinedEvent, type ProvideDataOperationConfig, ProvideDataOperationFull, type ProvideDataOperationPostResponseStart, type ProvideDataOperationSpecType, type ProvideDataOperationStart, type ProvideIdentifierError, type ProvideIdentifierFinish, type ProvideIdentifierPostResponseStart, type ProvideIdentifierSpecType, type ProvideIdentifierStart, type QueueOptions, RequestQueue, SDK_NAME, SDK_VERSION, type SdkInfo, type SdkReliabilityConfig, type SdkRetryConfig, SessionStorage, type SmsOTPOperationConfig, type SmsOTPOperationPostResponseStart, type SmsOTPOperationSpecType, SmsOtpOperationFull, type SocialLoginExchangeCodeFinished, type SocialLoginExchangeCodeStart, type SocialLoginGetRedirectUrlFinished, type SocialLoginGetRedirectUrlStart, type SocialLoginOperationConfig, SocialLoginOperationFull, type SocialLoginProviderType, type SocialLoginSpecType, type StepHelper, type StepOptions, type StorageEngine, type SubflowTrigger, type SubflowType, type TelemetryEntry, type TelemetryLevel, type TelemetrySink, type TrackerOptions, type Transport, type TransportMakeRequestResponse, type TransportOptions, type UserReference, cacheConfig, clearExperiment, clearExperiments, createLogger, destroy, getExperiments, getSessionId, getTracker, init, loadCachedConfig, logError, logInfo, namespacedKey, parseReliabilityConfig, resetSession, setExperiment, setExperiments, setUser, telemetry };
|