@corbado/observe 0.5.1 → 0.5.2-next.42-dd9eb36

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
@@ -1011,9 +1020,10 @@ interface QueueOptions {
1011
1020
  flushInterval?: number;
1012
1021
  debug?: boolean;
1013
1022
  /**
1014
- * Reliability config snapshot for this page load; defaults to all-features-OFF. Boot-snapshot
1015
- * model: the queue never changes its behavior mid-load. A fresh config returned by the server is
1016
- * 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.
1017
1027
  */
1018
1028
  config?: SdkReliabilityConfig;
1019
1029
  /** Called when the server returns a fresh config, so the client can cache it for the next load. */
@@ -1062,9 +1072,14 @@ declare class RequestQueue {
1062
1072
  private readonly debug;
1063
1073
  private readonly requestConfig;
1064
1074
  private readonly onConfigReceived?;
1065
- 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;
1066
1081
  /** Event names that trigger an immediate flush at enqueue time (config.flushOnEventNames). */
1067
- private readonly priorityNames;
1082
+ private priorityNames;
1068
1083
  private store?;
1069
1084
  /**
1070
1085
  * Once the server has answered the config request with a 2xx (200 = fresh config cached for the
@@ -1106,11 +1121,20 @@ declare class RequestQueue {
1106
1121
  private takeLows;
1107
1122
  private shouldRequestConfig;
1108
1123
  /**
1109
- * Handle the server's answer to the config request. Boot-snapshot model: a fresh config is ONLY
1110
- * handed to `onConfigReceived` for caching — it is never applied to this load. The behavior the
1111
- * 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.
1112
1130
  */
1113
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;
1114
1138
  /** Returns true when the batch was acknowledged with a 2xx (safe to keep draining). */
1115
1139
  private handleSendResult;
1116
1140
  private isRetryable;
@@ -1188,9 +1212,10 @@ declare const CONFIG_BOUNDS: {
1188
1212
  declare const DEFAULT_SESSION_INACTIVITY_MS: number;
1189
1213
  /**
1190
1214
  * Default config: every delivery-reliability feature is OFF. The SDK behaves like a plain async
1191
- * fetch-keepalive flusher until the server returns config (which is then cached as last-known and
1192
- * applied on the NEXT page load — boot-snapshot model). The empty version means "nothing cached";
1193
- * 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.
1194
1219
  */
1195
1220
  declare const DEFAULT_RELIABILITY_CONFIG: SdkReliabilityConfig;
1196
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
@@ -1011,9 +1020,10 @@ interface QueueOptions {
1011
1020
  flushInterval?: number;
1012
1021
  debug?: boolean;
1013
1022
  /**
1014
- * Reliability config snapshot for this page load; defaults to all-features-OFF. Boot-snapshot
1015
- * model: the queue never changes its behavior mid-load. A fresh config returned by the server is
1016
- * 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.
1017
1027
  */
1018
1028
  config?: SdkReliabilityConfig;
1019
1029
  /** Called when the server returns a fresh config, so the client can cache it for the next load. */
@@ -1062,9 +1072,14 @@ declare class RequestQueue {
1062
1072
  private readonly debug;
1063
1073
  private readonly requestConfig;
1064
1074
  private readonly onConfigReceived?;
1065
- 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;
1066
1081
  /** Event names that trigger an immediate flush at enqueue time (config.flushOnEventNames). */
1067
- private readonly priorityNames;
1082
+ private priorityNames;
1068
1083
  private store?;
1069
1084
  /**
1070
1085
  * Once the server has answered the config request with a 2xx (200 = fresh config cached for the
@@ -1106,11 +1121,20 @@ declare class RequestQueue {
1106
1121
  private takeLows;
1107
1122
  private shouldRequestConfig;
1108
1123
  /**
1109
- * Handle the server's answer to the config request. Boot-snapshot model: a fresh config is ONLY
1110
- * handed to `onConfigReceived` for caching — it is never applied to this load. The behavior the
1111
- * 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.
1112
1130
  */
1113
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;
1114
1138
  /** Returns true when the batch was acknowledged with a 2xx (safe to keep draining). */
1115
1139
  private handleSendResult;
1116
1140
  private isRetryable;
@@ -1188,9 +1212,10 @@ declare const CONFIG_BOUNDS: {
1188
1212
  declare const DEFAULT_SESSION_INACTIVITY_MS: number;
1189
1213
  /**
1190
1214
  * Default config: every delivery-reliability feature is OFF. The SDK behaves like a plain async
1191
- * fetch-keepalive flusher until the server returns config (which is then cached as last-known and
1192
- * applied on the NEXT page load — boot-snapshot model). The empty version means "nothing cached";
1193
- * 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.
1194
1219
  */
1195
1220
  declare const DEFAULT_RELIABILITY_CONFIG: SdkReliabilityConfig;
1196
1221
  /**