@corbado/observe 0.1.0 → 0.2.0-next.28-9ea8f5f

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/index.d.mts CHANGED
@@ -5,7 +5,7 @@ interface SdkInfo {
5
5
  type EventType = "predefined" | "custom" | "error" | "identify";
6
6
  type AuthMethodType = "identifier-email" | "passkey-login-known-identifier" | "passkey-login-no-identifier" | "passkey-login-cui" | "passkey-enrollment" | "password-login-known-identifier" | "password-login-with-identifier" | "password-enrollment" | "email-otp-login" | "email-otp-enrollment" | "email-link-login" | "email-link-enrollment" | "social-google" | "social-apple" | "social-facebook" | "social-other" | "reset-flow";
7
7
  type SubflowType = "passkey-enrollment" | "passkey-login" | "email-otp" | "email-link" | "social-login" | "sms-otp" | "provide-identifier" | "provide-data" | "password-login" | "password-enrollment" | "totp";
8
- type FlowType = "login" | "signup" | "recovery" | "enrollment";
8
+ type FlowType = "login" | "signup" | "recovery" | "enrollment" | (string & {});
9
9
  type SocialLoginProviderType = "google" | "apple" | "facebook" | "github" | "microsoft" | "other";
10
10
  declare enum AuthEventName {
11
11
  FlowStarted = "flow_started",
@@ -33,6 +33,7 @@ interface BaseEvent {
33
33
  contexts?: Record<string, unknown>;
34
34
  tags?: Record<string, string>;
35
35
  deviceInfo?: DeviceInfo;
36
+ meta?: EventMeta;
36
37
  }
37
38
  type UserReference = {
38
39
  userId?: string;
@@ -64,7 +65,10 @@ type FlowFinished = {
64
65
  explicitOutcome?: "skipped" | "invisible";
65
66
  } & UserReference;
66
67
  type FlowReset = {
67
- flowName: FlowType;
68
+ flowName?: FlowType;
69
+ };
70
+ type MultiFlowReset = {
71
+ flowNames: FlowType[];
68
72
  };
69
73
  type FlowAutoFinished = {
70
74
  flowName: FlowType;
@@ -126,10 +130,24 @@ interface CustomEvent extends BaseEvent {
126
130
  data?: Record<string, unknown>;
127
131
  }
128
132
  type Event = PredefinedEvent | CustomEvent;
133
+ interface LowEvent {
134
+ lowType: string;
135
+ ts: number;
136
+ durationMs?: number;
137
+ }
138
+ interface EventBatchMeta {
139
+ sent: number;
140
+ }
141
+ interface EventMeta {
142
+ trackingSourcePath: string;
143
+ }
129
144
  interface EventBatch {
130
145
  sessionId: string;
131
146
  events: Event[];
132
147
  sdk: SdkInfo;
148
+ transport?: "fetch" | "beacon";
149
+ lows?: LowEvent[];
150
+ meta?: EventBatchMeta;
133
151
  }
134
152
  type DeviceType = "web" | "app" | "other";
135
153
  interface DeviceInfo {
@@ -275,7 +293,7 @@ type PasswordLoginAutoTrackConfig = {
275
293
  };
276
294
  declare class PasswordLoginOperationFull extends OperationFull {
277
295
  readonly postResponse: StepHelper<{}, {}, PasswordLoginTypedError>;
278
- private patternDetector?;
296
+ private lowEventTracker?;
279
297
  constructor(tracker: CorbadoTracker, autoTrackConfig?: PasswordLoginAutoTrackConfig);
280
298
  destroy(): void;
281
299
  }
@@ -291,7 +309,7 @@ type PasswordEnrollmentAutoTrackConfig = {
291
309
  };
292
310
  declare class PasswordEnrollmentOperationFull extends OperationFull {
293
311
  readonly postResponse: StepHelper<{}, {}, PasswordEnrollmentTypedError>;
294
- private patternDetector?;
312
+ private lowEventTracker?;
295
313
  constructor(tracker: CorbadoTracker, autoTrackConfig?: PasswordEnrollmentAutoTrackConfig);
296
314
  destroy(): void;
297
315
  }
@@ -317,7 +335,7 @@ type PasskeyLoginCUIGetOptionsFinished = {
317
335
  };
318
336
  declare class OperationFullProvideIdentifierWithCUI {
319
337
  private tracker;
320
- private patternDetector?;
338
+ private lowEventTracker?;
321
339
  readonly cui: {
322
340
  trigger: (data: SubflowTrigger, options?: StepOptions) => void;
323
341
  getOptions: StepHelper<PasskeyLoginCUIGetOptionsStart, PasskeyLoginCUIGetOptionsFinished>;
@@ -360,6 +378,7 @@ interface TrackerOptions {
360
378
  deviceInfoDebounceTime?: number;
361
379
  defaultTags?: Record<string, string>;
362
380
  applicationId?: string;
381
+ flushInterval?: number;
363
382
  }
364
383
  /**
365
384
  * @remarks
@@ -391,9 +410,10 @@ declare class CorbadoTracker {
391
410
  private isTrackingBlocked;
392
411
  private getSessionId;
393
412
  private updateDeviceDebounced;
413
+ private resolveTrackingSourcePath;
394
414
  trackSubflowStarted(subflowType: SubflowType, data: Record<string, any>, options?: StepOptions): void;
395
415
  trackSubflowTrigger(subflowType: SubflowType, data: Record<string, any>, options?: StepOptions): void;
396
- trackSubflowStepStarted(subflowType: SubflowType, stepName: string, data: Record<string, any>, options?: StepOptions): void;
416
+ trackSubflowStepStarted(subflowType: SubflowType, stepName: string, data: Record<string, any>, options?: StepOptions, ignoreAsInteraction?: boolean): void;
397
417
  trackSubflowStepFinished(subflowType: SubflowType, stepName: string, data: Record<string, any>, options?: StepOptions): void;
398
418
  trackSubflowStepError(subflowType: SubflowType, stepName: string, data: Record<string, any>, options?: StepOptions): void;
399
419
  trackSubflowFinished(subflowType: SubflowType, data: Record<string, any>, options?: StepOptions): void;
@@ -479,7 +499,7 @@ declare class CorbadoTracker {
479
499
  * tracker.flowReset({flowName: "login"});
480
500
  * ```
481
501
  */
482
- flowReset(data: FlowReset, tags?: Record<string, string>): void;
502
+ flowReset(data: FlowReset | MultiFlowReset, tags?: Record<string, string>): void;
483
503
  /**
484
504
  * Track when a flow is considered finished because another flow finished it implicitly.
485
505
  *
@@ -525,6 +545,23 @@ declare class CorbadoTracker {
525
545
  authMethodsDecisionFinished(data: AuthMethodDecisionFinished, tags?: Record<string, string>): void;
526
546
  authDecisionStarted(data: AuthDecisionStarted): void;
527
547
  authDecisionFinished(data: AuthDecisionFinished): void;
548
+ /**
549
+ * Enqueue a "low" event (granular DOM/window/visualviewport/PWM signal) for the current session.
550
+ *
551
+ * @remarks
552
+ * Low events are sent in the `lows` array of the events endpoint payload, alongside any
553
+ * pending typed events. Blocked user agents are skipped silently.
554
+ *
555
+ * @internal
556
+ */
557
+ enqueueLowEvent(low: LowEvent): void;
558
+ /**
559
+ * Synchronously flush any pending events and low events via beacon. Use during page-unload
560
+ * style teardown where async flushing is unreliable.
561
+ *
562
+ * @internal
563
+ */
564
+ flushKeepalive(): void;
528
565
  passkeyLoginFullOperation(): PasskeyLoginOperationFull;
529
566
  passkeyEnrollmentFullOperation(): PasskeyEnrollmentOperationFull;
530
567
  passwordLoginFullOperation(autoTrackConfig?: PasswordLoginAutoTrackConfig): PasswordLoginOperationFull;
@@ -564,47 +601,6 @@ interface TransportOptions {
564
601
  headers?: Record<string, string>;
565
602
  }
566
603
 
567
- interface QueueOptions {
568
- batchSize?: number;
569
- flushInterval?: number;
570
- }
571
- /**
572
- * @remarks When `window` is defined, `visibilitychange` (when the document becomes hidden) and `pagehide` trigger a synchronous beacon flush (`flushSync`). Any thrown error in that path is logged as "Unexpected error in queue flushSync".
573
- */
574
- declare class RequestQueue {
575
- private readonly logger;
576
- private transport;
577
- private sessionId;
578
- private readonly sdk;
579
- private options;
580
- private queue;
581
- private timer;
582
- private isFlushing;
583
- private onVisibilityChange;
584
- private onPageHide;
585
- constructor(logger: Logger, transport: Transport, sessionId: string, sdk: SdkInfo, options?: QueueOptions);
586
- setSessionId(sessionId: string): void;
587
- /**
588
- * Error situations:
589
- * - Any error while enqueueing or scheduling flush (including a synchronous throw from `flush`): log "Failed to enqueue event"
590
- */
591
- enqueue(event: Event): void;
592
- /**
593
- * Error situations:
594
- * - Queue is empty: return without calling transport.send
595
- * - A flush is already in progress: return without calling transport.send again
596
- * - transport.send rejects or throws, or any other error in the try block: log "Unexpected error in queue flush"
597
- */
598
- flush(): Promise<void>;
599
- private setupLifecycleHooks;
600
- private flushSync;
601
- /**
602
- * Error situations:
603
- * - Timer clearance or event listener removal throws: log "Failed to destroy queue lifecycle hooks"
604
- */
605
- destroy(): void;
606
- }
607
-
608
604
  interface StorageEngine {
609
605
  getItem<T>(key: string): T | null;
610
606
  setItem<T>(key: string, value: T): void;
@@ -685,9 +681,64 @@ declare class SessionStorage implements StorageEngine {
685
681
  removeItem(key: string): void;
686
682
  }
687
683
 
684
+ interface QueueOptions {
685
+ batchSize?: number;
686
+ flushInterval?: number;
687
+ debug?: boolean;
688
+ }
689
+ /**
690
+ * @remarks When `window` is defined, `visibilitychange` (when the document becomes hidden) and `pagehide` trigger a synchronous beacon flush (`flushSync`). Any thrown error in that path is logged as "Unexpected error in queue flushSync".
691
+ */
692
+ declare class RequestQueue {
693
+ private readonly logger;
694
+ private transport;
695
+ private sessionId;
696
+ private readonly sdk;
697
+ private options;
698
+ private readonly storage?;
699
+ private queue;
700
+ private lowsQueue;
701
+ private timer;
702
+ private isFlushing;
703
+ private onVisibilityChange;
704
+ private onPageHide;
705
+ constructor(logger: Logger, transport: Transport, sessionId: string, sdk: SdkInfo, options?: QueueOptions, storage?: StorageEngine | undefined);
706
+ setSessionId(sessionId: string): void;
707
+ /**
708
+ * Error situations:
709
+ * - Any error while enqueueing or scheduling flush (including a synchronous throw from `flush`): log "Failed to enqueue event"
710
+ */
711
+ enqueue(event: Event): void;
712
+ /**
713
+ * Error situations:
714
+ * - Any error while enqueueing or scheduling flush (including a synchronous throw from `flush`): log "Failed to enqueue low event"
715
+ */
716
+ enqueueLow(low: LowEvent): void;
717
+ /**
718
+ * Error situations:
719
+ * - Queue is empty: return without calling transport.send
720
+ * - A flush is already in progress: return without calling transport.send again
721
+ * - transport.send rejects or throws, or any other error in the try block: log "Unexpected error in queue flush"
722
+ */
723
+ flush(): Promise<void>;
724
+ private setupLifecycleHooks;
725
+ private writeLifecycleDebugOutput;
726
+ /**
727
+ * Synchronously flush both events and lows via `sendBeacon` if the transport supports it.
728
+ * Safe to call multiple times: a no-op when both queues are empty.
729
+ */
730
+ flushKeepalive(): void;
731
+ private flushSync;
732
+ /**
733
+ * Error situations:
734
+ * - Timer clearance or event listener removal throws: log "Failed to destroy queue lifecycle hooks"
735
+ */
736
+ destroy(): void;
737
+ }
738
+
688
739
  declare function init(options: TrackerOptions): CorbadoTracker;
689
740
  declare function getTracker(): CorbadoTracker | undefined;
690
741
  declare function resetSession(): string | undefined;
691
742
  declare function destroy(): Promise<void>;
692
743
 
693
- export { type AuthDecisionFinished, type AuthDecisionStarted, AuthEventName, type AuthMethodDecisionFinished, type AuthMethodDecisionStarted, type AuthMethodType, type BaseEvent, type ClientCapabilities, type ClientEnvHandleMeta, type ClientEnvHandleMetaSource, CookieStorage, CorbadoTracker, type CreateLoggerOptions, type CustomEvent, type DeviceInfo, type DeviceInfoDataWeb, type DeviceType, EmailLinkOperationFull, type EmailLinkOperationPostResponseStart, type EmailLinkOperationSendStart, type EmailLinkOperationSpecType, type EmailOTPOperationPostResponseStart, type EmailOTPOperationSendOTPStart, type EmailOTPOperationSpecType, EmailOtpOperationFull, type Event, type EventBatch, type EventType, type FlowAutoFinished, type FlowDecided, type FlowFinished, type FlowReset, type FlowStarted, type FlowType, type JavaScriptHighEntropy, LocalStorage, type Logger, type MultiFlowStarted, type NormalizedError, OperationFull, OperationFullProvideIdentifierWithCUI, type PasskeyEnrollmentCeremonyFinished, type PasskeyEnrollmentCeremonyStart, type PasskeyEnrollmentGetOptionsFinished, type PasskeyEnrollmentGetOptionsStart, PasskeyEnrollmentOperationFull, type PasskeyLoginCUIGetOptionsFinished, type PasskeyLoginCUIGetOptionsStart, type PasskeyLoginCUISpecType, type PasskeyLoginCeremonyFinished, type PasskeyLoginCeremonyStart, type PasskeyLoginClientError, type PasskeyLoginFinish, type PasskeyLoginGetOptionsFinished, type PasskeyLoginGetOptionsStart, PasskeyLoginOperationFull, type PasskeyLoginStartable, type PasskeyLoginSubmitted, type PasskeyOperationEnrollmentExplicitSpecType, type PasskeyOperationLoginExplicitSpecType, type PasswordEnrollmentAutoTrackConfig, PasswordEnrollmentOperationFull, type PasswordEnrollmentTypedError, type PasswordLoginAutoTrackConfig, PasswordLoginOperationFull, type PasswordLoginTypedError, type PredefinedEvent, type ProvideIdentifierError, type ProvideIdentifierFinish, type ProvideIdentifierPostResponseStart, type ProvideIdentifierSpecType, type ProvideIdentifierStart, type QueueOptions, RequestQueue, SDK_NAME, SDK_VERSION, type SdkInfo, SessionStorage, type SocialLoginExchangeCodeFinished, type SocialLoginExchangeCodeStart, type SocialLoginGetRedirectUrlFinished, type SocialLoginGetRedirectUrlStart, SocialLoginOperationFull, type SocialLoginProviderType, type SocialLoginSpecType, type StepHelper, type StepOptions, type StorageEngine, type SubflowTrigger, type SubflowType, type TrackerOptions, type Transport, type TransportMakeRequestResponse, type TransportOptions, type UserReference, createLogger, destroy, getTracker, init, resetSession };
744
+ export { type AuthDecisionFinished, type AuthDecisionStarted, AuthEventName, type AuthMethodDecisionFinished, type AuthMethodDecisionStarted, type AuthMethodType, type BaseEvent, type ClientCapabilities, type ClientEnvHandleMeta, type ClientEnvHandleMetaSource, CookieStorage, CorbadoTracker, type CreateLoggerOptions, type CustomEvent, type DeviceInfo, type DeviceInfoDataWeb, type DeviceType, EmailLinkOperationFull, type EmailLinkOperationPostResponseStart, type EmailLinkOperationSendStart, type EmailLinkOperationSpecType, type EmailOTPOperationPostResponseStart, type EmailOTPOperationSendOTPStart, type EmailOTPOperationSpecType, EmailOtpOperationFull, type Event, type EventBatch, type EventBatchMeta, type EventMeta, type EventType, type FlowAutoFinished, type FlowDecided, type FlowFinished, type FlowReset, type FlowStarted, type FlowType, type JavaScriptHighEntropy, LocalStorage, type Logger, type LowEvent, type MultiFlowReset, type MultiFlowStarted, type NormalizedError, OperationFull, OperationFullProvideIdentifierWithCUI, type PasskeyEnrollmentCeremonyFinished, type PasskeyEnrollmentCeremonyStart, type PasskeyEnrollmentGetOptionsFinished, type PasskeyEnrollmentGetOptionsStart, PasskeyEnrollmentOperationFull, type PasskeyLoginCUIGetOptionsFinished, type PasskeyLoginCUIGetOptionsStart, type PasskeyLoginCUISpecType, type PasskeyLoginCeremonyFinished, type PasskeyLoginCeremonyStart, type PasskeyLoginClientError, type PasskeyLoginFinish, type PasskeyLoginGetOptionsFinished, type PasskeyLoginGetOptionsStart, PasskeyLoginOperationFull, type PasskeyLoginStartable, type PasskeyLoginSubmitted, type PasskeyOperationEnrollmentExplicitSpecType, type PasskeyOperationLoginExplicitSpecType, type PasswordEnrollmentAutoTrackConfig, PasswordEnrollmentOperationFull, type PasswordEnrollmentTypedError, type PasswordLoginAutoTrackConfig, PasswordLoginOperationFull, type PasswordLoginTypedError, type PredefinedEvent, type ProvideIdentifierError, type ProvideIdentifierFinish, type ProvideIdentifierPostResponseStart, type ProvideIdentifierSpecType, type ProvideIdentifierStart, type QueueOptions, RequestQueue, SDK_NAME, SDK_VERSION, type SdkInfo, SessionStorage, type SocialLoginExchangeCodeFinished, type SocialLoginExchangeCodeStart, type SocialLoginGetRedirectUrlFinished, type SocialLoginGetRedirectUrlStart, SocialLoginOperationFull, type SocialLoginProviderType, type SocialLoginSpecType, type StepHelper, type StepOptions, type StorageEngine, type SubflowTrigger, type SubflowType, type TrackerOptions, type Transport, type TransportMakeRequestResponse, type TransportOptions, type UserReference, createLogger, destroy, getTracker, init, resetSession };
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ interface SdkInfo {
5
5
  type EventType = "predefined" | "custom" | "error" | "identify";
6
6
  type AuthMethodType = "identifier-email" | "passkey-login-known-identifier" | "passkey-login-no-identifier" | "passkey-login-cui" | "passkey-enrollment" | "password-login-known-identifier" | "password-login-with-identifier" | "password-enrollment" | "email-otp-login" | "email-otp-enrollment" | "email-link-login" | "email-link-enrollment" | "social-google" | "social-apple" | "social-facebook" | "social-other" | "reset-flow";
7
7
  type SubflowType = "passkey-enrollment" | "passkey-login" | "email-otp" | "email-link" | "social-login" | "sms-otp" | "provide-identifier" | "provide-data" | "password-login" | "password-enrollment" | "totp";
8
- type FlowType = "login" | "signup" | "recovery" | "enrollment";
8
+ type FlowType = "login" | "signup" | "recovery" | "enrollment" | (string & {});
9
9
  type SocialLoginProviderType = "google" | "apple" | "facebook" | "github" | "microsoft" | "other";
10
10
  declare enum AuthEventName {
11
11
  FlowStarted = "flow_started",
@@ -33,6 +33,7 @@ interface BaseEvent {
33
33
  contexts?: Record<string, unknown>;
34
34
  tags?: Record<string, string>;
35
35
  deviceInfo?: DeviceInfo;
36
+ meta?: EventMeta;
36
37
  }
37
38
  type UserReference = {
38
39
  userId?: string;
@@ -64,7 +65,10 @@ type FlowFinished = {
64
65
  explicitOutcome?: "skipped" | "invisible";
65
66
  } & UserReference;
66
67
  type FlowReset = {
67
- flowName: FlowType;
68
+ flowName?: FlowType;
69
+ };
70
+ type MultiFlowReset = {
71
+ flowNames: FlowType[];
68
72
  };
69
73
  type FlowAutoFinished = {
70
74
  flowName: FlowType;
@@ -126,10 +130,24 @@ interface CustomEvent extends BaseEvent {
126
130
  data?: Record<string, unknown>;
127
131
  }
128
132
  type Event = PredefinedEvent | CustomEvent;
133
+ interface LowEvent {
134
+ lowType: string;
135
+ ts: number;
136
+ durationMs?: number;
137
+ }
138
+ interface EventBatchMeta {
139
+ sent: number;
140
+ }
141
+ interface EventMeta {
142
+ trackingSourcePath: string;
143
+ }
129
144
  interface EventBatch {
130
145
  sessionId: string;
131
146
  events: Event[];
132
147
  sdk: SdkInfo;
148
+ transport?: "fetch" | "beacon";
149
+ lows?: LowEvent[];
150
+ meta?: EventBatchMeta;
133
151
  }
134
152
  type DeviceType = "web" | "app" | "other";
135
153
  interface DeviceInfo {
@@ -275,7 +293,7 @@ type PasswordLoginAutoTrackConfig = {
275
293
  };
276
294
  declare class PasswordLoginOperationFull extends OperationFull {
277
295
  readonly postResponse: StepHelper<{}, {}, PasswordLoginTypedError>;
278
- private patternDetector?;
296
+ private lowEventTracker?;
279
297
  constructor(tracker: CorbadoTracker, autoTrackConfig?: PasswordLoginAutoTrackConfig);
280
298
  destroy(): void;
281
299
  }
@@ -291,7 +309,7 @@ type PasswordEnrollmentAutoTrackConfig = {
291
309
  };
292
310
  declare class PasswordEnrollmentOperationFull extends OperationFull {
293
311
  readonly postResponse: StepHelper<{}, {}, PasswordEnrollmentTypedError>;
294
- private patternDetector?;
312
+ private lowEventTracker?;
295
313
  constructor(tracker: CorbadoTracker, autoTrackConfig?: PasswordEnrollmentAutoTrackConfig);
296
314
  destroy(): void;
297
315
  }
@@ -317,7 +335,7 @@ type PasskeyLoginCUIGetOptionsFinished = {
317
335
  };
318
336
  declare class OperationFullProvideIdentifierWithCUI {
319
337
  private tracker;
320
- private patternDetector?;
338
+ private lowEventTracker?;
321
339
  readonly cui: {
322
340
  trigger: (data: SubflowTrigger, options?: StepOptions) => void;
323
341
  getOptions: StepHelper<PasskeyLoginCUIGetOptionsStart, PasskeyLoginCUIGetOptionsFinished>;
@@ -360,6 +378,7 @@ interface TrackerOptions {
360
378
  deviceInfoDebounceTime?: number;
361
379
  defaultTags?: Record<string, string>;
362
380
  applicationId?: string;
381
+ flushInterval?: number;
363
382
  }
364
383
  /**
365
384
  * @remarks
@@ -391,9 +410,10 @@ declare class CorbadoTracker {
391
410
  private isTrackingBlocked;
392
411
  private getSessionId;
393
412
  private updateDeviceDebounced;
413
+ private resolveTrackingSourcePath;
394
414
  trackSubflowStarted(subflowType: SubflowType, data: Record<string, any>, options?: StepOptions): void;
395
415
  trackSubflowTrigger(subflowType: SubflowType, data: Record<string, any>, options?: StepOptions): void;
396
- trackSubflowStepStarted(subflowType: SubflowType, stepName: string, data: Record<string, any>, options?: StepOptions): void;
416
+ trackSubflowStepStarted(subflowType: SubflowType, stepName: string, data: Record<string, any>, options?: StepOptions, ignoreAsInteraction?: boolean): void;
397
417
  trackSubflowStepFinished(subflowType: SubflowType, stepName: string, data: Record<string, any>, options?: StepOptions): void;
398
418
  trackSubflowStepError(subflowType: SubflowType, stepName: string, data: Record<string, any>, options?: StepOptions): void;
399
419
  trackSubflowFinished(subflowType: SubflowType, data: Record<string, any>, options?: StepOptions): void;
@@ -479,7 +499,7 @@ declare class CorbadoTracker {
479
499
  * tracker.flowReset({flowName: "login"});
480
500
  * ```
481
501
  */
482
- flowReset(data: FlowReset, tags?: Record<string, string>): void;
502
+ flowReset(data: FlowReset | MultiFlowReset, tags?: Record<string, string>): void;
483
503
  /**
484
504
  * Track when a flow is considered finished because another flow finished it implicitly.
485
505
  *
@@ -525,6 +545,23 @@ declare class CorbadoTracker {
525
545
  authMethodsDecisionFinished(data: AuthMethodDecisionFinished, tags?: Record<string, string>): void;
526
546
  authDecisionStarted(data: AuthDecisionStarted): void;
527
547
  authDecisionFinished(data: AuthDecisionFinished): void;
548
+ /**
549
+ * Enqueue a "low" event (granular DOM/window/visualviewport/PWM signal) for the current session.
550
+ *
551
+ * @remarks
552
+ * Low events are sent in the `lows` array of the events endpoint payload, alongside any
553
+ * pending typed events. Blocked user agents are skipped silently.
554
+ *
555
+ * @internal
556
+ */
557
+ enqueueLowEvent(low: LowEvent): void;
558
+ /**
559
+ * Synchronously flush any pending events and low events via beacon. Use during page-unload
560
+ * style teardown where async flushing is unreliable.
561
+ *
562
+ * @internal
563
+ */
564
+ flushKeepalive(): void;
528
565
  passkeyLoginFullOperation(): PasskeyLoginOperationFull;
529
566
  passkeyEnrollmentFullOperation(): PasskeyEnrollmentOperationFull;
530
567
  passwordLoginFullOperation(autoTrackConfig?: PasswordLoginAutoTrackConfig): PasswordLoginOperationFull;
@@ -564,47 +601,6 @@ interface TransportOptions {
564
601
  headers?: Record<string, string>;
565
602
  }
566
603
 
567
- interface QueueOptions {
568
- batchSize?: number;
569
- flushInterval?: number;
570
- }
571
- /**
572
- * @remarks When `window` is defined, `visibilitychange` (when the document becomes hidden) and `pagehide` trigger a synchronous beacon flush (`flushSync`). Any thrown error in that path is logged as "Unexpected error in queue flushSync".
573
- */
574
- declare class RequestQueue {
575
- private readonly logger;
576
- private transport;
577
- private sessionId;
578
- private readonly sdk;
579
- private options;
580
- private queue;
581
- private timer;
582
- private isFlushing;
583
- private onVisibilityChange;
584
- private onPageHide;
585
- constructor(logger: Logger, transport: Transport, sessionId: string, sdk: SdkInfo, options?: QueueOptions);
586
- setSessionId(sessionId: string): void;
587
- /**
588
- * Error situations:
589
- * - Any error while enqueueing or scheduling flush (including a synchronous throw from `flush`): log "Failed to enqueue event"
590
- */
591
- enqueue(event: Event): void;
592
- /**
593
- * Error situations:
594
- * - Queue is empty: return without calling transport.send
595
- * - A flush is already in progress: return without calling transport.send again
596
- * - transport.send rejects or throws, or any other error in the try block: log "Unexpected error in queue flush"
597
- */
598
- flush(): Promise<void>;
599
- private setupLifecycleHooks;
600
- private flushSync;
601
- /**
602
- * Error situations:
603
- * - Timer clearance or event listener removal throws: log "Failed to destroy queue lifecycle hooks"
604
- */
605
- destroy(): void;
606
- }
607
-
608
604
  interface StorageEngine {
609
605
  getItem<T>(key: string): T | null;
610
606
  setItem<T>(key: string, value: T): void;
@@ -685,9 +681,64 @@ declare class SessionStorage implements StorageEngine {
685
681
  removeItem(key: string): void;
686
682
  }
687
683
 
684
+ interface QueueOptions {
685
+ batchSize?: number;
686
+ flushInterval?: number;
687
+ debug?: boolean;
688
+ }
689
+ /**
690
+ * @remarks When `window` is defined, `visibilitychange` (when the document becomes hidden) and `pagehide` trigger a synchronous beacon flush (`flushSync`). Any thrown error in that path is logged as "Unexpected error in queue flushSync".
691
+ */
692
+ declare class RequestQueue {
693
+ private readonly logger;
694
+ private transport;
695
+ private sessionId;
696
+ private readonly sdk;
697
+ private options;
698
+ private readonly storage?;
699
+ private queue;
700
+ private lowsQueue;
701
+ private timer;
702
+ private isFlushing;
703
+ private onVisibilityChange;
704
+ private onPageHide;
705
+ constructor(logger: Logger, transport: Transport, sessionId: string, sdk: SdkInfo, options?: QueueOptions, storage?: StorageEngine | undefined);
706
+ setSessionId(sessionId: string): void;
707
+ /**
708
+ * Error situations:
709
+ * - Any error while enqueueing or scheduling flush (including a synchronous throw from `flush`): log "Failed to enqueue event"
710
+ */
711
+ enqueue(event: Event): void;
712
+ /**
713
+ * Error situations:
714
+ * - Any error while enqueueing or scheduling flush (including a synchronous throw from `flush`): log "Failed to enqueue low event"
715
+ */
716
+ enqueueLow(low: LowEvent): void;
717
+ /**
718
+ * Error situations:
719
+ * - Queue is empty: return without calling transport.send
720
+ * - A flush is already in progress: return without calling transport.send again
721
+ * - transport.send rejects or throws, or any other error in the try block: log "Unexpected error in queue flush"
722
+ */
723
+ flush(): Promise<void>;
724
+ private setupLifecycleHooks;
725
+ private writeLifecycleDebugOutput;
726
+ /**
727
+ * Synchronously flush both events and lows via `sendBeacon` if the transport supports it.
728
+ * Safe to call multiple times: a no-op when both queues are empty.
729
+ */
730
+ flushKeepalive(): void;
731
+ private flushSync;
732
+ /**
733
+ * Error situations:
734
+ * - Timer clearance or event listener removal throws: log "Failed to destroy queue lifecycle hooks"
735
+ */
736
+ destroy(): void;
737
+ }
738
+
688
739
  declare function init(options: TrackerOptions): CorbadoTracker;
689
740
  declare function getTracker(): CorbadoTracker | undefined;
690
741
  declare function resetSession(): string | undefined;
691
742
  declare function destroy(): Promise<void>;
692
743
 
693
- export { type AuthDecisionFinished, type AuthDecisionStarted, AuthEventName, type AuthMethodDecisionFinished, type AuthMethodDecisionStarted, type AuthMethodType, type BaseEvent, type ClientCapabilities, type ClientEnvHandleMeta, type ClientEnvHandleMetaSource, CookieStorage, CorbadoTracker, type CreateLoggerOptions, type CustomEvent, type DeviceInfo, type DeviceInfoDataWeb, type DeviceType, EmailLinkOperationFull, type EmailLinkOperationPostResponseStart, type EmailLinkOperationSendStart, type EmailLinkOperationSpecType, type EmailOTPOperationPostResponseStart, type EmailOTPOperationSendOTPStart, type EmailOTPOperationSpecType, EmailOtpOperationFull, type Event, type EventBatch, type EventType, type FlowAutoFinished, type FlowDecided, type FlowFinished, type FlowReset, type FlowStarted, type FlowType, type JavaScriptHighEntropy, LocalStorage, type Logger, type MultiFlowStarted, type NormalizedError, OperationFull, OperationFullProvideIdentifierWithCUI, type PasskeyEnrollmentCeremonyFinished, type PasskeyEnrollmentCeremonyStart, type PasskeyEnrollmentGetOptionsFinished, type PasskeyEnrollmentGetOptionsStart, PasskeyEnrollmentOperationFull, type PasskeyLoginCUIGetOptionsFinished, type PasskeyLoginCUIGetOptionsStart, type PasskeyLoginCUISpecType, type PasskeyLoginCeremonyFinished, type PasskeyLoginCeremonyStart, type PasskeyLoginClientError, type PasskeyLoginFinish, type PasskeyLoginGetOptionsFinished, type PasskeyLoginGetOptionsStart, PasskeyLoginOperationFull, type PasskeyLoginStartable, type PasskeyLoginSubmitted, type PasskeyOperationEnrollmentExplicitSpecType, type PasskeyOperationLoginExplicitSpecType, type PasswordEnrollmentAutoTrackConfig, PasswordEnrollmentOperationFull, type PasswordEnrollmentTypedError, type PasswordLoginAutoTrackConfig, PasswordLoginOperationFull, type PasswordLoginTypedError, type PredefinedEvent, type ProvideIdentifierError, type ProvideIdentifierFinish, type ProvideIdentifierPostResponseStart, type ProvideIdentifierSpecType, type ProvideIdentifierStart, type QueueOptions, RequestQueue, SDK_NAME, SDK_VERSION, type SdkInfo, SessionStorage, type SocialLoginExchangeCodeFinished, type SocialLoginExchangeCodeStart, type SocialLoginGetRedirectUrlFinished, type SocialLoginGetRedirectUrlStart, SocialLoginOperationFull, type SocialLoginProviderType, type SocialLoginSpecType, type StepHelper, type StepOptions, type StorageEngine, type SubflowTrigger, type SubflowType, type TrackerOptions, type Transport, type TransportMakeRequestResponse, type TransportOptions, type UserReference, createLogger, destroy, getTracker, init, resetSession };
744
+ export { type AuthDecisionFinished, type AuthDecisionStarted, AuthEventName, type AuthMethodDecisionFinished, type AuthMethodDecisionStarted, type AuthMethodType, type BaseEvent, type ClientCapabilities, type ClientEnvHandleMeta, type ClientEnvHandleMetaSource, CookieStorage, CorbadoTracker, type CreateLoggerOptions, type CustomEvent, type DeviceInfo, type DeviceInfoDataWeb, type DeviceType, EmailLinkOperationFull, type EmailLinkOperationPostResponseStart, type EmailLinkOperationSendStart, type EmailLinkOperationSpecType, type EmailOTPOperationPostResponseStart, type EmailOTPOperationSendOTPStart, type EmailOTPOperationSpecType, EmailOtpOperationFull, type Event, type EventBatch, type EventBatchMeta, type EventMeta, type EventType, type FlowAutoFinished, type FlowDecided, type FlowFinished, type FlowReset, type FlowStarted, type FlowType, type JavaScriptHighEntropy, LocalStorage, type Logger, type LowEvent, type MultiFlowReset, type MultiFlowStarted, type NormalizedError, OperationFull, OperationFullProvideIdentifierWithCUI, type PasskeyEnrollmentCeremonyFinished, type PasskeyEnrollmentCeremonyStart, type PasskeyEnrollmentGetOptionsFinished, type PasskeyEnrollmentGetOptionsStart, PasskeyEnrollmentOperationFull, type PasskeyLoginCUIGetOptionsFinished, type PasskeyLoginCUIGetOptionsStart, type PasskeyLoginCUISpecType, type PasskeyLoginCeremonyFinished, type PasskeyLoginCeremonyStart, type PasskeyLoginClientError, type PasskeyLoginFinish, type PasskeyLoginGetOptionsFinished, type PasskeyLoginGetOptionsStart, PasskeyLoginOperationFull, type PasskeyLoginStartable, type PasskeyLoginSubmitted, type PasskeyOperationEnrollmentExplicitSpecType, type PasskeyOperationLoginExplicitSpecType, type PasswordEnrollmentAutoTrackConfig, PasswordEnrollmentOperationFull, type PasswordEnrollmentTypedError, type PasswordLoginAutoTrackConfig, PasswordLoginOperationFull, type PasswordLoginTypedError, type PredefinedEvent, type ProvideIdentifierError, type ProvideIdentifierFinish, type ProvideIdentifierPostResponseStart, type ProvideIdentifierSpecType, type ProvideIdentifierStart, type QueueOptions, RequestQueue, SDK_NAME, SDK_VERSION, type SdkInfo, SessionStorage, type SocialLoginExchangeCodeFinished, type SocialLoginExchangeCodeStart, type SocialLoginGetRedirectUrlFinished, type SocialLoginGetRedirectUrlStart, SocialLoginOperationFull, type SocialLoginProviderType, type SocialLoginSpecType, type StepHelper, type StepOptions, type StorageEngine, type SubflowTrigger, type SubflowType, type TrackerOptions, type Transport, type TransportMakeRequestResponse, type TransportOptions, type UserReference, createLogger, destroy, getTracker, init, resetSession };