@corbado/observe 0.5.0 → 0.5.2

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
@@ -615,8 +615,12 @@ declare class CorbadoTracker {
615
615
  private sessionStorage;
616
616
  /** Dedicated localStorage engine for reliability state (config cache, outbox, continuity session, seq). */
617
617
  private persistentStorage;
618
- /** Boot snapshot of the reliability config; immutable for the lifetime of this page load. */
619
- private readonly config;
618
+ /**
619
+ * Reliability config for this load. A boot with a cached server config is a snapshot (immutable
620
+ * mid-load); a boot on the built-in defaults upgrades once to the first server-returned config
621
+ * (see {@link handleConfig}).
622
+ */
623
+ private config;
620
624
  private deviceInfoCollector;
621
625
  private deviceInfoDebounceTime;
622
626
  private deviceInfoTransmittedLastTime;
@@ -625,9 +629,11 @@ declare class CorbadoTracker {
625
629
  private experiments;
626
630
  constructor(options: TrackerOptions);
627
631
  /**
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}.
632
+ * Cache fresh server config as last-known so the next page load boots with it. When this load
633
+ * booted on the built-in defaults (no cached config), the config is additionally applied live:
634
+ * every field is read at use time, and a mid-load `sessionContinuity` flip is safe because
635
+ * `nextSeq` adopts the in-memory session id into the empty continuity store instead of minting
636
+ * (no session split). A load that booted on a cached config keeps its snapshot untouched.
631
637
  */
632
638
  private handleConfig;
633
639
  /**
@@ -685,7 +691,9 @@ declare class CorbadoTracker {
685
691
  * seq order matches `track()` call order within a tab. Every tracked event also bumps the
686
692
  * continuity session's `lastActiveAt`, so the inactivity window measures real user inactivity
687
693
  * instead of time-since-page-load (a long-lived active tab must not rotate the session on the next
688
- * reload).
694
+ * reload). An empty store while this load already has a session id means persistence is failing
695
+ * (or was cleared); the in-memory id is reused then — never re-minted — so a broken store degrades
696
+ * to one session per page load instead of one session per event.
689
697
  */
690
698
  private nextSeq;
691
699
  private updateDeviceDebounced;
@@ -1009,9 +1017,10 @@ interface QueueOptions {
1009
1017
  flushInterval?: number;
1010
1018
  debug?: boolean;
1011
1019
  /**
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.
1020
+ * Reliability config for this page load; defaults to all-features-OFF. Boot-snapshot model: with
1021
+ * a cached config the queue never changes its behavior mid-load a fresh config returned by the
1022
+ * server is only handed to {@link QueueOptions.onConfigReceived} for caching and applies on the
1023
+ * next load. Only a defaults boot (no cached config) applies the first server config live.
1015
1024
  */
1016
1025
  config?: SdkReliabilityConfig;
1017
1026
  /** Called when the server returns a fresh config, so the client can cache it for the next load. */
@@ -1060,9 +1069,14 @@ declare class RequestQueue {
1060
1069
  private readonly debug;
1061
1070
  private readonly requestConfig;
1062
1071
  private readonly onConfigReceived?;
1063
- private readonly config;
1072
+ /**
1073
+ * Reliability config for this load. A boot with a cached server config is a snapshot that never
1074
+ * changes mid-load; a boot on the built-in defaults upgrades once to the first server-returned
1075
+ * config (see {@link handleConfigResponse}).
1076
+ */
1077
+ private config;
1064
1078
  /** Event names that trigger an immediate flush at enqueue time (config.flushOnEventNames). */
1065
- private readonly priorityNames;
1079
+ private priorityNames;
1066
1080
  private store?;
1067
1081
  /**
1068
1082
  * Once the server has answered the config request with a 2xx (200 = fresh config cached for the
@@ -1104,11 +1118,20 @@ declare class RequestQueue {
1104
1118
  private takeLows;
1105
1119
  private shouldRequestConfig;
1106
1120
  /**
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.
1121
+ * Handle the server's answer to the config request. With a cached boot config the boot-snapshot
1122
+ * model applies: a fresh config is ONLY handed to `onConfigReceived` for caching and takes effect
1123
+ * on the next load. A load that booted on the built-in defaults (nothing cached) has no prior
1124
+ * behavior to stay coherent with — there the first server config is additionally applied live,
1125
+ * so cold-storage visits (first visit, cleared storage) don't run their whole load without the
1126
+ * reliability features.
1110
1127
  */
1111
1128
  private handleConfigResponse;
1129
+ /**
1130
+ * Switch this load from the built-in defaults to the first server config (defaults boot only).
1131
+ * Most fields are read at use time, so replacing the reference is enough; only the derived state
1132
+ * (priority-name set, durable outbox store) needs rebuilding.
1133
+ */
1134
+ private applyConfigLive;
1112
1135
  /** Returns true when the batch was acknowledged with a 2xx (safe to keep draining). */
1113
1136
  private handleSendResult;
1114
1137
  private isRetryable;
@@ -1186,9 +1209,10 @@ declare const CONFIG_BOUNDS: {
1186
1209
  declare const DEFAULT_SESSION_INACTIVITY_MS: number;
1187
1210
  /**
1188
1211
  * 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.
1212
+ * fetch-keepalive flusher until the server returns config, which is cached as last-known for the
1213
+ * next load AND applied live to the current load (a defaults boot has no prior config to stay
1214
+ * coherent with; loads booting on a cached config keep their snapshot boot-snapshot model). The
1215
+ * empty version means "nothing cached"; the config request header sends "1" in that case.
1192
1216
  */
1193
1217
  declare const DEFAULT_RELIABILITY_CONFIG: SdkReliabilityConfig;
1194
1218
  /**
package/dist/index.d.ts CHANGED
@@ -615,8 +615,12 @@ declare class CorbadoTracker {
615
615
  private sessionStorage;
616
616
  /** Dedicated localStorage engine for reliability state (config cache, outbox, continuity session, seq). */
617
617
  private persistentStorage;
618
- /** Boot snapshot of the reliability config; immutable for the lifetime of this page load. */
619
- private readonly config;
618
+ /**
619
+ * Reliability config for this load. A boot with a cached server config is a snapshot (immutable
620
+ * mid-load); a boot on the built-in defaults upgrades once to the first server-returned config
621
+ * (see {@link handleConfig}).
622
+ */
623
+ private config;
620
624
  private deviceInfoCollector;
621
625
  private deviceInfoDebounceTime;
622
626
  private deviceInfoTransmittedLastTime;
@@ -625,9 +629,11 @@ declare class CorbadoTracker {
625
629
  private experiments;
626
630
  constructor(options: TrackerOptions);
627
631
  /**
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}.
632
+ * Cache fresh server config as last-known so the next page load boots with it. When this load
633
+ * booted on the built-in defaults (no cached config), the config is additionally applied live:
634
+ * every field is read at use time, and a mid-load `sessionContinuity` flip is safe because
635
+ * `nextSeq` adopts the in-memory session id into the empty continuity store instead of minting
636
+ * (no session split). A load that booted on a cached config keeps its snapshot untouched.
631
637
  */
632
638
  private handleConfig;
633
639
  /**
@@ -685,7 +691,9 @@ declare class CorbadoTracker {
685
691
  * seq order matches `track()` call order within a tab. Every tracked event also bumps the
686
692
  * continuity session's `lastActiveAt`, so the inactivity window measures real user inactivity
687
693
  * instead of time-since-page-load (a long-lived active tab must not rotate the session on the next
688
- * reload).
694
+ * reload). An empty store while this load already has a session id means persistence is failing
695
+ * (or was cleared); the in-memory id is reused then — never re-minted — so a broken store degrades
696
+ * to one session per page load instead of one session per event.
689
697
  */
690
698
  private nextSeq;
691
699
  private updateDeviceDebounced;
@@ -1009,9 +1017,10 @@ interface QueueOptions {
1009
1017
  flushInterval?: number;
1010
1018
  debug?: boolean;
1011
1019
  /**
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.
1020
+ * Reliability config for this page load; defaults to all-features-OFF. Boot-snapshot model: with
1021
+ * a cached config the queue never changes its behavior mid-load a fresh config returned by the
1022
+ * server is only handed to {@link QueueOptions.onConfigReceived} for caching and applies on the
1023
+ * next load. Only a defaults boot (no cached config) applies the first server config live.
1015
1024
  */
1016
1025
  config?: SdkReliabilityConfig;
1017
1026
  /** Called when the server returns a fresh config, so the client can cache it for the next load. */
@@ -1060,9 +1069,14 @@ declare class RequestQueue {
1060
1069
  private readonly debug;
1061
1070
  private readonly requestConfig;
1062
1071
  private readonly onConfigReceived?;
1063
- private readonly config;
1072
+ /**
1073
+ * Reliability config for this load. A boot with a cached server config is a snapshot that never
1074
+ * changes mid-load; a boot on the built-in defaults upgrades once to the first server-returned
1075
+ * config (see {@link handleConfigResponse}).
1076
+ */
1077
+ private config;
1064
1078
  /** Event names that trigger an immediate flush at enqueue time (config.flushOnEventNames). */
1065
- private readonly priorityNames;
1079
+ private priorityNames;
1066
1080
  private store?;
1067
1081
  /**
1068
1082
  * Once the server has answered the config request with a 2xx (200 = fresh config cached for the
@@ -1104,11 +1118,20 @@ declare class RequestQueue {
1104
1118
  private takeLows;
1105
1119
  private shouldRequestConfig;
1106
1120
  /**
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.
1121
+ * Handle the server's answer to the config request. With a cached boot config the boot-snapshot
1122
+ * model applies: a fresh config is ONLY handed to `onConfigReceived` for caching and takes effect
1123
+ * on the next load. A load that booted on the built-in defaults (nothing cached) has no prior
1124
+ * behavior to stay coherent with — there the first server config is additionally applied live,
1125
+ * so cold-storage visits (first visit, cleared storage) don't run their whole load without the
1126
+ * reliability features.
1110
1127
  */
1111
1128
  private handleConfigResponse;
1129
+ /**
1130
+ * Switch this load from the built-in defaults to the first server config (defaults boot only).
1131
+ * Most fields are read at use time, so replacing the reference is enough; only the derived state
1132
+ * (priority-name set, durable outbox store) needs rebuilding.
1133
+ */
1134
+ private applyConfigLive;
1112
1135
  /** Returns true when the batch was acknowledged with a 2xx (safe to keep draining). */
1113
1136
  private handleSendResult;
1114
1137
  private isRetryable;
@@ -1186,9 +1209,10 @@ declare const CONFIG_BOUNDS: {
1186
1209
  declare const DEFAULT_SESSION_INACTIVITY_MS: number;
1187
1210
  /**
1188
1211
  * 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.
1212
+ * fetch-keepalive flusher until the server returns config, which is cached as last-known for the
1213
+ * next load AND applied live to the current load (a defaults boot has no prior config to stay
1214
+ * coherent with; loads booting on a cached config keep their snapshot boot-snapshot model). The
1215
+ * empty version means "nothing cached"; the config request header sends "1" in that case.
1192
1216
  */
1193
1217
  declare const DEFAULT_RELIABILITY_CONFIG: SdkReliabilityConfig;
1194
1218
  /**