@usero/sdk 1.1.11 → 1.1.12

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/react.d.cts CHANGED
@@ -12,6 +12,7 @@ interface PluginContext {
12
12
  logger: PluginLogger;
13
13
  resolveUser?: () => void;
14
14
  getSdkSessionId?: () => string;
15
+ reseatSdkSessionId?: (id: string) => void;
15
16
  getAnonymousId?: () => string;
16
17
  getUserId?: () => string | null;
17
18
  getReplayStartMs?: () => number | null;
package/dist/react.d.ts CHANGED
@@ -12,6 +12,7 @@ interface PluginContext {
12
12
  logger: PluginLogger;
13
13
  resolveUser?: () => void;
14
14
  getSdkSessionId?: () => string;
15
+ reseatSdkSessionId?: (id: string) => void;
15
16
  getAnonymousId?: () => string;
16
17
  getUserId?: () => string | null;
17
18
  getReplayStartMs?: () => number | null;
package/dist/react.js CHANGED
@@ -231,10 +231,13 @@ function rotateAnonymousId() {
231
231
  currentUserId = null;
232
232
  return id;
233
233
  }
234
+ function isValidSdkSessionId(id) {
235
+ return /^[a-z0-9-]{8,}$/i.test(id);
236
+ }
234
237
  function getOrMintSdkSessionId() {
235
238
  if (cachedSdkSessionId) return cachedSdkSessionId;
236
239
  const existing = safeReadSessionStorage(SDK_SESSION_STORAGE_KEY);
237
- if (existing && /^[a-z0-9-]{8,}$/i.test(existing)) {
240
+ if (existing && isValidSdkSessionId(existing)) {
238
241
  cachedSdkSessionId = existing;
239
242
  return existing;
240
243
  }
@@ -243,6 +246,12 @@ function getOrMintSdkSessionId() {
243
246
  cachedSdkSessionId = id;
244
247
  return id;
245
248
  }
249
+ function reseatSdkSessionId(id) {
250
+ if (!isValidSdkSessionId(id)) return;
251
+ if (cachedSdkSessionId === id) return;
252
+ cachedSdkSessionId = id;
253
+ safeWriteSessionStorage(SDK_SESSION_STORAGE_KEY, id);
254
+ }
246
255
  function getCurrentUserId() {
247
256
  return currentUserId;
248
257
  }
@@ -954,6 +963,7 @@ function initUseroFeedbackWidget(props) {
954
963
  // source of truth in identity.ts, so user-test and session-replay
955
964
  // agree on the per-tab sdkSessionId without importing each other.
956
965
  getSdkSessionId: () => getOrMintSdkSessionId(),
966
+ reseatSdkSessionId: (id) => reseatSdkSessionId(id),
957
967
  getAnonymousId: () => getOrMintAnonymousId(),
958
968
  getUserId: () => getCurrentUserId(),
959
969
  getReplayStartMs: () => getReplayStartMs(),