@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/plugins/session-replay.cjs +10 -3
- package/dist/plugins/session-replay.cjs.map +1 -1
- package/dist/plugins/session-replay.d.cts +1 -0
- package/dist/plugins/session-replay.d.ts +1 -0
- package/dist/plugins/session-replay.js +10 -3
- package/dist/plugins/session-replay.js.map +1 -1
- package/dist/plugins/user-test.cjs +536 -247
- package/dist/plugins/user-test.cjs.map +1 -1
- package/dist/plugins/user-test.d.cts +50 -2
- package/dist/plugins/user-test.d.ts +50 -2
- package/dist/plugins/user-test.js +536 -247
- package/dist/plugins/user-test.js.map +1 -1
- package/dist/react.cjs +11 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -0
- package/dist/react.d.ts +1 -0
- package/dist/react.js +11 -1
- package/dist/react.js.map +1 -1
- package/dist/usero.iife.js +20 -20
- package/dist/usero.iife.js.map +1 -1
- package/dist/vanilla.cjs +26 -1
- package/dist/vanilla.cjs.map +1 -1
- package/dist/vanilla.d.cts +41 -1
- package/dist/vanilla.d.ts +41 -1
- package/dist/vanilla.js +26 -2
- package/dist/vanilla.js.map +1 -1
- package/package.json +1 -1
package/dist/vanilla.d.cts
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the stable per-tab sdkSessionId. Core-owned so every plugin
|
|
3
|
+
* (replay, user-test, future feedback linkage) reads the SAME id for a
|
|
4
|
+
* given tab. Reads sessionStorage at most once per SDK instance; later
|
|
5
|
+
* calls hit the in-memory cache.
|
|
6
|
+
*
|
|
7
|
+
* Backward compat: reuses the `usero:sdk-session-id` key the replay
|
|
8
|
+
* plugin has always written, and the same loose sanity filter, so an
|
|
9
|
+
* id minted by an older replay-only SDK build is adopted as-is rather
|
|
10
|
+
* than rotated (which would split a tab's replay from its user-test).
|
|
11
|
+
*/
|
|
12
|
+
declare function getOrMintSdkSessionId(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Re-seat the per-tab sdkSessionId to a specific value. Used ONLY by the
|
|
15
|
+
* user-test resume path: a cross-origin hard navigation (e.g. an OAuth round
|
|
16
|
+
* trip) wipes sessionStorage, so the post-nav document would mint a NEW
|
|
17
|
+
* sdkSessionId and the post-nav SessionReplay row would no longer share an id
|
|
18
|
+
* with the audio session, breaking the (clientId, sdkSessionId) finalise join.
|
|
19
|
+
*
|
|
20
|
+
* The user-test plugin durably persists the original id in its localStorage
|
|
21
|
+
* resume state (which survives the round trip) and calls this synchronously at
|
|
22
|
+
* the very top of its onInit, BEFORE the session-replay plugin reads the id,
|
|
23
|
+
* so the resumed replay reuses the SAME id and the server stitches both replay
|
|
24
|
+
* rows under it.
|
|
25
|
+
*
|
|
26
|
+
* No-ops on a malformed id (so a corrupted resume entry can never poison the
|
|
27
|
+
* tab's id) and on an id identical to the current one. Writes sessionStorage
|
|
28
|
+
* AND the in-memory cache so a replay onInit that already cached a fresh mint
|
|
29
|
+
* is corrected (the cache is the read-through path).
|
|
30
|
+
*/
|
|
31
|
+
declare function reseatSdkSessionId(id: string): void;
|
|
32
|
+
|
|
1
33
|
interface PluginLogger {
|
|
2
34
|
debug: (...args: unknown[]) => void;
|
|
3
35
|
info: (...args: unknown[]) => void;
|
|
@@ -12,6 +44,7 @@ interface PluginContext {
|
|
|
12
44
|
logger: PluginLogger;
|
|
13
45
|
resolveUser?: () => void;
|
|
14
46
|
getSdkSessionId?: () => string;
|
|
47
|
+
reseatSdkSessionId?: (id: string) => void;
|
|
15
48
|
getAnonymousId?: () => string;
|
|
16
49
|
getUserId?: () => string | null;
|
|
17
50
|
getReplayStartMs?: () => number | null;
|
|
@@ -100,6 +133,13 @@ declare const DEFAULT_THEME: WidgetTheme;
|
|
|
100
133
|
declare const DARK_THEME: WidgetTheme;
|
|
101
134
|
declare function mergeTheme(customTheme?: Partial<WidgetTheme>): WidgetTheme;
|
|
102
135
|
|
|
136
|
+
declare const __identityTest__: {
|
|
137
|
+
ANON_STORAGE_KEY: string;
|
|
138
|
+
SDK_SESSION_STORAGE_KEY: string;
|
|
139
|
+
reseatSdkSessionId: typeof reseatSdkSessionId;
|
|
140
|
+
getOrMintSdkSessionId: typeof getOrMintSdkSessionId;
|
|
141
|
+
resetIdentityState: () => void;
|
|
142
|
+
};
|
|
103
143
|
declare function resolveTheme(userTheme: Partial<WidgetTheme> | undefined): WidgetTheme;
|
|
104
144
|
|
|
105
145
|
interface UseroWidgetHandle {
|
|
@@ -113,4 +153,4 @@ interface UseroWidgetHandle {
|
|
|
113
153
|
declare function mergePluginPatches(base: FeedbackSubmission, patches: ReadonlyArray<Partial<FeedbackSubmission> | undefined>): FeedbackSubmission;
|
|
114
154
|
declare function initUseroFeedbackWidget(props: FeedbackWidgetProps): UseroWidgetHandle;
|
|
115
155
|
|
|
116
|
-
export { DARK_THEME, DEFAULT_THEME, type FeedbackData, type FeedbackRating, type FeedbackSubmission, type FeedbackWidgetProps, type PluginContext, type PluginLogger, type ScreenshotData, type UseroPlugin, type UseroWidgetHandle, type WidgetPosition, type WidgetTheme, initUseroFeedbackWidget, mergePluginPatches, mergeTheme, resolveTheme };
|
|
156
|
+
export { DARK_THEME, DEFAULT_THEME, type FeedbackData, type FeedbackRating, type FeedbackSubmission, type FeedbackWidgetProps, type PluginContext, type PluginLogger, type ScreenshotData, type UseroPlugin, type UseroWidgetHandle, type WidgetPosition, type WidgetTheme, __identityTest__, initUseroFeedbackWidget, mergePluginPatches, mergeTheme, resolveTheme };
|
package/dist/vanilla.d.ts
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the stable per-tab sdkSessionId. Core-owned so every plugin
|
|
3
|
+
* (replay, user-test, future feedback linkage) reads the SAME id for a
|
|
4
|
+
* given tab. Reads sessionStorage at most once per SDK instance; later
|
|
5
|
+
* calls hit the in-memory cache.
|
|
6
|
+
*
|
|
7
|
+
* Backward compat: reuses the `usero:sdk-session-id` key the replay
|
|
8
|
+
* plugin has always written, and the same loose sanity filter, so an
|
|
9
|
+
* id minted by an older replay-only SDK build is adopted as-is rather
|
|
10
|
+
* than rotated (which would split a tab's replay from its user-test).
|
|
11
|
+
*/
|
|
12
|
+
declare function getOrMintSdkSessionId(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Re-seat the per-tab sdkSessionId to a specific value. Used ONLY by the
|
|
15
|
+
* user-test resume path: a cross-origin hard navigation (e.g. an OAuth round
|
|
16
|
+
* trip) wipes sessionStorage, so the post-nav document would mint a NEW
|
|
17
|
+
* sdkSessionId and the post-nav SessionReplay row would no longer share an id
|
|
18
|
+
* with the audio session, breaking the (clientId, sdkSessionId) finalise join.
|
|
19
|
+
*
|
|
20
|
+
* The user-test plugin durably persists the original id in its localStorage
|
|
21
|
+
* resume state (which survives the round trip) and calls this synchronously at
|
|
22
|
+
* the very top of its onInit, BEFORE the session-replay plugin reads the id,
|
|
23
|
+
* so the resumed replay reuses the SAME id and the server stitches both replay
|
|
24
|
+
* rows under it.
|
|
25
|
+
*
|
|
26
|
+
* No-ops on a malformed id (so a corrupted resume entry can never poison the
|
|
27
|
+
* tab's id) and on an id identical to the current one. Writes sessionStorage
|
|
28
|
+
* AND the in-memory cache so a replay onInit that already cached a fresh mint
|
|
29
|
+
* is corrected (the cache is the read-through path).
|
|
30
|
+
*/
|
|
31
|
+
declare function reseatSdkSessionId(id: string): void;
|
|
32
|
+
|
|
1
33
|
interface PluginLogger {
|
|
2
34
|
debug: (...args: unknown[]) => void;
|
|
3
35
|
info: (...args: unknown[]) => void;
|
|
@@ -12,6 +44,7 @@ interface PluginContext {
|
|
|
12
44
|
logger: PluginLogger;
|
|
13
45
|
resolveUser?: () => void;
|
|
14
46
|
getSdkSessionId?: () => string;
|
|
47
|
+
reseatSdkSessionId?: (id: string) => void;
|
|
15
48
|
getAnonymousId?: () => string;
|
|
16
49
|
getUserId?: () => string | null;
|
|
17
50
|
getReplayStartMs?: () => number | null;
|
|
@@ -100,6 +133,13 @@ declare const DEFAULT_THEME: WidgetTheme;
|
|
|
100
133
|
declare const DARK_THEME: WidgetTheme;
|
|
101
134
|
declare function mergeTheme(customTheme?: Partial<WidgetTheme>): WidgetTheme;
|
|
102
135
|
|
|
136
|
+
declare const __identityTest__: {
|
|
137
|
+
ANON_STORAGE_KEY: string;
|
|
138
|
+
SDK_SESSION_STORAGE_KEY: string;
|
|
139
|
+
reseatSdkSessionId: typeof reseatSdkSessionId;
|
|
140
|
+
getOrMintSdkSessionId: typeof getOrMintSdkSessionId;
|
|
141
|
+
resetIdentityState: () => void;
|
|
142
|
+
};
|
|
103
143
|
declare function resolveTheme(userTheme: Partial<WidgetTheme> | undefined): WidgetTheme;
|
|
104
144
|
|
|
105
145
|
interface UseroWidgetHandle {
|
|
@@ -113,4 +153,4 @@ interface UseroWidgetHandle {
|
|
|
113
153
|
declare function mergePluginPatches(base: FeedbackSubmission, patches: ReadonlyArray<Partial<FeedbackSubmission> | undefined>): FeedbackSubmission;
|
|
114
154
|
declare function initUseroFeedbackWidget(props: FeedbackWidgetProps): UseroWidgetHandle;
|
|
115
155
|
|
|
116
|
-
export { DARK_THEME, DEFAULT_THEME, type FeedbackData, type FeedbackRating, type FeedbackSubmission, type FeedbackWidgetProps, type PluginContext, type PluginLogger, type ScreenshotData, type UseroPlugin, type UseroWidgetHandle, type WidgetPosition, type WidgetTheme, initUseroFeedbackWidget, mergePluginPatches, mergeTheme, resolveTheme };
|
|
156
|
+
export { DARK_THEME, DEFAULT_THEME, type FeedbackData, type FeedbackRating, type FeedbackSubmission, type FeedbackWidgetProps, type PluginContext, type PluginLogger, type ScreenshotData, type UseroPlugin, type UseroWidgetHandle, type WidgetPosition, type WidgetTheme, __identityTest__, initUseroFeedbackWidget, mergePluginPatches, mergeTheme, resolveTheme };
|
package/dist/vanilla.js
CHANGED
|
@@ -227,10 +227,13 @@ function rotateAnonymousId() {
|
|
|
227
227
|
currentUserId = null;
|
|
228
228
|
return id;
|
|
229
229
|
}
|
|
230
|
+
function isValidSdkSessionId(id) {
|
|
231
|
+
return /^[a-z0-9-]{8,}$/i.test(id);
|
|
232
|
+
}
|
|
230
233
|
function getOrMintSdkSessionId() {
|
|
231
234
|
if (cachedSdkSessionId) return cachedSdkSessionId;
|
|
232
235
|
const existing = safeReadSessionStorage(SDK_SESSION_STORAGE_KEY);
|
|
233
|
-
if (existing &&
|
|
236
|
+
if (existing && isValidSdkSessionId(existing)) {
|
|
234
237
|
cachedSdkSessionId = existing;
|
|
235
238
|
return existing;
|
|
236
239
|
}
|
|
@@ -239,6 +242,12 @@ function getOrMintSdkSessionId() {
|
|
|
239
242
|
cachedSdkSessionId = id;
|
|
240
243
|
return id;
|
|
241
244
|
}
|
|
245
|
+
function reseatSdkSessionId(id) {
|
|
246
|
+
if (!isValidSdkSessionId(id)) return;
|
|
247
|
+
if (cachedSdkSessionId === id) return;
|
|
248
|
+
cachedSdkSessionId = id;
|
|
249
|
+
safeWriteSessionStorage(SDK_SESSION_STORAGE_KEY, id);
|
|
250
|
+
}
|
|
242
251
|
function getCurrentUserId() {
|
|
243
252
|
return currentUserId;
|
|
244
253
|
}
|
|
@@ -301,6 +310,19 @@ async function identifyIfChanged(transport, user) {
|
|
|
301
310
|
function handleLogout() {
|
|
302
311
|
rotateAnonymousId();
|
|
303
312
|
}
|
|
313
|
+
var __test__ = {
|
|
314
|
+
ANON_STORAGE_KEY,
|
|
315
|
+
SDK_SESSION_STORAGE_KEY,
|
|
316
|
+
reseatSdkSessionId,
|
|
317
|
+
getOrMintSdkSessionId,
|
|
318
|
+
resetIdentityState: () => {
|
|
319
|
+
cachedAnonymousId = null;
|
|
320
|
+
cachedSdkSessionId = null;
|
|
321
|
+
currentUserId = null;
|
|
322
|
+
replayStartMs = null;
|
|
323
|
+
lastIdentifyFingerprint = null;
|
|
324
|
+
}
|
|
325
|
+
};
|
|
304
326
|
|
|
305
327
|
// src/plugin.ts
|
|
306
328
|
function createPluginLogger(name) {
|
|
@@ -775,6 +797,7 @@ var FEEDBACK_CSS = `
|
|
|
775
797
|
`;
|
|
776
798
|
|
|
777
799
|
// src/vanilla.ts
|
|
800
|
+
var __identityTest__ = __test__;
|
|
778
801
|
function resolveBaseTheme() {
|
|
779
802
|
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
780
803
|
return DARK_THEME;
|
|
@@ -950,6 +973,7 @@ function initUseroFeedbackWidget(props) {
|
|
|
950
973
|
// source of truth in identity.ts, so user-test and session-replay
|
|
951
974
|
// agree on the per-tab sdkSessionId without importing each other.
|
|
952
975
|
getSdkSessionId: () => getOrMintSdkSessionId(),
|
|
976
|
+
reseatSdkSessionId: (id) => reseatSdkSessionId(id),
|
|
953
977
|
getAnonymousId: () => getOrMintAnonymousId(),
|
|
954
978
|
getUserId: () => getCurrentUserId(),
|
|
955
979
|
getReplayStartMs: () => getReplayStartMs(),
|
|
@@ -1478,6 +1502,6 @@ function initUseroFeedbackWidget(props) {
|
|
|
1478
1502
|
};
|
|
1479
1503
|
}
|
|
1480
1504
|
|
|
1481
|
-
export { DARK_THEME, DEFAULT_THEME, initUseroFeedbackWidget, mergePluginPatches, mergeTheme, resolveTheme };
|
|
1505
|
+
export { DARK_THEME, DEFAULT_THEME, __identityTest__, initUseroFeedbackWidget, mergePluginPatches, mergeTheme, resolveTheme };
|
|
1482
1506
|
//# sourceMappingURL=vanilla.js.map
|
|
1483
1507
|
//# sourceMappingURL=vanilla.js.map
|