@corbado/observe 0.5.0 → 0.5.2-next.41-054d51c

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
@@ -605,6 +605,8 @@ interface TrackerOptions {
605
605
  * It will be removed in a future release.
606
606
  */
607
607
  flushInterval?: number;
608
+ /** Generates new Observe session ids; returned values must be UUID-compatible. Existing stored sessions are still reused. */
609
+ sessionIdGenerator?: () => string;
608
610
  }
609
611
  declare class CorbadoTracker {
610
612
  private options;
@@ -615,8 +617,12 @@ declare class CorbadoTracker {
615
617
  private sessionStorage;
616
618
  /** Dedicated localStorage engine for reliability state (config cache, outbox, continuity session, seq). */
617
619
  private persistentStorage;
618
- /** Boot snapshot of the reliability config; immutable for the lifetime of this page load. */
619
- private readonly config;
620
+ /**
621
+ * Reliability config for this load. A boot with a cached server config is a snapshot (immutable
622
+ * mid-load); a boot on the built-in defaults upgrades once to the first server-returned config
623
+ * (see {@link handleConfig}).
624
+ */
625
+ private config;
620
626
  private deviceInfoCollector;
621
627
  private deviceInfoDebounceTime;
622
628
  private deviceInfoTransmittedLastTime;
@@ -625,9 +631,11 @@ declare class CorbadoTracker {
625
631
  private experiments;
626
632
  constructor(options: TrackerOptions);
627
633
  /**
628
- * Cache fresh server config as last-known. Boot-snapshot model: the config is NOT applied to this
629
- * load — `this.config` stays the construction-time snapshot — it takes effect on the next page
630
- * load via {@link loadCachedConfig}.
634
+ * Cache fresh server config as last-known so the next page load boots with it. When this load
635
+ * booted on the built-in defaults (no cached config), the config is additionally applied live:
636
+ * every field is read at use time, and a mid-load `sessionContinuity` flip is safe because
637
+ * `nextSeq` adopts the in-memory session id into the empty continuity store instead of minting
638
+ * (no session split). A load that booted on a cached config keeps its snapshot untouched.
631
639
  */
632
640
  private handleConfig;
633
641
  /**
@@ -670,6 +678,7 @@ declare class CorbadoTracker {
670
678
  */
671
679
  private resolveExperiments;
672
680
  private isTrackingBlocked;
681
+ private createSessionId;
673
682
  private getSessionId;
674
683
  /**
675
684
  * Resolve the session id from localStorage so it survives reloads and is shared across tabs of the
@@ -685,7 +694,9 @@ declare class CorbadoTracker {
685
694
  * seq order matches `track()` call order within a tab. Every tracked event also bumps the
686
695
  * continuity session's `lastActiveAt`, so the inactivity window measures real user inactivity
687
696
  * instead of time-since-page-load (a long-lived active tab must not rotate the session on the next
688
- * reload).
697
+ * reload). An empty store while this load already has a session id means persistence is failing
698
+ * (or was cleared); the in-memory id is reused then — never re-minted — so a broken store degrades
699
+ * to one session per page load instead of one session per event.
689
700
  */
690
701
  private nextSeq;
691
702
  private updateDeviceDebounced;
@@ -1009,9 +1020,10 @@ interface QueueOptions {
1009
1020
  flushInterval?: number;
1010
1021
  debug?: boolean;
1011
1022
  /**
1012
- * Reliability config snapshot for this page load; defaults to all-features-OFF. Boot-snapshot
1013
- * model: the queue never changes its behavior mid-load. A fresh config returned by the server is
1014
- * only handed to {@link QueueOptions.onConfigReceived} for caching and applies on the next load.
1023
+ * Reliability config for this page load; defaults to all-features-OFF. Boot-snapshot model: with
1024
+ * a cached config the queue never changes its behavior mid-load — a fresh config returned by the
1025
+ * server is only handed to {@link QueueOptions.onConfigReceived} for caching and applies on the
1026
+ * next load. Only a defaults boot (no cached config) applies the first server config live.
1015
1027
  */
1016
1028
  config?: SdkReliabilityConfig;
1017
1029
  /** Called when the server returns a fresh config, so the client can cache it for the next load. */
@@ -1060,9 +1072,14 @@ declare class RequestQueue {
1060
1072
  private readonly debug;
1061
1073
  private readonly requestConfig;
1062
1074
  private readonly onConfigReceived?;
1063
- private readonly config;
1075
+ /**
1076
+ * Reliability config for this load. A boot with a cached server config is a snapshot that never
1077
+ * changes mid-load; a boot on the built-in defaults upgrades once to the first server-returned
1078
+ * config (see {@link handleConfigResponse}).
1079
+ */
1080
+ private config;
1064
1081
  /** Event names that trigger an immediate flush at enqueue time (config.flushOnEventNames). */
1065
- private readonly priorityNames;
1082
+ private priorityNames;
1066
1083
  private store?;
1067
1084
  /**
1068
1085
  * Once the server has answered the config request with a 2xx (200 = fresh config cached for the
@@ -1104,11 +1121,20 @@ declare class RequestQueue {
1104
1121
  private takeLows;
1105
1122
  private shouldRequestConfig;
1106
1123
  /**
1107
- * Handle the server's answer to the config request. Boot-snapshot model: a fresh config is ONLY
1108
- * handed to `onConfigReceived` for caching — it is never applied to this load. The behavior the
1109
- * queue was constructed with stays in effect until the page unloads.
1124
+ * Handle the server's answer to the config request. With a cached boot config the boot-snapshot
1125
+ * model applies: a fresh config is ONLY handed to `onConfigReceived` for caching and takes effect
1126
+ * on the next load. A load that booted on the built-in defaults (nothing cached) has no prior
1127
+ * behavior to stay coherent with — there the first server config is additionally applied live,
1128
+ * so cold-storage visits (first visit, cleared storage) don't run their whole load without the
1129
+ * reliability features.
1110
1130
  */
1111
1131
  private handleConfigResponse;
1132
+ /**
1133
+ * Switch this load from the built-in defaults to the first server config (defaults boot only).
1134
+ * Most fields are read at use time, so replacing the reference is enough; only the derived state
1135
+ * (priority-name set, durable outbox store) needs rebuilding.
1136
+ */
1137
+ private applyConfigLive;
1112
1138
  /** Returns true when the batch was acknowledged with a 2xx (safe to keep draining). */
1113
1139
  private handleSendResult;
1114
1140
  private isRetryable;
@@ -1186,9 +1212,10 @@ declare const CONFIG_BOUNDS: {
1186
1212
  declare const DEFAULT_SESSION_INACTIVITY_MS: number;
1187
1213
  /**
1188
1214
  * Default config: every delivery-reliability feature is OFF. The SDK behaves like a plain async
1189
- * fetch-keepalive flusher until the server returns config (which is then cached as last-known and
1190
- * applied on the NEXT page load — boot-snapshot model). The empty version means "nothing cached";
1191
- * the config request header sends "1" in that case.
1215
+ * fetch-keepalive flusher until the server returns config, which is cached as last-known for the
1216
+ * next load AND applied live to the current load (a defaults boot has no prior config to stay
1217
+ * coherent with; loads booting on a cached config keep their snapshot — boot-snapshot model). The
1218
+ * empty version means "nothing cached"; the config request header sends "1" in that case.
1192
1219
  */
1193
1220
  declare const DEFAULT_RELIABILITY_CONFIG: SdkReliabilityConfig;
1194
1221
  /**
package/dist/index.d.ts CHANGED
@@ -605,6 +605,8 @@ interface TrackerOptions {
605
605
  * It will be removed in a future release.
606
606
  */
607
607
  flushInterval?: number;
608
+ /** Generates new Observe session ids; returned values must be UUID-compatible. Existing stored sessions are still reused. */
609
+ sessionIdGenerator?: () => string;
608
610
  }
609
611
  declare class CorbadoTracker {
610
612
  private options;
@@ -615,8 +617,12 @@ declare class CorbadoTracker {
615
617
  private sessionStorage;
616
618
  /** Dedicated localStorage engine for reliability state (config cache, outbox, continuity session, seq). */
617
619
  private persistentStorage;
618
- /** Boot snapshot of the reliability config; immutable for the lifetime of this page load. */
619
- private readonly config;
620
+ /**
621
+ * Reliability config for this load. A boot with a cached server config is a snapshot (immutable
622
+ * mid-load); a boot on the built-in defaults upgrades once to the first server-returned config
623
+ * (see {@link handleConfig}).
624
+ */
625
+ private config;
620
626
  private deviceInfoCollector;
621
627
  private deviceInfoDebounceTime;
622
628
  private deviceInfoTransmittedLastTime;
@@ -625,9 +631,11 @@ declare class CorbadoTracker {
625
631
  private experiments;
626
632
  constructor(options: TrackerOptions);
627
633
  /**
628
- * Cache fresh server config as last-known. Boot-snapshot model: the config is NOT applied to this
629
- * load — `this.config` stays the construction-time snapshot — it takes effect on the next page
630
- * load via {@link loadCachedConfig}.
634
+ * Cache fresh server config as last-known so the next page load boots with it. When this load
635
+ * booted on the built-in defaults (no cached config), the config is additionally applied live:
636
+ * every field is read at use time, and a mid-load `sessionContinuity` flip is safe because
637
+ * `nextSeq` adopts the in-memory session id into the empty continuity store instead of minting
638
+ * (no session split). A load that booted on a cached config keeps its snapshot untouched.
631
639
  */
632
640
  private handleConfig;
633
641
  /**
@@ -670,6 +678,7 @@ declare class CorbadoTracker {
670
678
  */
671
679
  private resolveExperiments;
672
680
  private isTrackingBlocked;
681
+ private createSessionId;
673
682
  private getSessionId;
674
683
  /**
675
684
  * Resolve the session id from localStorage so it survives reloads and is shared across tabs of the
@@ -685,7 +694,9 @@ declare class CorbadoTracker {
685
694
  * seq order matches `track()` call order within a tab. Every tracked event also bumps the
686
695
  * continuity session's `lastActiveAt`, so the inactivity window measures real user inactivity
687
696
  * instead of time-since-page-load (a long-lived active tab must not rotate the session on the next
688
- * reload).
697
+ * reload). An empty store while this load already has a session id means persistence is failing
698
+ * (or was cleared); the in-memory id is reused then — never re-minted — so a broken store degrades
699
+ * to one session per page load instead of one session per event.
689
700
  */
690
701
  private nextSeq;
691
702
  private updateDeviceDebounced;
@@ -1009,9 +1020,10 @@ interface QueueOptions {
1009
1020
  flushInterval?: number;
1010
1021
  debug?: boolean;
1011
1022
  /**
1012
- * Reliability config snapshot for this page load; defaults to all-features-OFF. Boot-snapshot
1013
- * model: the queue never changes its behavior mid-load. A fresh config returned by the server is
1014
- * only handed to {@link QueueOptions.onConfigReceived} for caching and applies on the next load.
1023
+ * Reliability config for this page load; defaults to all-features-OFF. Boot-snapshot model: with
1024
+ * a cached config the queue never changes its behavior mid-load — a fresh config returned by the
1025
+ * server is only handed to {@link QueueOptions.onConfigReceived} for caching and applies on the
1026
+ * next load. Only a defaults boot (no cached config) applies the first server config live.
1015
1027
  */
1016
1028
  config?: SdkReliabilityConfig;
1017
1029
  /** Called when the server returns a fresh config, so the client can cache it for the next load. */
@@ -1060,9 +1072,14 @@ declare class RequestQueue {
1060
1072
  private readonly debug;
1061
1073
  private readonly requestConfig;
1062
1074
  private readonly onConfigReceived?;
1063
- private readonly config;
1075
+ /**
1076
+ * Reliability config for this load. A boot with a cached server config is a snapshot that never
1077
+ * changes mid-load; a boot on the built-in defaults upgrades once to the first server-returned
1078
+ * config (see {@link handleConfigResponse}).
1079
+ */
1080
+ private config;
1064
1081
  /** Event names that trigger an immediate flush at enqueue time (config.flushOnEventNames). */
1065
- private readonly priorityNames;
1082
+ private priorityNames;
1066
1083
  private store?;
1067
1084
  /**
1068
1085
  * Once the server has answered the config request with a 2xx (200 = fresh config cached for the
@@ -1104,11 +1121,20 @@ declare class RequestQueue {
1104
1121
  private takeLows;
1105
1122
  private shouldRequestConfig;
1106
1123
  /**
1107
- * Handle the server's answer to the config request. Boot-snapshot model: a fresh config is ONLY
1108
- * handed to `onConfigReceived` for caching — it is never applied to this load. The behavior the
1109
- * queue was constructed with stays in effect until the page unloads.
1124
+ * Handle the server's answer to the config request. With a cached boot config the boot-snapshot
1125
+ * model applies: a fresh config is ONLY handed to `onConfigReceived` for caching and takes effect
1126
+ * on the next load. A load that booted on the built-in defaults (nothing cached) has no prior
1127
+ * behavior to stay coherent with — there the first server config is additionally applied live,
1128
+ * so cold-storage visits (first visit, cleared storage) don't run their whole load without the
1129
+ * reliability features.
1110
1130
  */
1111
1131
  private handleConfigResponse;
1132
+ /**
1133
+ * Switch this load from the built-in defaults to the first server config (defaults boot only).
1134
+ * Most fields are read at use time, so replacing the reference is enough; only the derived state
1135
+ * (priority-name set, durable outbox store) needs rebuilding.
1136
+ */
1137
+ private applyConfigLive;
1112
1138
  /** Returns true when the batch was acknowledged with a 2xx (safe to keep draining). */
1113
1139
  private handleSendResult;
1114
1140
  private isRetryable;
@@ -1186,9 +1212,10 @@ declare const CONFIG_BOUNDS: {
1186
1212
  declare const DEFAULT_SESSION_INACTIVITY_MS: number;
1187
1213
  /**
1188
1214
  * Default config: every delivery-reliability feature is OFF. The SDK behaves like a plain async
1189
- * fetch-keepalive flusher until the server returns config (which is then cached as last-known and
1190
- * applied on the NEXT page load — boot-snapshot model). The empty version means "nothing cached";
1191
- * the config request header sends "1" in that case.
1215
+ * fetch-keepalive flusher until the server returns config, which is cached as last-known for the
1216
+ * next load AND applied live to the current load (a defaults boot has no prior config to stay
1217
+ * coherent with; loads booting on a cached config keep their snapshot — boot-snapshot model). The
1218
+ * empty version means "nothing cached"; the config request header sends "1" in that case.
1192
1219
  */
1193
1220
  declare const DEFAULT_RELIABILITY_CONFIG: SdkReliabilityConfig;
1194
1221
  /**