@corbado/observe 0.4.0 → 0.5.0-next.37-0eb15e7
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 +81 -14
- package/dist/index.d.ts +81 -14
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -38,6 +38,13 @@ interface BaseEvent {
|
|
|
38
38
|
user?: UserReference;
|
|
39
39
|
contexts?: Record<string, unknown>;
|
|
40
40
|
tags?: Record<string, string>;
|
|
41
|
+
/**
|
|
42
|
+
* Experiment assignments active for this event, as a map of experiment key → variant value (e.g.
|
|
43
|
+
* `{ button_color: "blue" }`). First-class, prefix-free representation of A/B-test exposure: the
|
|
44
|
+
* backend attaches these to the flow. Resolved per event from the tracker's persistent assignments
|
|
45
|
+
* (see `setExperiment`) merged with any per-call override.
|
|
46
|
+
*/
|
|
47
|
+
experiments?: Record<string, string>;
|
|
41
48
|
deviceInfo?: DeviceInfo;
|
|
42
49
|
meta?: EventMeta;
|
|
43
50
|
}
|
|
@@ -130,6 +137,8 @@ type AuthDecisionFinished = {
|
|
|
130
137
|
type StepOptions = {
|
|
131
138
|
userReference?: UserReference;
|
|
132
139
|
explicitTimestamp?: number;
|
|
140
|
+
/** Per-call experiment override (experiment key → variant), merged over the persistent assignments. */
|
|
141
|
+
experiments?: Record<string, string>;
|
|
133
142
|
};
|
|
134
143
|
type SubflowTrigger = {
|
|
135
144
|
actor: "system" | "user";
|
|
@@ -470,10 +479,19 @@ type PasswordLoginTypedError = {
|
|
|
470
479
|
code: PasswordLoginTypedErrorCode;
|
|
471
480
|
};
|
|
472
481
|
type PasswordLoginTypedErrorCode = "invalid_password" | "user_not_found" | "account_locked";
|
|
473
|
-
type PasswordLoginExplicitSpecType = "password-known-identifier" | "password-with-identifier";
|
|
474
482
|
type PasswordLoginAutoTrackConfig = {
|
|
475
|
-
explicitSpecType:
|
|
483
|
+
explicitSpecType: "password-known-identifier";
|
|
484
|
+
/** The password input field. */
|
|
476
485
|
inputHtmlField: HTMLInputElement;
|
|
486
|
+
} | {
|
|
487
|
+
explicitSpecType: "password-with-identifier";
|
|
488
|
+
/** The password input field. */
|
|
489
|
+
inputHtmlField: HTMLInputElement;
|
|
490
|
+
/**
|
|
491
|
+
* The identifier (e.g. email) input field. Accepted but not tracked yet — low-event
|
|
492
|
+
* tracking for a second field lands together with per-field attribution.
|
|
493
|
+
*/
|
|
494
|
+
identifierInputHtmlField?: HTMLInputElement;
|
|
477
495
|
};
|
|
478
496
|
declare class PasswordLoginOperationFull extends OperationFull {
|
|
479
497
|
readonly postResponse: StepHelper<{}, {}, PasswordLoginTypedError>;
|
|
@@ -574,6 +592,11 @@ interface TrackerOptions {
|
|
|
574
592
|
logger?: Logger;
|
|
575
593
|
deviceInfoDebounceTime?: number;
|
|
576
594
|
defaultTags?: Record<string, string>;
|
|
595
|
+
/**
|
|
596
|
+
* Experiment assignments to seed at init (experiment key → variant). Merged over any persisted
|
|
597
|
+
* assignments and then attached to every event the tracker produces (see {@link CorbadoTracker.setExperiment}).
|
|
598
|
+
*/
|
|
599
|
+
experiments?: Record<string, string>;
|
|
577
600
|
applicationId?: string;
|
|
578
601
|
/**
|
|
579
602
|
* @deprecated The flush interval is server-controlled via the SDK reliability config
|
|
@@ -582,6 +605,8 @@ interface TrackerOptions {
|
|
|
582
605
|
* It will be removed in a future release.
|
|
583
606
|
*/
|
|
584
607
|
flushInterval?: number;
|
|
608
|
+
/** Generates new Observe session ids; returned values must be UUID-compatible. Existing stored sessions are still reused. */
|
|
609
|
+
sessionIdGenerator?: () => string;
|
|
585
610
|
}
|
|
586
611
|
declare class CorbadoTracker {
|
|
587
612
|
private options;
|
|
@@ -598,6 +623,8 @@ declare class CorbadoTracker {
|
|
|
598
623
|
private deviceInfoDebounceTime;
|
|
599
624
|
private deviceInfoTransmittedLastTime;
|
|
600
625
|
private seq;
|
|
626
|
+
/** Persistent experiment assignments (experiment key → variant), attached to every produced event. */
|
|
627
|
+
private experiments;
|
|
601
628
|
constructor(options: TrackerOptions);
|
|
602
629
|
/**
|
|
603
630
|
* Cache fresh server config as last-known. Boot-snapshot model: the config is NOT applied to this
|
|
@@ -610,7 +637,42 @@ declare class CorbadoTracker {
|
|
|
610
637
|
*/
|
|
611
638
|
getLogger(): Logger;
|
|
612
639
|
private applicationTag;
|
|
640
|
+
/**
|
|
641
|
+
* Register the user's variant for an experiment (e.g. `setExperiment("button_color", "blue")`).
|
|
642
|
+
*
|
|
643
|
+
* @remarks
|
|
644
|
+
* Corbado Observe does not assign variants — your app decides, and this records the assignment so
|
|
645
|
+
* Observe can attribute flows to it. The assignment persists (localStorage) across reloads and
|
|
646
|
+
* `resetSession`, and is attached to every event the tracker produces until you change or clear it.
|
|
647
|
+
* Multiple experiments can be active at once. Set it close to where the variant actually affects the
|
|
648
|
+
* user (or use the per-call `experiments` argument on a tracking method) to avoid over-attributing
|
|
649
|
+
* exposure; call {@link clearExperiment} when it no longer applies (e.g. on logout).
|
|
650
|
+
*
|
|
651
|
+
* Never throws: invalid input is ignored with a debug log.
|
|
652
|
+
*/
|
|
653
|
+
setExperiment(key: string, variant: string): void;
|
|
654
|
+
/**
|
|
655
|
+
* Register several experiment assignments at once (experiment key → variant). Additive: existing
|
|
656
|
+
* assignments for other keys are kept. See {@link setExperiment}.
|
|
657
|
+
*/
|
|
658
|
+
setExperiments(assignments: Record<string, string>): void;
|
|
659
|
+
/** Remove a single experiment assignment. */
|
|
660
|
+
clearExperiment(key: string): void;
|
|
661
|
+
/** Remove all experiment assignments. */
|
|
662
|
+
clearExperiments(): void;
|
|
663
|
+
/** Returns a copy of the currently active experiment assignments. */
|
|
664
|
+
getExperiments(): Record<string, string>;
|
|
665
|
+
private static isValidExperimentKey;
|
|
666
|
+
private static isValidExperimentVariant;
|
|
667
|
+
private loadPersistedExperiments;
|
|
668
|
+
private persistExperiments;
|
|
669
|
+
/**
|
|
670
|
+
* Resolves the experiments to attach to one event: the persistent assignments with any per-call
|
|
671
|
+
* override merged on top. Returns undefined when there are none (so the field is omitted).
|
|
672
|
+
*/
|
|
673
|
+
private resolveExperiments;
|
|
613
674
|
private isTrackingBlocked;
|
|
675
|
+
private createSessionId;
|
|
614
676
|
private getSessionId;
|
|
615
677
|
/**
|
|
616
678
|
* Resolve the session id from localStorage so it survives reloads and is shared across tabs of the
|
|
@@ -645,7 +707,7 @@ declare class CorbadoTracker {
|
|
|
645
707
|
*
|
|
646
708
|
* @internal
|
|
647
709
|
*/
|
|
648
|
-
track(name: AuthEventName, data: Record<string, any>, userReference?: UserReference, tags?: Record<string, string>, contexts?: Record<string, any>, explicitTimestamp?: number): Promise<void>;
|
|
710
|
+
track(name: AuthEventName, data: Record<string, any>, userReference?: UserReference, tags?: Record<string, string>, contexts?: Record<string, any>, explicitTimestamp?: number, experiments?: Record<string, string>): Promise<void>;
|
|
649
711
|
/**
|
|
650
712
|
* Track when an authentication flow (or flow selection screen) becomes visible.
|
|
651
713
|
*
|
|
@@ -666,7 +728,7 @@ declare class CorbadoTracker {
|
|
|
666
728
|
* });
|
|
667
729
|
* ```
|
|
668
730
|
*/
|
|
669
|
-
flowStarted(data: FlowStarted | MultiFlowStarted, tags?: Record<string, string>): void;
|
|
731
|
+
flowStarted(data: FlowStarted | MultiFlowStarted, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
670
732
|
/**
|
|
671
733
|
* Track when the user commits to a specific flow.
|
|
672
734
|
*
|
|
@@ -682,7 +744,7 @@ declare class CorbadoTracker {
|
|
|
682
744
|
* tracker.flowDecided({flowName: "signup"});
|
|
683
745
|
* ```
|
|
684
746
|
*/
|
|
685
|
-
flowDecided(data: FlowDecided, tags?: Record<string, string>): void;
|
|
747
|
+
flowDecided(data: FlowDecided, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
686
748
|
/**
|
|
687
749
|
* Track a business/marketing conversion that is not part of an authentication flow.
|
|
688
750
|
*
|
|
@@ -705,7 +767,7 @@ declare class CorbadoTracker {
|
|
|
705
767
|
* });
|
|
706
768
|
* ```
|
|
707
769
|
*/
|
|
708
|
-
conversion(data: Conversion, tags?: Record<string, string>): void;
|
|
770
|
+
conversion(data: Conversion, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
709
771
|
/**
|
|
710
772
|
* Track when a flow successfully completes.
|
|
711
773
|
*
|
|
@@ -726,7 +788,7 @@ declare class CorbadoTracker {
|
|
|
726
788
|
* });
|
|
727
789
|
* ```
|
|
728
790
|
*/
|
|
729
|
-
flowFinished(data: FlowFinished, tags?: Record<string, string>): void;
|
|
791
|
+
flowFinished(data: FlowFinished, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
730
792
|
/**
|
|
731
793
|
* Track when an in-progress flow is reset and restarted.
|
|
732
794
|
*
|
|
@@ -742,7 +804,7 @@ declare class CorbadoTracker {
|
|
|
742
804
|
* tracker.flowReset({flowName: "login"});
|
|
743
805
|
* ```
|
|
744
806
|
*/
|
|
745
|
-
flowReset(data: FlowReset | MultiFlowReset, tags?: Record<string, string>): void;
|
|
807
|
+
flowReset(data: FlowReset | MultiFlowReset, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
746
808
|
/**
|
|
747
809
|
* Track when a flow is considered finished because another flow finished it implicitly.
|
|
748
810
|
*
|
|
@@ -763,7 +825,7 @@ declare class CorbadoTracker {
|
|
|
763
825
|
* });
|
|
764
826
|
* ```
|
|
765
827
|
*/
|
|
766
|
-
flowAutoFinished(data: FlowAutoFinished, tags?: Record<string, string>): void;
|
|
828
|
+
flowAutoFinished(data: FlowAutoFinished, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
767
829
|
/**
|
|
768
830
|
* Track when you present authentication method choices to the user.
|
|
769
831
|
*
|
|
@@ -784,10 +846,10 @@ declare class CorbadoTracker {
|
|
|
784
846
|
* });
|
|
785
847
|
* ```
|
|
786
848
|
*/
|
|
787
|
-
authMethodsDecisionStarted(data: AuthMethodDecisionStarted, tags?: Record<string, string>): void;
|
|
788
|
-
authMethodsDecisionFinished(data: AuthMethodDecisionFinished, tags?: Record<string, string>): void;
|
|
789
|
-
authDecisionStarted(data: AuthDecisionStarted): void;
|
|
790
|
-
authDecisionFinished(data: AuthDecisionFinished): void;
|
|
849
|
+
authMethodsDecisionStarted(data: AuthMethodDecisionStarted, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
850
|
+
authMethodsDecisionFinished(data: AuthMethodDecisionFinished, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
851
|
+
authDecisionStarted(data: AuthDecisionStarted, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
852
|
+
authDecisionFinished(data: AuthDecisionFinished, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
791
853
|
/**
|
|
792
854
|
* Enqueue a "low" event (granular DOM/window/visualviewport/PWM signal) for the current session.
|
|
793
855
|
*
|
|
@@ -1213,6 +1275,11 @@ declare class EventStore {
|
|
|
1213
1275
|
declare function init(options: TrackerOptions): CorbadoTracker;
|
|
1214
1276
|
declare function getTracker(): CorbadoTracker | undefined;
|
|
1215
1277
|
declare function resetSession(): string | undefined;
|
|
1278
|
+
declare function setExperiment(key: string, variant: string): void;
|
|
1279
|
+
declare function setExperiments(assignments: Record<string, string>): void;
|
|
1280
|
+
declare function clearExperiment(key: string): void;
|
|
1281
|
+
declare function clearExperiments(): void;
|
|
1282
|
+
declare function getExperiments(): Record<string, string>;
|
|
1216
1283
|
declare function destroy(): Promise<void>;
|
|
1217
1284
|
|
|
1218
|
-
export { 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 ClientCapabilities, type ClientEnvHandleMeta, type ClientEnvHandleMetaSource, type Conversion, CookieStorage, CorbadoTracker, type CreateLoggerOptions, type CustomEvent, DEFAULT_FLUSH_INTERVAL_MS, DEFAULT_MAX_ENTRIES, DEFAULT_MAX_SERIALIZED_LENGTH, DEFAULT_RELIABILITY_CONFIG, DEFAULT_SESSION_INACTIVITY_MS, type DeviceInfo, type DeviceInfoCollectionError, 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, EventStore, 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, OUTBOX_LOCK_NAME, OUTBOX_STORAGE_KEY, OperationFull, OperationFullProvideIdentifierWithCUI, type OutboxEntry, 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, type SdkReliabilityConfig, type SdkRetryConfig, 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, cacheConfig, createLogger, destroy, getTracker, init, loadCachedConfig, parseReliabilityConfig, resetSession };
|
|
1285
|
+
export { 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 ClientCapabilities, type ClientEnvHandleMeta, type ClientEnvHandleMetaSource, type Conversion, CookieStorage, CorbadoTracker, type CreateLoggerOptions, type CustomEvent, DEFAULT_FLUSH_INTERVAL_MS, DEFAULT_MAX_ENTRIES, DEFAULT_MAX_SERIALIZED_LENGTH, DEFAULT_RELIABILITY_CONFIG, DEFAULT_SESSION_INACTIVITY_MS, type DeviceInfo, type DeviceInfoCollectionError, 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, EventStore, 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, OUTBOX_LOCK_NAME, OUTBOX_STORAGE_KEY, OperationFull, OperationFullProvideIdentifierWithCUI, type OutboxEntry, 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, type SdkReliabilityConfig, type SdkRetryConfig, 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, cacheConfig, clearExperiment, clearExperiments, createLogger, destroy, getExperiments, getTracker, init, loadCachedConfig, parseReliabilityConfig, resetSession, setExperiment, setExperiments };
|
package/dist/index.d.ts
CHANGED
|
@@ -38,6 +38,13 @@ interface BaseEvent {
|
|
|
38
38
|
user?: UserReference;
|
|
39
39
|
contexts?: Record<string, unknown>;
|
|
40
40
|
tags?: Record<string, string>;
|
|
41
|
+
/**
|
|
42
|
+
* Experiment assignments active for this event, as a map of experiment key → variant value (e.g.
|
|
43
|
+
* `{ button_color: "blue" }`). First-class, prefix-free representation of A/B-test exposure: the
|
|
44
|
+
* backend attaches these to the flow. Resolved per event from the tracker's persistent assignments
|
|
45
|
+
* (see `setExperiment`) merged with any per-call override.
|
|
46
|
+
*/
|
|
47
|
+
experiments?: Record<string, string>;
|
|
41
48
|
deviceInfo?: DeviceInfo;
|
|
42
49
|
meta?: EventMeta;
|
|
43
50
|
}
|
|
@@ -130,6 +137,8 @@ type AuthDecisionFinished = {
|
|
|
130
137
|
type StepOptions = {
|
|
131
138
|
userReference?: UserReference;
|
|
132
139
|
explicitTimestamp?: number;
|
|
140
|
+
/** Per-call experiment override (experiment key → variant), merged over the persistent assignments. */
|
|
141
|
+
experiments?: Record<string, string>;
|
|
133
142
|
};
|
|
134
143
|
type SubflowTrigger = {
|
|
135
144
|
actor: "system" | "user";
|
|
@@ -470,10 +479,19 @@ type PasswordLoginTypedError = {
|
|
|
470
479
|
code: PasswordLoginTypedErrorCode;
|
|
471
480
|
};
|
|
472
481
|
type PasswordLoginTypedErrorCode = "invalid_password" | "user_not_found" | "account_locked";
|
|
473
|
-
type PasswordLoginExplicitSpecType = "password-known-identifier" | "password-with-identifier";
|
|
474
482
|
type PasswordLoginAutoTrackConfig = {
|
|
475
|
-
explicitSpecType:
|
|
483
|
+
explicitSpecType: "password-known-identifier";
|
|
484
|
+
/** The password input field. */
|
|
476
485
|
inputHtmlField: HTMLInputElement;
|
|
486
|
+
} | {
|
|
487
|
+
explicitSpecType: "password-with-identifier";
|
|
488
|
+
/** The password input field. */
|
|
489
|
+
inputHtmlField: HTMLInputElement;
|
|
490
|
+
/**
|
|
491
|
+
* The identifier (e.g. email) input field. Accepted but not tracked yet — low-event
|
|
492
|
+
* tracking for a second field lands together with per-field attribution.
|
|
493
|
+
*/
|
|
494
|
+
identifierInputHtmlField?: HTMLInputElement;
|
|
477
495
|
};
|
|
478
496
|
declare class PasswordLoginOperationFull extends OperationFull {
|
|
479
497
|
readonly postResponse: StepHelper<{}, {}, PasswordLoginTypedError>;
|
|
@@ -574,6 +592,11 @@ interface TrackerOptions {
|
|
|
574
592
|
logger?: Logger;
|
|
575
593
|
deviceInfoDebounceTime?: number;
|
|
576
594
|
defaultTags?: Record<string, string>;
|
|
595
|
+
/**
|
|
596
|
+
* Experiment assignments to seed at init (experiment key → variant). Merged over any persisted
|
|
597
|
+
* assignments and then attached to every event the tracker produces (see {@link CorbadoTracker.setExperiment}).
|
|
598
|
+
*/
|
|
599
|
+
experiments?: Record<string, string>;
|
|
577
600
|
applicationId?: string;
|
|
578
601
|
/**
|
|
579
602
|
* @deprecated The flush interval is server-controlled via the SDK reliability config
|
|
@@ -582,6 +605,8 @@ interface TrackerOptions {
|
|
|
582
605
|
* It will be removed in a future release.
|
|
583
606
|
*/
|
|
584
607
|
flushInterval?: number;
|
|
608
|
+
/** Generates new Observe session ids; returned values must be UUID-compatible. Existing stored sessions are still reused. */
|
|
609
|
+
sessionIdGenerator?: () => string;
|
|
585
610
|
}
|
|
586
611
|
declare class CorbadoTracker {
|
|
587
612
|
private options;
|
|
@@ -598,6 +623,8 @@ declare class CorbadoTracker {
|
|
|
598
623
|
private deviceInfoDebounceTime;
|
|
599
624
|
private deviceInfoTransmittedLastTime;
|
|
600
625
|
private seq;
|
|
626
|
+
/** Persistent experiment assignments (experiment key → variant), attached to every produced event. */
|
|
627
|
+
private experiments;
|
|
601
628
|
constructor(options: TrackerOptions);
|
|
602
629
|
/**
|
|
603
630
|
* Cache fresh server config as last-known. Boot-snapshot model: the config is NOT applied to this
|
|
@@ -610,7 +637,42 @@ declare class CorbadoTracker {
|
|
|
610
637
|
*/
|
|
611
638
|
getLogger(): Logger;
|
|
612
639
|
private applicationTag;
|
|
640
|
+
/**
|
|
641
|
+
* Register the user's variant for an experiment (e.g. `setExperiment("button_color", "blue")`).
|
|
642
|
+
*
|
|
643
|
+
* @remarks
|
|
644
|
+
* Corbado Observe does not assign variants — your app decides, and this records the assignment so
|
|
645
|
+
* Observe can attribute flows to it. The assignment persists (localStorage) across reloads and
|
|
646
|
+
* `resetSession`, and is attached to every event the tracker produces until you change or clear it.
|
|
647
|
+
* Multiple experiments can be active at once. Set it close to where the variant actually affects the
|
|
648
|
+
* user (or use the per-call `experiments` argument on a tracking method) to avoid over-attributing
|
|
649
|
+
* exposure; call {@link clearExperiment} when it no longer applies (e.g. on logout).
|
|
650
|
+
*
|
|
651
|
+
* Never throws: invalid input is ignored with a debug log.
|
|
652
|
+
*/
|
|
653
|
+
setExperiment(key: string, variant: string): void;
|
|
654
|
+
/**
|
|
655
|
+
* Register several experiment assignments at once (experiment key → variant). Additive: existing
|
|
656
|
+
* assignments for other keys are kept. See {@link setExperiment}.
|
|
657
|
+
*/
|
|
658
|
+
setExperiments(assignments: Record<string, string>): void;
|
|
659
|
+
/** Remove a single experiment assignment. */
|
|
660
|
+
clearExperiment(key: string): void;
|
|
661
|
+
/** Remove all experiment assignments. */
|
|
662
|
+
clearExperiments(): void;
|
|
663
|
+
/** Returns a copy of the currently active experiment assignments. */
|
|
664
|
+
getExperiments(): Record<string, string>;
|
|
665
|
+
private static isValidExperimentKey;
|
|
666
|
+
private static isValidExperimentVariant;
|
|
667
|
+
private loadPersistedExperiments;
|
|
668
|
+
private persistExperiments;
|
|
669
|
+
/**
|
|
670
|
+
* Resolves the experiments to attach to one event: the persistent assignments with any per-call
|
|
671
|
+
* override merged on top. Returns undefined when there are none (so the field is omitted).
|
|
672
|
+
*/
|
|
673
|
+
private resolveExperiments;
|
|
613
674
|
private isTrackingBlocked;
|
|
675
|
+
private createSessionId;
|
|
614
676
|
private getSessionId;
|
|
615
677
|
/**
|
|
616
678
|
* Resolve the session id from localStorage so it survives reloads and is shared across tabs of the
|
|
@@ -645,7 +707,7 @@ declare class CorbadoTracker {
|
|
|
645
707
|
*
|
|
646
708
|
* @internal
|
|
647
709
|
*/
|
|
648
|
-
track(name: AuthEventName, data: Record<string, any>, userReference?: UserReference, tags?: Record<string, string>, contexts?: Record<string, any>, explicitTimestamp?: number): Promise<void>;
|
|
710
|
+
track(name: AuthEventName, data: Record<string, any>, userReference?: UserReference, tags?: Record<string, string>, contexts?: Record<string, any>, explicitTimestamp?: number, experiments?: Record<string, string>): Promise<void>;
|
|
649
711
|
/**
|
|
650
712
|
* Track when an authentication flow (or flow selection screen) becomes visible.
|
|
651
713
|
*
|
|
@@ -666,7 +728,7 @@ declare class CorbadoTracker {
|
|
|
666
728
|
* });
|
|
667
729
|
* ```
|
|
668
730
|
*/
|
|
669
|
-
flowStarted(data: FlowStarted | MultiFlowStarted, tags?: Record<string, string>): void;
|
|
731
|
+
flowStarted(data: FlowStarted | MultiFlowStarted, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
670
732
|
/**
|
|
671
733
|
* Track when the user commits to a specific flow.
|
|
672
734
|
*
|
|
@@ -682,7 +744,7 @@ declare class CorbadoTracker {
|
|
|
682
744
|
* tracker.flowDecided({flowName: "signup"});
|
|
683
745
|
* ```
|
|
684
746
|
*/
|
|
685
|
-
flowDecided(data: FlowDecided, tags?: Record<string, string>): void;
|
|
747
|
+
flowDecided(data: FlowDecided, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
686
748
|
/**
|
|
687
749
|
* Track a business/marketing conversion that is not part of an authentication flow.
|
|
688
750
|
*
|
|
@@ -705,7 +767,7 @@ declare class CorbadoTracker {
|
|
|
705
767
|
* });
|
|
706
768
|
* ```
|
|
707
769
|
*/
|
|
708
|
-
conversion(data: Conversion, tags?: Record<string, string>): void;
|
|
770
|
+
conversion(data: Conversion, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
709
771
|
/**
|
|
710
772
|
* Track when a flow successfully completes.
|
|
711
773
|
*
|
|
@@ -726,7 +788,7 @@ declare class CorbadoTracker {
|
|
|
726
788
|
* });
|
|
727
789
|
* ```
|
|
728
790
|
*/
|
|
729
|
-
flowFinished(data: FlowFinished, tags?: Record<string, string>): void;
|
|
791
|
+
flowFinished(data: FlowFinished, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
730
792
|
/**
|
|
731
793
|
* Track when an in-progress flow is reset and restarted.
|
|
732
794
|
*
|
|
@@ -742,7 +804,7 @@ declare class CorbadoTracker {
|
|
|
742
804
|
* tracker.flowReset({flowName: "login"});
|
|
743
805
|
* ```
|
|
744
806
|
*/
|
|
745
|
-
flowReset(data: FlowReset | MultiFlowReset, tags?: Record<string, string>): void;
|
|
807
|
+
flowReset(data: FlowReset | MultiFlowReset, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
746
808
|
/**
|
|
747
809
|
* Track when a flow is considered finished because another flow finished it implicitly.
|
|
748
810
|
*
|
|
@@ -763,7 +825,7 @@ declare class CorbadoTracker {
|
|
|
763
825
|
* });
|
|
764
826
|
* ```
|
|
765
827
|
*/
|
|
766
|
-
flowAutoFinished(data: FlowAutoFinished, tags?: Record<string, string>): void;
|
|
828
|
+
flowAutoFinished(data: FlowAutoFinished, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
767
829
|
/**
|
|
768
830
|
* Track when you present authentication method choices to the user.
|
|
769
831
|
*
|
|
@@ -784,10 +846,10 @@ declare class CorbadoTracker {
|
|
|
784
846
|
* });
|
|
785
847
|
* ```
|
|
786
848
|
*/
|
|
787
|
-
authMethodsDecisionStarted(data: AuthMethodDecisionStarted, tags?: Record<string, string>): void;
|
|
788
|
-
authMethodsDecisionFinished(data: AuthMethodDecisionFinished, tags?: Record<string, string>): void;
|
|
789
|
-
authDecisionStarted(data: AuthDecisionStarted): void;
|
|
790
|
-
authDecisionFinished(data: AuthDecisionFinished): void;
|
|
849
|
+
authMethodsDecisionStarted(data: AuthMethodDecisionStarted, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
850
|
+
authMethodsDecisionFinished(data: AuthMethodDecisionFinished, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
851
|
+
authDecisionStarted(data: AuthDecisionStarted, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
852
|
+
authDecisionFinished(data: AuthDecisionFinished, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
791
853
|
/**
|
|
792
854
|
* Enqueue a "low" event (granular DOM/window/visualviewport/PWM signal) for the current session.
|
|
793
855
|
*
|
|
@@ -1213,6 +1275,11 @@ declare class EventStore {
|
|
|
1213
1275
|
declare function init(options: TrackerOptions): CorbadoTracker;
|
|
1214
1276
|
declare function getTracker(): CorbadoTracker | undefined;
|
|
1215
1277
|
declare function resetSession(): string | undefined;
|
|
1278
|
+
declare function setExperiment(key: string, variant: string): void;
|
|
1279
|
+
declare function setExperiments(assignments: Record<string, string>): void;
|
|
1280
|
+
declare function clearExperiment(key: string): void;
|
|
1281
|
+
declare function clearExperiments(): void;
|
|
1282
|
+
declare function getExperiments(): Record<string, string>;
|
|
1216
1283
|
declare function destroy(): Promise<void>;
|
|
1217
1284
|
|
|
1218
|
-
export { 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 ClientCapabilities, type ClientEnvHandleMeta, type ClientEnvHandleMetaSource, type Conversion, CookieStorage, CorbadoTracker, type CreateLoggerOptions, type CustomEvent, DEFAULT_FLUSH_INTERVAL_MS, DEFAULT_MAX_ENTRIES, DEFAULT_MAX_SERIALIZED_LENGTH, DEFAULT_RELIABILITY_CONFIG, DEFAULT_SESSION_INACTIVITY_MS, type DeviceInfo, type DeviceInfoCollectionError, 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, EventStore, 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, OUTBOX_LOCK_NAME, OUTBOX_STORAGE_KEY, OperationFull, OperationFullProvideIdentifierWithCUI, type OutboxEntry, 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, type SdkReliabilityConfig, type SdkRetryConfig, 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, cacheConfig, createLogger, destroy, getTracker, init, loadCachedConfig, parseReliabilityConfig, resetSession };
|
|
1285
|
+
export { 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 ClientCapabilities, type ClientEnvHandleMeta, type ClientEnvHandleMetaSource, type Conversion, CookieStorage, CorbadoTracker, type CreateLoggerOptions, type CustomEvent, DEFAULT_FLUSH_INTERVAL_MS, DEFAULT_MAX_ENTRIES, DEFAULT_MAX_SERIALIZED_LENGTH, DEFAULT_RELIABILITY_CONFIG, DEFAULT_SESSION_INACTIVITY_MS, type DeviceInfo, type DeviceInfoCollectionError, 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, EventStore, 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, OUTBOX_LOCK_NAME, OUTBOX_STORAGE_KEY, OperationFull, OperationFullProvideIdentifierWithCUI, type OutboxEntry, 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, type SdkReliabilityConfig, type SdkRetryConfig, 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, cacheConfig, clearExperiment, clearExperiments, createLogger, destroy, getExperiments, getTracker, init, loadCachedConfig, parseReliabilityConfig, resetSession, setExperiment, setExperiments };
|