@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.cjs CHANGED
@@ -233,10 +233,13 @@ function rotateAnonymousId() {
233
233
  currentUserId = null;
234
234
  return id;
235
235
  }
236
+ function isValidSdkSessionId(id) {
237
+ return /^[a-z0-9-]{8,}$/i.test(id);
238
+ }
236
239
  function getOrMintSdkSessionId() {
237
240
  if (cachedSdkSessionId) return cachedSdkSessionId;
238
241
  const existing = safeReadSessionStorage(SDK_SESSION_STORAGE_KEY);
239
- if (existing && /^[a-z0-9-]{8,}$/i.test(existing)) {
242
+ if (existing && isValidSdkSessionId(existing)) {
240
243
  cachedSdkSessionId = existing;
241
244
  return existing;
242
245
  }
@@ -245,6 +248,12 @@ function getOrMintSdkSessionId() {
245
248
  cachedSdkSessionId = id;
246
249
  return id;
247
250
  }
251
+ function reseatSdkSessionId(id) {
252
+ if (!isValidSdkSessionId(id)) return;
253
+ if (cachedSdkSessionId === id) return;
254
+ cachedSdkSessionId = id;
255
+ safeWriteSessionStorage(SDK_SESSION_STORAGE_KEY, id);
256
+ }
248
257
  function getCurrentUserId() {
249
258
  return currentUserId;
250
259
  }
@@ -956,6 +965,7 @@ function initUseroFeedbackWidget(props) {
956
965
  // source of truth in identity.ts, so user-test and session-replay
957
966
  // agree on the per-tab sdkSessionId without importing each other.
958
967
  getSdkSessionId: () => getOrMintSdkSessionId(),
968
+ reseatSdkSessionId: (id) => reseatSdkSessionId(id),
959
969
  getAnonymousId: () => getOrMintAnonymousId(),
960
970
  getUserId: () => getCurrentUserId(),
961
971
  getReplayStartMs: () => getReplayStartMs(),