@corbado/observe 0.4.0-next.35-ad0ac60 → 0.5.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 +67 -15
- package/dist/index.d.ts +67 -15
- 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";
|
|
@@ -583,6 +592,11 @@ interface TrackerOptions {
|
|
|
583
592
|
logger?: Logger;
|
|
584
593
|
deviceInfoDebounceTime?: number;
|
|
585
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>;
|
|
586
600
|
applicationId?: string;
|
|
587
601
|
/**
|
|
588
602
|
* @deprecated The flush interval is server-controlled via the SDK reliability config
|
|
@@ -591,8 +605,6 @@ interface TrackerOptions {
|
|
|
591
605
|
* It will be removed in a future release.
|
|
592
606
|
*/
|
|
593
607
|
flushInterval?: number;
|
|
594
|
-
/** Generates new Observe session ids; returned values must be UUID-compatible. Existing stored sessions are still reused. */
|
|
595
|
-
sessionIdGenerator?: () => string;
|
|
596
608
|
}
|
|
597
609
|
declare class CorbadoTracker {
|
|
598
610
|
private options;
|
|
@@ -609,6 +621,8 @@ declare class CorbadoTracker {
|
|
|
609
621
|
private deviceInfoDebounceTime;
|
|
610
622
|
private deviceInfoTransmittedLastTime;
|
|
611
623
|
private seq;
|
|
624
|
+
/** Persistent experiment assignments (experiment key → variant), attached to every produced event. */
|
|
625
|
+
private experiments;
|
|
612
626
|
constructor(options: TrackerOptions);
|
|
613
627
|
/**
|
|
614
628
|
* Cache fresh server config as last-known. Boot-snapshot model: the config is NOT applied to this
|
|
@@ -621,8 +635,41 @@ declare class CorbadoTracker {
|
|
|
621
635
|
*/
|
|
622
636
|
getLogger(): Logger;
|
|
623
637
|
private applicationTag;
|
|
638
|
+
/**
|
|
639
|
+
* Register the user's variant for an experiment (e.g. `setExperiment("button_color", "blue")`).
|
|
640
|
+
*
|
|
641
|
+
* @remarks
|
|
642
|
+
* Corbado Observe does not assign variants — your app decides, and this records the assignment so
|
|
643
|
+
* Observe can attribute flows to it. The assignment persists (localStorage) across reloads and
|
|
644
|
+
* `resetSession`, and is attached to every event the tracker produces until you change or clear it.
|
|
645
|
+
* Multiple experiments can be active at once. Set it close to where the variant actually affects the
|
|
646
|
+
* user (or use the per-call `experiments` argument on a tracking method) to avoid over-attributing
|
|
647
|
+
* exposure; call {@link clearExperiment} when it no longer applies (e.g. on logout).
|
|
648
|
+
*
|
|
649
|
+
* Never throws: invalid input is ignored with a debug log.
|
|
650
|
+
*/
|
|
651
|
+
setExperiment(key: string, variant: string): void;
|
|
652
|
+
/**
|
|
653
|
+
* Register several experiment assignments at once (experiment key → variant). Additive: existing
|
|
654
|
+
* assignments for other keys are kept. See {@link setExperiment}.
|
|
655
|
+
*/
|
|
656
|
+
setExperiments(assignments: Record<string, string>): void;
|
|
657
|
+
/** Remove a single experiment assignment. */
|
|
658
|
+
clearExperiment(key: string): void;
|
|
659
|
+
/** Remove all experiment assignments. */
|
|
660
|
+
clearExperiments(): void;
|
|
661
|
+
/** Returns a copy of the currently active experiment assignments. */
|
|
662
|
+
getExperiments(): Record<string, string>;
|
|
663
|
+
private static isValidExperimentKey;
|
|
664
|
+
private static isValidExperimentVariant;
|
|
665
|
+
private loadPersistedExperiments;
|
|
666
|
+
private persistExperiments;
|
|
667
|
+
/**
|
|
668
|
+
* Resolves the experiments to attach to one event: the persistent assignments with any per-call
|
|
669
|
+
* override merged on top. Returns undefined when there are none (so the field is omitted).
|
|
670
|
+
*/
|
|
671
|
+
private resolveExperiments;
|
|
624
672
|
private isTrackingBlocked;
|
|
625
|
-
private createSessionId;
|
|
626
673
|
private getSessionId;
|
|
627
674
|
/**
|
|
628
675
|
* Resolve the session id from localStorage so it survives reloads and is shared across tabs of the
|
|
@@ -657,7 +704,7 @@ declare class CorbadoTracker {
|
|
|
657
704
|
*
|
|
658
705
|
* @internal
|
|
659
706
|
*/
|
|
660
|
-
track(name: AuthEventName, data: Record<string, any>, userReference?: UserReference, tags?: Record<string, string>, contexts?: Record<string, any>, explicitTimestamp?: number): Promise<void>;
|
|
707
|
+
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>;
|
|
661
708
|
/**
|
|
662
709
|
* Track when an authentication flow (or flow selection screen) becomes visible.
|
|
663
710
|
*
|
|
@@ -678,7 +725,7 @@ declare class CorbadoTracker {
|
|
|
678
725
|
* });
|
|
679
726
|
* ```
|
|
680
727
|
*/
|
|
681
|
-
flowStarted(data: FlowStarted | MultiFlowStarted, tags?: Record<string, string>): void;
|
|
728
|
+
flowStarted(data: FlowStarted | MultiFlowStarted, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
682
729
|
/**
|
|
683
730
|
* Track when the user commits to a specific flow.
|
|
684
731
|
*
|
|
@@ -694,7 +741,7 @@ declare class CorbadoTracker {
|
|
|
694
741
|
* tracker.flowDecided({flowName: "signup"});
|
|
695
742
|
* ```
|
|
696
743
|
*/
|
|
697
|
-
flowDecided(data: FlowDecided, tags?: Record<string, string>): void;
|
|
744
|
+
flowDecided(data: FlowDecided, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
698
745
|
/**
|
|
699
746
|
* Track a business/marketing conversion that is not part of an authentication flow.
|
|
700
747
|
*
|
|
@@ -717,7 +764,7 @@ declare class CorbadoTracker {
|
|
|
717
764
|
* });
|
|
718
765
|
* ```
|
|
719
766
|
*/
|
|
720
|
-
conversion(data: Conversion, tags?: Record<string, string>): void;
|
|
767
|
+
conversion(data: Conversion, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
721
768
|
/**
|
|
722
769
|
* Track when a flow successfully completes.
|
|
723
770
|
*
|
|
@@ -738,7 +785,7 @@ declare class CorbadoTracker {
|
|
|
738
785
|
* });
|
|
739
786
|
* ```
|
|
740
787
|
*/
|
|
741
|
-
flowFinished(data: FlowFinished, tags?: Record<string, string>): void;
|
|
788
|
+
flowFinished(data: FlowFinished, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
742
789
|
/**
|
|
743
790
|
* Track when an in-progress flow is reset and restarted.
|
|
744
791
|
*
|
|
@@ -754,7 +801,7 @@ declare class CorbadoTracker {
|
|
|
754
801
|
* tracker.flowReset({flowName: "login"});
|
|
755
802
|
* ```
|
|
756
803
|
*/
|
|
757
|
-
flowReset(data: FlowReset | MultiFlowReset, tags?: Record<string, string>): void;
|
|
804
|
+
flowReset(data: FlowReset | MultiFlowReset, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
758
805
|
/**
|
|
759
806
|
* Track when a flow is considered finished because another flow finished it implicitly.
|
|
760
807
|
*
|
|
@@ -775,7 +822,7 @@ declare class CorbadoTracker {
|
|
|
775
822
|
* });
|
|
776
823
|
* ```
|
|
777
824
|
*/
|
|
778
|
-
flowAutoFinished(data: FlowAutoFinished, tags?: Record<string, string>): void;
|
|
825
|
+
flowAutoFinished(data: FlowAutoFinished, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
779
826
|
/**
|
|
780
827
|
* Track when you present authentication method choices to the user.
|
|
781
828
|
*
|
|
@@ -796,10 +843,10 @@ declare class CorbadoTracker {
|
|
|
796
843
|
* });
|
|
797
844
|
* ```
|
|
798
845
|
*/
|
|
799
|
-
authMethodsDecisionStarted(data: AuthMethodDecisionStarted, tags?: Record<string, string>): void;
|
|
800
|
-
authMethodsDecisionFinished(data: AuthMethodDecisionFinished, tags?: Record<string, string>): void;
|
|
801
|
-
authDecisionStarted(data: AuthDecisionStarted): void;
|
|
802
|
-
authDecisionFinished(data: AuthDecisionFinished): void;
|
|
846
|
+
authMethodsDecisionStarted(data: AuthMethodDecisionStarted, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
847
|
+
authMethodsDecisionFinished(data: AuthMethodDecisionFinished, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
848
|
+
authDecisionStarted(data: AuthDecisionStarted, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
849
|
+
authDecisionFinished(data: AuthDecisionFinished, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
803
850
|
/**
|
|
804
851
|
* Enqueue a "low" event (granular DOM/window/visualviewport/PWM signal) for the current session.
|
|
805
852
|
*
|
|
@@ -1225,6 +1272,11 @@ declare class EventStore {
|
|
|
1225
1272
|
declare function init(options: TrackerOptions): CorbadoTracker;
|
|
1226
1273
|
declare function getTracker(): CorbadoTracker | undefined;
|
|
1227
1274
|
declare function resetSession(): string | undefined;
|
|
1275
|
+
declare function setExperiment(key: string, variant: string): void;
|
|
1276
|
+
declare function setExperiments(assignments: Record<string, string>): void;
|
|
1277
|
+
declare function clearExperiment(key: string): void;
|
|
1278
|
+
declare function clearExperiments(): void;
|
|
1279
|
+
declare function getExperiments(): Record<string, string>;
|
|
1228
1280
|
declare function destroy(): Promise<void>;
|
|
1229
1281
|
|
|
1230
|
-
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 };
|
|
1282
|
+
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";
|
|
@@ -583,6 +592,11 @@ interface TrackerOptions {
|
|
|
583
592
|
logger?: Logger;
|
|
584
593
|
deviceInfoDebounceTime?: number;
|
|
585
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>;
|
|
586
600
|
applicationId?: string;
|
|
587
601
|
/**
|
|
588
602
|
* @deprecated The flush interval is server-controlled via the SDK reliability config
|
|
@@ -591,8 +605,6 @@ interface TrackerOptions {
|
|
|
591
605
|
* It will be removed in a future release.
|
|
592
606
|
*/
|
|
593
607
|
flushInterval?: number;
|
|
594
|
-
/** Generates new Observe session ids; returned values must be UUID-compatible. Existing stored sessions are still reused. */
|
|
595
|
-
sessionIdGenerator?: () => string;
|
|
596
608
|
}
|
|
597
609
|
declare class CorbadoTracker {
|
|
598
610
|
private options;
|
|
@@ -609,6 +621,8 @@ declare class CorbadoTracker {
|
|
|
609
621
|
private deviceInfoDebounceTime;
|
|
610
622
|
private deviceInfoTransmittedLastTime;
|
|
611
623
|
private seq;
|
|
624
|
+
/** Persistent experiment assignments (experiment key → variant), attached to every produced event. */
|
|
625
|
+
private experiments;
|
|
612
626
|
constructor(options: TrackerOptions);
|
|
613
627
|
/**
|
|
614
628
|
* Cache fresh server config as last-known. Boot-snapshot model: the config is NOT applied to this
|
|
@@ -621,8 +635,41 @@ declare class CorbadoTracker {
|
|
|
621
635
|
*/
|
|
622
636
|
getLogger(): Logger;
|
|
623
637
|
private applicationTag;
|
|
638
|
+
/**
|
|
639
|
+
* Register the user's variant for an experiment (e.g. `setExperiment("button_color", "blue")`).
|
|
640
|
+
*
|
|
641
|
+
* @remarks
|
|
642
|
+
* Corbado Observe does not assign variants — your app decides, and this records the assignment so
|
|
643
|
+
* Observe can attribute flows to it. The assignment persists (localStorage) across reloads and
|
|
644
|
+
* `resetSession`, and is attached to every event the tracker produces until you change or clear it.
|
|
645
|
+
* Multiple experiments can be active at once. Set it close to where the variant actually affects the
|
|
646
|
+
* user (or use the per-call `experiments` argument on a tracking method) to avoid over-attributing
|
|
647
|
+
* exposure; call {@link clearExperiment} when it no longer applies (e.g. on logout).
|
|
648
|
+
*
|
|
649
|
+
* Never throws: invalid input is ignored with a debug log.
|
|
650
|
+
*/
|
|
651
|
+
setExperiment(key: string, variant: string): void;
|
|
652
|
+
/**
|
|
653
|
+
* Register several experiment assignments at once (experiment key → variant). Additive: existing
|
|
654
|
+
* assignments for other keys are kept. See {@link setExperiment}.
|
|
655
|
+
*/
|
|
656
|
+
setExperiments(assignments: Record<string, string>): void;
|
|
657
|
+
/** Remove a single experiment assignment. */
|
|
658
|
+
clearExperiment(key: string): void;
|
|
659
|
+
/** Remove all experiment assignments. */
|
|
660
|
+
clearExperiments(): void;
|
|
661
|
+
/** Returns a copy of the currently active experiment assignments. */
|
|
662
|
+
getExperiments(): Record<string, string>;
|
|
663
|
+
private static isValidExperimentKey;
|
|
664
|
+
private static isValidExperimentVariant;
|
|
665
|
+
private loadPersistedExperiments;
|
|
666
|
+
private persistExperiments;
|
|
667
|
+
/**
|
|
668
|
+
* Resolves the experiments to attach to one event: the persistent assignments with any per-call
|
|
669
|
+
* override merged on top. Returns undefined when there are none (so the field is omitted).
|
|
670
|
+
*/
|
|
671
|
+
private resolveExperiments;
|
|
624
672
|
private isTrackingBlocked;
|
|
625
|
-
private createSessionId;
|
|
626
673
|
private getSessionId;
|
|
627
674
|
/**
|
|
628
675
|
* Resolve the session id from localStorage so it survives reloads and is shared across tabs of the
|
|
@@ -657,7 +704,7 @@ declare class CorbadoTracker {
|
|
|
657
704
|
*
|
|
658
705
|
* @internal
|
|
659
706
|
*/
|
|
660
|
-
track(name: AuthEventName, data: Record<string, any>, userReference?: UserReference, tags?: Record<string, string>, contexts?: Record<string, any>, explicitTimestamp?: number): Promise<void>;
|
|
707
|
+
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>;
|
|
661
708
|
/**
|
|
662
709
|
* Track when an authentication flow (or flow selection screen) becomes visible.
|
|
663
710
|
*
|
|
@@ -678,7 +725,7 @@ declare class CorbadoTracker {
|
|
|
678
725
|
* });
|
|
679
726
|
* ```
|
|
680
727
|
*/
|
|
681
|
-
flowStarted(data: FlowStarted | MultiFlowStarted, tags?: Record<string, string>): void;
|
|
728
|
+
flowStarted(data: FlowStarted | MultiFlowStarted, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
682
729
|
/**
|
|
683
730
|
* Track when the user commits to a specific flow.
|
|
684
731
|
*
|
|
@@ -694,7 +741,7 @@ declare class CorbadoTracker {
|
|
|
694
741
|
* tracker.flowDecided({flowName: "signup"});
|
|
695
742
|
* ```
|
|
696
743
|
*/
|
|
697
|
-
flowDecided(data: FlowDecided, tags?: Record<string, string>): void;
|
|
744
|
+
flowDecided(data: FlowDecided, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
698
745
|
/**
|
|
699
746
|
* Track a business/marketing conversion that is not part of an authentication flow.
|
|
700
747
|
*
|
|
@@ -717,7 +764,7 @@ declare class CorbadoTracker {
|
|
|
717
764
|
* });
|
|
718
765
|
* ```
|
|
719
766
|
*/
|
|
720
|
-
conversion(data: Conversion, tags?: Record<string, string>): void;
|
|
767
|
+
conversion(data: Conversion, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
721
768
|
/**
|
|
722
769
|
* Track when a flow successfully completes.
|
|
723
770
|
*
|
|
@@ -738,7 +785,7 @@ declare class CorbadoTracker {
|
|
|
738
785
|
* });
|
|
739
786
|
* ```
|
|
740
787
|
*/
|
|
741
|
-
flowFinished(data: FlowFinished, tags?: Record<string, string>): void;
|
|
788
|
+
flowFinished(data: FlowFinished, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
742
789
|
/**
|
|
743
790
|
* Track when an in-progress flow is reset and restarted.
|
|
744
791
|
*
|
|
@@ -754,7 +801,7 @@ declare class CorbadoTracker {
|
|
|
754
801
|
* tracker.flowReset({flowName: "login"});
|
|
755
802
|
* ```
|
|
756
803
|
*/
|
|
757
|
-
flowReset(data: FlowReset | MultiFlowReset, tags?: Record<string, string>): void;
|
|
804
|
+
flowReset(data: FlowReset | MultiFlowReset, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
758
805
|
/**
|
|
759
806
|
* Track when a flow is considered finished because another flow finished it implicitly.
|
|
760
807
|
*
|
|
@@ -775,7 +822,7 @@ declare class CorbadoTracker {
|
|
|
775
822
|
* });
|
|
776
823
|
* ```
|
|
777
824
|
*/
|
|
778
|
-
flowAutoFinished(data: FlowAutoFinished, tags?: Record<string, string>): void;
|
|
825
|
+
flowAutoFinished(data: FlowAutoFinished, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
779
826
|
/**
|
|
780
827
|
* Track when you present authentication method choices to the user.
|
|
781
828
|
*
|
|
@@ -796,10 +843,10 @@ declare class CorbadoTracker {
|
|
|
796
843
|
* });
|
|
797
844
|
* ```
|
|
798
845
|
*/
|
|
799
|
-
authMethodsDecisionStarted(data: AuthMethodDecisionStarted, tags?: Record<string, string>): void;
|
|
800
|
-
authMethodsDecisionFinished(data: AuthMethodDecisionFinished, tags?: Record<string, string>): void;
|
|
801
|
-
authDecisionStarted(data: AuthDecisionStarted): void;
|
|
802
|
-
authDecisionFinished(data: AuthDecisionFinished): void;
|
|
846
|
+
authMethodsDecisionStarted(data: AuthMethodDecisionStarted, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
847
|
+
authMethodsDecisionFinished(data: AuthMethodDecisionFinished, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
848
|
+
authDecisionStarted(data: AuthDecisionStarted, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
849
|
+
authDecisionFinished(data: AuthDecisionFinished, tags?: Record<string, string>, experiments?: Record<string, string>): void;
|
|
803
850
|
/**
|
|
804
851
|
* Enqueue a "low" event (granular DOM/window/visualviewport/PWM signal) for the current session.
|
|
805
852
|
*
|
|
@@ -1225,6 +1272,11 @@ declare class EventStore {
|
|
|
1225
1272
|
declare function init(options: TrackerOptions): CorbadoTracker;
|
|
1226
1273
|
declare function getTracker(): CorbadoTracker | undefined;
|
|
1227
1274
|
declare function resetSession(): string | undefined;
|
|
1275
|
+
declare function setExperiment(key: string, variant: string): void;
|
|
1276
|
+
declare function setExperiments(assignments: Record<string, string>): void;
|
|
1277
|
+
declare function clearExperiment(key: string): void;
|
|
1278
|
+
declare function clearExperiments(): void;
|
|
1279
|
+
declare function getExperiments(): Record<string, string>;
|
|
1228
1280
|
declare function destroy(): Promise<void>;
|
|
1229
1281
|
|
|
1230
|
-
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 };
|
|
1282
|
+
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 };
|