@amplifyup/sdk 0.1.40 → 0.1.41
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/AmplifyRenderer.d.mts +1 -1
- package/dist/AmplifyRenderer.d.ts +1 -1
- package/dist/AmplifyRenderer.js +44 -3
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +44 -3
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +21 -9
- package/dist/index.d.ts +21 -9
- package/dist/index.js +52 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -4
- package/dist/index.mjs.map +1 -1
- package/dist/middleware.d.mts +2 -1
- package/dist/middleware.d.ts +2 -1
- package/dist/middleware.js +19 -4
- package/dist/middleware.js.map +1 -1
- package/dist/middleware.mjs +19 -5
- package/dist/middleware.mjs.map +1 -1
- package/dist/{query-6BmINKLR.d.mts → query-BMsorj0k.d.ts} +3 -1
- package/dist/{query-DjIuJ71C.d.ts → query-CraXKhi7.d.mts} +3 -1
- package/dist/react.d.mts +3 -3
- package/dist/react.d.ts +3 -3
- package/dist/react.js +51 -3
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +51 -3
- package/dist/react.mjs.map +1 -1
- package/dist/server.d.mts +3 -3
- package/dist/server.d.ts +3 -3
- package/dist/server.js +4 -0
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +4 -0
- package/dist/server.mjs.map +1 -1
- package/dist/{types-CBoVIFI8.d.mts → types-DUP8Lb7R.d.mts} +3 -0
- package/dist/{types-CBoVIFI8.d.ts → types-DUP8Lb7R.d.ts} +3 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as EventTrackingConfig$1, a as CDPAdapter, b as AmplifyUpConfig, c as EventProperties, I as IdentifyInput, d as IdentifyTraits, e as ProfileFieldsInput, f as AmplifyUpTarget } from './types-
|
|
2
|
-
export { Z as ZoneConfig, i as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, g as resolveAmplifyUpUrls } from './types-
|
|
1
|
+
import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as EventTrackingConfig$1, a as CDPAdapter, b as AmplifyUpConfig, c as EventProperties, I as IdentifyInput, d as IdentifyTraits, e as ProfileFieldsInput, f as AmplifyUpTarget } from './types-DUP8Lb7R.mjs';
|
|
2
|
+
export { Z as ZoneConfig, i as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, g as resolveAmplifyUpUrls } from './types-DUP8Lb7R.mjs';
|
|
3
3
|
export { i as isComposerPreview, a as isPreviewRequest, b as isWorkingContentRequest } from './preview-_vHmzRen.mjs';
|
|
4
|
-
export { g as FetchEdgeQueryOptions, F as FetchEdgeSelectOptions, Q as QueryContentError, e as QueryContentOptions, k as QueryFilter, l as QueryFilterOp, i as QueryPagination, h as QueryResult, m as QuerySort, j as QuerySpec, S as SelectVariantsError, a as SelectVariantsOptions, b as SelectVariantsResult, c as fetchEdgeQuery, f as fetchEdgeSelect, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-
|
|
4
|
+
export { g as FetchEdgeQueryOptions, F as FetchEdgeSelectOptions, Q as QueryContentError, e as QueryContentOptions, k as QueryFilter, l as QueryFilterOp, i as QueryPagination, h as QueryResult, m as QuerySort, j as QuerySpec, S as SelectVariantsError, a as SelectVariantsOptions, b as SelectVariantsResult, c as fetchEdgeQuery, f as fetchEdgeSelect, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-CraXKhi7.mjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Storage utilities for instance ID and user ID
|
|
8
|
+
*/
|
|
9
|
+
/** First-party cookie so Next middleware can SSR/ISR personalized variants. */
|
|
10
|
+
declare const ANON_COOKIE_NAME = "amplifyup_anon_id";
|
|
11
|
+
/** First-party session cookie — same pattern as visitor id; 30-minute inactivity. */
|
|
12
|
+
declare const SESSION_COOKIE_NAME = "amplifyup_session_id";
|
|
13
|
+
/** Idle gap that starts a new session. Keep aligned with orchestrator SESSION_GAP_MS. */
|
|
14
|
+
declare const SESSION_IDLE_GAP_MS: number;
|
|
5
15
|
|
|
6
16
|
interface FetchContentResult {
|
|
7
17
|
pageConfig: PageConfig | null;
|
|
@@ -13,6 +23,7 @@ interface FetchContentOptions {
|
|
|
13
23
|
route: string;
|
|
14
24
|
trackingId: string;
|
|
15
25
|
anonId?: string | null;
|
|
26
|
+
sessionId?: string | null;
|
|
16
27
|
siteId?: string | null;
|
|
17
28
|
/** Force preview (Composer); otherwise uses isComposerPreview() in browser. */
|
|
18
29
|
preview?: boolean;
|
|
@@ -84,6 +95,7 @@ declare function fetchEdgeResolve(options: {
|
|
|
84
95
|
trackingId: string;
|
|
85
96
|
route: string;
|
|
86
97
|
anonId?: string | null;
|
|
98
|
+
sessionId?: string | null;
|
|
87
99
|
siteId?: string | null;
|
|
88
100
|
/** Deterministic variant combo — cacheable; do not send with anonId. */
|
|
89
101
|
variantKeys?: Record<string, string> | null;
|
|
@@ -117,11 +129,6 @@ declare function normalizeRoute(route: string): string;
|
|
|
117
129
|
* All runtime data (events, profiles, decisions) lives in AWS.
|
|
118
130
|
*/
|
|
119
131
|
|
|
120
|
-
/**
|
|
121
|
-
* Idle gap that starts a new logical visit when a tab is reactivated.
|
|
122
|
-
* Must stay aligned with SESSION_GAP_MS in apps/orchestrator/lib/aws-profiles.ts.
|
|
123
|
-
*/
|
|
124
|
-
declare const SESSION_IDLE_GAP_MS: number;
|
|
125
132
|
/**
|
|
126
133
|
* Time on Page: one event per page visit, sent when the visit ends
|
|
127
134
|
* (SPA navigation, tab close, or 30-minute idle resume). Switching tabs
|
|
@@ -290,6 +297,10 @@ declare class AmplifyUpSDK {
|
|
|
290
297
|
* Get instance ID (anonymous ID)
|
|
291
298
|
*/
|
|
292
299
|
getInstanceId(): string;
|
|
300
|
+
/**
|
|
301
|
+
* Get session id (30-minute inactivity reset).
|
|
302
|
+
*/
|
|
303
|
+
getSessionId(): string;
|
|
293
304
|
/**
|
|
294
305
|
* Get user ID
|
|
295
306
|
*/
|
|
@@ -487,6 +498,7 @@ declare const setProfileFields: (fields: ProfileFieldsInput) => void;
|
|
|
487
498
|
declare const trackContentEngagement: (contentId: string, engagementType: "view" | "click" | "dismiss") => void;
|
|
488
499
|
declare const reset: () => void;
|
|
489
500
|
declare const getInstanceId: () => string;
|
|
501
|
+
declare const getSessionId: () => string;
|
|
490
502
|
declare const getUserId: () => string | null;
|
|
491
503
|
declare const getTrackingId: () => string | undefined;
|
|
492
504
|
declare const getTarget: () => AmplifyUpTarget;
|
|
@@ -533,4 +545,4 @@ declare const verifyAWSConnection: () => {
|
|
|
533
545
|
|
|
534
546
|
declare const _default: AmplifyUpSDK;
|
|
535
547
|
|
|
536
|
-
export { AmplifyContentMeta, AmplifyUpConfig, AmplifyUpSDK, AmplifyUpTarget, CDPAdapter, ContentSource, DWELL_ACTIVITY_IDLE_MS, EdgeResolveError, EventProperties, EventTrackingConfig$1 as EventTrackingConfig, type FetchContentOptions, type FetchContentResult, IdentifyInput, IdentifyTraits, PageConfig, ProfileFieldsInput, SESSION_IDLE_GAP_MS, buildLayoutProviderUrl, buildPageRenderUrl, cleanupEventTracking, _default as default, fetchContent, fetchEdgeResolve, fetchPageConfig, getDiagnostics, getInstanceId, getOrchestratorUrl, getSDK, getStatus, getTarget, getTrackingId, getUserId, identify, init, mapResolvedToPageConfig, normalizeRoute, page, refreshEventTracking, reset, routeChange, setProfileFields, setupComponentViewTracking, setupEventTracking, testTracking, track, trackClick, trackContentEngagement, trackContentView, trackFormFieldInteraction, trackFormSubmit, verifyAWSConnection };
|
|
548
|
+
export { ANON_COOKIE_NAME, AmplifyContentMeta, AmplifyUpConfig, AmplifyUpSDK, AmplifyUpTarget, CDPAdapter, ContentSource, DWELL_ACTIVITY_IDLE_MS, EdgeResolveError, EventProperties, EventTrackingConfig$1 as EventTrackingConfig, type FetchContentOptions, type FetchContentResult, IdentifyInput, IdentifyTraits, PageConfig, ProfileFieldsInput, SESSION_COOKIE_NAME, SESSION_IDLE_GAP_MS, buildLayoutProviderUrl, buildPageRenderUrl, cleanupEventTracking, _default as default, fetchContent, fetchEdgeResolve, fetchPageConfig, getDiagnostics, getInstanceId, getOrchestratorUrl, getSDK, getSessionId, getStatus, getTarget, getTrackingId, getUserId, identify, init, mapResolvedToPageConfig, normalizeRoute, page, refreshEventTracking, reset, routeChange, setProfileFields, setupComponentViewTracking, setupEventTracking, testTracking, track, trackClick, trackContentEngagement, trackContentView, trackFormFieldInteraction, trackFormSubmit, verifyAWSConnection };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as EventTrackingConfig$1, a as CDPAdapter, b as AmplifyUpConfig, c as EventProperties, I as IdentifyInput, d as IdentifyTraits, e as ProfileFieldsInput, f as AmplifyUpTarget } from './types-
|
|
2
|
-
export { Z as ZoneConfig, i as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, g as resolveAmplifyUpUrls } from './types-
|
|
1
|
+
import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as EventTrackingConfig$1, a as CDPAdapter, b as AmplifyUpConfig, c as EventProperties, I as IdentifyInput, d as IdentifyTraits, e as ProfileFieldsInput, f as AmplifyUpTarget } from './types-DUP8Lb7R.js';
|
|
2
|
+
export { Z as ZoneConfig, i as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, g as resolveAmplifyUpUrls } from './types-DUP8Lb7R.js';
|
|
3
3
|
export { i as isComposerPreview, a as isPreviewRequest, b as isWorkingContentRequest } from './preview-_vHmzRen.js';
|
|
4
|
-
export { g as FetchEdgeQueryOptions, F as FetchEdgeSelectOptions, Q as QueryContentError, e as QueryContentOptions, k as QueryFilter, l as QueryFilterOp, i as QueryPagination, h as QueryResult, m as QuerySort, j as QuerySpec, S as SelectVariantsError, a as SelectVariantsOptions, b as SelectVariantsResult, c as fetchEdgeQuery, f as fetchEdgeSelect, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-
|
|
4
|
+
export { g as FetchEdgeQueryOptions, F as FetchEdgeSelectOptions, Q as QueryContentError, e as QueryContentOptions, k as QueryFilter, l as QueryFilterOp, i as QueryPagination, h as QueryResult, m as QuerySort, j as QuerySpec, S as SelectVariantsError, a as SelectVariantsOptions, b as SelectVariantsResult, c as fetchEdgeQuery, f as fetchEdgeSelect, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-BMsorj0k.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Storage utilities for instance ID and user ID
|
|
8
|
+
*/
|
|
9
|
+
/** First-party cookie so Next middleware can SSR/ISR personalized variants. */
|
|
10
|
+
declare const ANON_COOKIE_NAME = "amplifyup_anon_id";
|
|
11
|
+
/** First-party session cookie — same pattern as visitor id; 30-minute inactivity. */
|
|
12
|
+
declare const SESSION_COOKIE_NAME = "amplifyup_session_id";
|
|
13
|
+
/** Idle gap that starts a new session. Keep aligned with orchestrator SESSION_GAP_MS. */
|
|
14
|
+
declare const SESSION_IDLE_GAP_MS: number;
|
|
5
15
|
|
|
6
16
|
interface FetchContentResult {
|
|
7
17
|
pageConfig: PageConfig | null;
|
|
@@ -13,6 +23,7 @@ interface FetchContentOptions {
|
|
|
13
23
|
route: string;
|
|
14
24
|
trackingId: string;
|
|
15
25
|
anonId?: string | null;
|
|
26
|
+
sessionId?: string | null;
|
|
16
27
|
siteId?: string | null;
|
|
17
28
|
/** Force preview (Composer); otherwise uses isComposerPreview() in browser. */
|
|
18
29
|
preview?: boolean;
|
|
@@ -84,6 +95,7 @@ declare function fetchEdgeResolve(options: {
|
|
|
84
95
|
trackingId: string;
|
|
85
96
|
route: string;
|
|
86
97
|
anonId?: string | null;
|
|
98
|
+
sessionId?: string | null;
|
|
87
99
|
siteId?: string | null;
|
|
88
100
|
/** Deterministic variant combo — cacheable; do not send with anonId. */
|
|
89
101
|
variantKeys?: Record<string, string> | null;
|
|
@@ -117,11 +129,6 @@ declare function normalizeRoute(route: string): string;
|
|
|
117
129
|
* All runtime data (events, profiles, decisions) lives in AWS.
|
|
118
130
|
*/
|
|
119
131
|
|
|
120
|
-
/**
|
|
121
|
-
* Idle gap that starts a new logical visit when a tab is reactivated.
|
|
122
|
-
* Must stay aligned with SESSION_GAP_MS in apps/orchestrator/lib/aws-profiles.ts.
|
|
123
|
-
*/
|
|
124
|
-
declare const SESSION_IDLE_GAP_MS: number;
|
|
125
132
|
/**
|
|
126
133
|
* Time on Page: one event per page visit, sent when the visit ends
|
|
127
134
|
* (SPA navigation, tab close, or 30-minute idle resume). Switching tabs
|
|
@@ -290,6 +297,10 @@ declare class AmplifyUpSDK {
|
|
|
290
297
|
* Get instance ID (anonymous ID)
|
|
291
298
|
*/
|
|
292
299
|
getInstanceId(): string;
|
|
300
|
+
/**
|
|
301
|
+
* Get session id (30-minute inactivity reset).
|
|
302
|
+
*/
|
|
303
|
+
getSessionId(): string;
|
|
293
304
|
/**
|
|
294
305
|
* Get user ID
|
|
295
306
|
*/
|
|
@@ -487,6 +498,7 @@ declare const setProfileFields: (fields: ProfileFieldsInput) => void;
|
|
|
487
498
|
declare const trackContentEngagement: (contentId: string, engagementType: "view" | "click" | "dismiss") => void;
|
|
488
499
|
declare const reset: () => void;
|
|
489
500
|
declare const getInstanceId: () => string;
|
|
501
|
+
declare const getSessionId: () => string;
|
|
490
502
|
declare const getUserId: () => string | null;
|
|
491
503
|
declare const getTrackingId: () => string | undefined;
|
|
492
504
|
declare const getTarget: () => AmplifyUpTarget;
|
|
@@ -533,4 +545,4 @@ declare const verifyAWSConnection: () => {
|
|
|
533
545
|
|
|
534
546
|
declare const _default: AmplifyUpSDK;
|
|
535
547
|
|
|
536
|
-
export { AmplifyContentMeta, AmplifyUpConfig, AmplifyUpSDK, AmplifyUpTarget, CDPAdapter, ContentSource, DWELL_ACTIVITY_IDLE_MS, EdgeResolveError, EventProperties, EventTrackingConfig$1 as EventTrackingConfig, type FetchContentOptions, type FetchContentResult, IdentifyInput, IdentifyTraits, PageConfig, ProfileFieldsInput, SESSION_IDLE_GAP_MS, buildLayoutProviderUrl, buildPageRenderUrl, cleanupEventTracking, _default as default, fetchContent, fetchEdgeResolve, fetchPageConfig, getDiagnostics, getInstanceId, getOrchestratorUrl, getSDK, getStatus, getTarget, getTrackingId, getUserId, identify, init, mapResolvedToPageConfig, normalizeRoute, page, refreshEventTracking, reset, routeChange, setProfileFields, setupComponentViewTracking, setupEventTracking, testTracking, track, trackClick, trackContentEngagement, trackContentView, trackFormFieldInteraction, trackFormSubmit, verifyAWSConnection };
|
|
548
|
+
export { ANON_COOKIE_NAME, AmplifyContentMeta, AmplifyUpConfig, AmplifyUpSDK, AmplifyUpTarget, CDPAdapter, ContentSource, DWELL_ACTIVITY_IDLE_MS, EdgeResolveError, EventProperties, EventTrackingConfig$1 as EventTrackingConfig, type FetchContentOptions, type FetchContentResult, IdentifyInput, IdentifyTraits, PageConfig, ProfileFieldsInput, SESSION_COOKIE_NAME, SESSION_IDLE_GAP_MS, buildLayoutProviderUrl, buildPageRenderUrl, cleanupEventTracking, _default as default, fetchContent, fetchEdgeResolve, fetchPageConfig, getDiagnostics, getInstanceId, getOrchestratorUrl, getSDK, getSessionId, getStatus, getTarget, getTrackingId, getUserId, identify, init, mapResolvedToPageConfig, normalizeRoute, page, refreshEventTracking, reset, routeChange, setProfileFields, setupComponentViewTracking, setupEventTracking, testTracking, track, trackClick, trackContentEngagement, trackContentView, trackFormFieldInteraction, trackFormSubmit, verifyAWSConnection };
|
package/dist/index.js
CHANGED
|
@@ -95,6 +95,7 @@ var AWSAdapter = class {
|
|
|
95
95
|
const eventData = {
|
|
96
96
|
type: "page",
|
|
97
97
|
anonymousId: properties.instanceId,
|
|
98
|
+
sessionId: properties.sessionId,
|
|
98
99
|
userId: properties.userId,
|
|
99
100
|
properties: {
|
|
100
101
|
path: properties.path || properties.url,
|
|
@@ -137,6 +138,7 @@ var AWSAdapter = class {
|
|
|
137
138
|
type: "track",
|
|
138
139
|
event: eventName,
|
|
139
140
|
anonymousId: properties.instanceId,
|
|
141
|
+
sessionId: properties.sessionId,
|
|
140
142
|
userId: properties.userId,
|
|
141
143
|
properties: {
|
|
142
144
|
...properties
|
|
@@ -159,6 +161,7 @@ var AWSAdapter = class {
|
|
|
159
161
|
const eventData = {
|
|
160
162
|
type: "identify",
|
|
161
163
|
anonymousId: traits.instanceId,
|
|
164
|
+
sessionId: traits.sessionId,
|
|
162
165
|
traits: {
|
|
163
166
|
...traits,
|
|
164
167
|
...identifiers ? { identifiers } : {}
|
|
@@ -177,6 +180,7 @@ var AWSAdapter = class {
|
|
|
177
180
|
const eventData = {
|
|
178
181
|
type: "set_fields",
|
|
179
182
|
anonymousId: context.instanceId,
|
|
183
|
+
sessionId: context.sessionId,
|
|
180
184
|
fields,
|
|
181
185
|
traits: {
|
|
182
186
|
instanceId: context.instanceId,
|
|
@@ -199,7 +203,11 @@ var AWSAdapter = class {
|
|
|
199
203
|
// src/storage.ts
|
|
200
204
|
var INSTANCE_ID_KEY = "amplifyup_instance_id";
|
|
201
205
|
var USER_ID_KEY = "amplifyup_user_id";
|
|
206
|
+
var SESSION_ID_KEY = "amplifyup_session_id";
|
|
207
|
+
var SESSION_ACTIVITY_KEY = "amplifyup_session_activity";
|
|
202
208
|
var ANON_COOKIE_NAME = "amplifyup_anon_id";
|
|
209
|
+
var SESSION_COOKIE_NAME = "amplifyup_session_id";
|
|
210
|
+
var SESSION_IDLE_GAP_MS = 30 * 60 * 1e3;
|
|
203
211
|
function generateGuid() {
|
|
204
212
|
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
205
213
|
return crypto.randomUUID();
|
|
@@ -226,9 +234,9 @@ function readCookie(name) {
|
|
|
226
234
|
}
|
|
227
235
|
return null;
|
|
228
236
|
}
|
|
229
|
-
function writeCookie(name, value) {
|
|
237
|
+
function writeCookie(name, value, maxAgeSeconds = 31536e3) {
|
|
230
238
|
if (typeof document === "undefined") return;
|
|
231
|
-
document.cookie = `${name}=${encodeURIComponent(value)}; Path=/; Max-Age
|
|
239
|
+
document.cookie = `${name}=${encodeURIComponent(value)}; Path=/; Max-Age=${maxAgeSeconds}; SameSite=Lax`;
|
|
232
240
|
}
|
|
233
241
|
function getInstanceId() {
|
|
234
242
|
if (typeof window === "undefined") {
|
|
@@ -251,6 +259,23 @@ function getUserId() {
|
|
|
251
259
|
}
|
|
252
260
|
return localStorage.getItem(USER_ID_KEY);
|
|
253
261
|
}
|
|
262
|
+
function getSessionId() {
|
|
263
|
+
if (typeof window === "undefined") {
|
|
264
|
+
return "";
|
|
265
|
+
}
|
|
266
|
+
const now = Date.now();
|
|
267
|
+
const lastActivity = Number(localStorage.getItem(SESSION_ACTIVITY_KEY) || 0);
|
|
268
|
+
const fromCookie = readCookie(SESSION_COOKIE_NAME);
|
|
269
|
+
const fromLs = localStorage.getItem(SESSION_ID_KEY);
|
|
270
|
+
let sessionId = fromLs || fromCookie || "";
|
|
271
|
+
if (!sessionId || lastActivity > 0 && now - lastActivity >= SESSION_IDLE_GAP_MS) {
|
|
272
|
+
sessionId = generateGuid();
|
|
273
|
+
}
|
|
274
|
+
localStorage.setItem(SESSION_ID_KEY, sessionId);
|
|
275
|
+
localStorage.setItem(SESSION_ACTIVITY_KEY, String(now));
|
|
276
|
+
writeCookie(SESSION_COOKIE_NAME, sessionId, Math.floor(SESSION_IDLE_GAP_MS / 1e3));
|
|
277
|
+
return sessionId;
|
|
278
|
+
}
|
|
254
279
|
function setUserId(userId) {
|
|
255
280
|
if (typeof window === "undefined") {
|
|
256
281
|
return;
|
|
@@ -263,7 +288,10 @@ function clearIds() {
|
|
|
263
288
|
}
|
|
264
289
|
localStorage.removeItem(INSTANCE_ID_KEY);
|
|
265
290
|
localStorage.removeItem(USER_ID_KEY);
|
|
291
|
+
localStorage.removeItem(SESSION_ID_KEY);
|
|
292
|
+
localStorage.removeItem(SESSION_ACTIVITY_KEY);
|
|
266
293
|
document.cookie = `${ANON_COOKIE_NAME}=; Path=/; Max-Age=0; SameSite=Lax`;
|
|
294
|
+
document.cookie = `${SESSION_COOKIE_NAME}=; Path=/; Max-Age=0; SameSite=Lax`;
|
|
267
295
|
}
|
|
268
296
|
|
|
269
297
|
// src/targets.ts
|
|
@@ -426,6 +454,7 @@ async function fetchEdgeResolve(options) {
|
|
|
426
454
|
params.set("variants", variantParam);
|
|
427
455
|
} else if (options.anonId) {
|
|
428
456
|
params.set("anonId", options.anonId);
|
|
457
|
+
if (options.sessionId) params.set("sessionId", options.sessionId);
|
|
429
458
|
}
|
|
430
459
|
const fetchFn = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
431
460
|
const init2 = {
|
|
@@ -527,6 +556,7 @@ async function fetchContent(options) {
|
|
|
527
556
|
trackingId: options.trackingId,
|
|
528
557
|
route: options.route,
|
|
529
558
|
anonId: options.variantKeys ? void 0 : options.anonId,
|
|
559
|
+
sessionId: options.variantKeys ? void 0 : options.sessionId,
|
|
530
560
|
siteId: options.siteId,
|
|
531
561
|
fetch: options.fetchFn,
|
|
532
562
|
revalidate: options.revalidate,
|
|
@@ -596,6 +626,7 @@ async function fetchEdgeSelect(options) {
|
|
|
596
626
|
...options.trackingId ? { trackingId: options.trackingId } : {},
|
|
597
627
|
...options.site ? { site: options.site } : {},
|
|
598
628
|
anonId: options.anonId,
|
|
629
|
+
...options.sessionId ? { sessionId: options.sessionId } : {},
|
|
599
630
|
...options.zones?.length ? { zones: options.zones } : {},
|
|
600
631
|
...options.context ? { context: options.context } : {}
|
|
601
632
|
})
|
|
@@ -624,6 +655,7 @@ async function selectVariants(options) {
|
|
|
624
655
|
site: options.site,
|
|
625
656
|
view: options.view,
|
|
626
657
|
anonId: options.anonId,
|
|
658
|
+
sessionId: options.sessionId,
|
|
627
659
|
zones: options.zones,
|
|
628
660
|
context: options.context,
|
|
629
661
|
fetch: options.fetch,
|
|
@@ -708,7 +740,6 @@ function searchSpec(pagination, field, term) {
|
|
|
708
740
|
}
|
|
709
741
|
|
|
710
742
|
// src/index.ts
|
|
711
|
-
var SESSION_IDLE_GAP_MS = 30 * 60 * 1e3;
|
|
712
743
|
var DWELL_ACTIVITY_IDLE_MS = 2 * 60 * 1e3;
|
|
713
744
|
var DWELL_POLL_MS = 5e3;
|
|
714
745
|
function readPreviewQueryOverrides() {
|
|
@@ -884,6 +915,7 @@ var AmplifyUpSDK = class {
|
|
|
884
915
|
if (typeof window === "undefined") return;
|
|
885
916
|
window.AmplifyUp = {
|
|
886
917
|
getInstanceId: () => this.getInstanceId(),
|
|
918
|
+
getSessionId: () => this.getSessionId(),
|
|
887
919
|
getUserId: () => this.getUserId(),
|
|
888
920
|
getTrackingId: () => this.getTrackingId(),
|
|
889
921
|
getTarget: () => this.getTarget(),
|
|
@@ -1306,12 +1338,14 @@ var AmplifyUpSDK = class {
|
|
|
1306
1338
|
return;
|
|
1307
1339
|
}
|
|
1308
1340
|
const instanceId = getInstanceId();
|
|
1341
|
+
const sessionId = getSessionId();
|
|
1309
1342
|
const pageProperties = {
|
|
1310
1343
|
name: url,
|
|
1311
1344
|
path: url,
|
|
1312
1345
|
url: typeof window !== "undefined" ? window.location.href : url,
|
|
1313
1346
|
referrer: typeof document !== "undefined" ? document.referrer : void 0,
|
|
1314
1347
|
instanceId,
|
|
1348
|
+
sessionId,
|
|
1315
1349
|
trackingId: this.config?.trackingId,
|
|
1316
1350
|
// Timestamp is included in event payload
|
|
1317
1351
|
...properties
|
|
@@ -1330,8 +1364,10 @@ var AmplifyUpSDK = class {
|
|
|
1330
1364
|
return;
|
|
1331
1365
|
}
|
|
1332
1366
|
const instanceId = getInstanceId();
|
|
1367
|
+
const sessionId = getSessionId();
|
|
1333
1368
|
const trackProperties = {
|
|
1334
1369
|
instanceId,
|
|
1370
|
+
sessionId,
|
|
1335
1371
|
trackingId: this.config?.trackingId,
|
|
1336
1372
|
url: typeof window !== "undefined" ? window.location.href : void 0,
|
|
1337
1373
|
path: properties?.path || (typeof window !== "undefined" ? window.location.pathname : void 0),
|
|
@@ -1404,8 +1440,10 @@ var AmplifyUpSDK = class {
|
|
|
1404
1440
|
return;
|
|
1405
1441
|
}
|
|
1406
1442
|
const instanceId = getInstanceId();
|
|
1443
|
+
const sessionId = getSessionId();
|
|
1407
1444
|
const identifyTraits = {
|
|
1408
1445
|
instanceId,
|
|
1446
|
+
sessionId,
|
|
1409
1447
|
trackingId: this.config?.trackingId,
|
|
1410
1448
|
...traits
|
|
1411
1449
|
};
|
|
@@ -1443,6 +1481,7 @@ var AmplifyUpSDK = class {
|
|
|
1443
1481
|
if (typeof this.adapter.setProfileFields === "function") {
|
|
1444
1482
|
this.adapter.setProfileFields(fields, {
|
|
1445
1483
|
instanceId: instanceId || void 0,
|
|
1484
|
+
sessionId: getSessionId() || void 0,
|
|
1446
1485
|
trackingId: this.config?.trackingId
|
|
1447
1486
|
});
|
|
1448
1487
|
}
|
|
@@ -1493,6 +1532,12 @@ var AmplifyUpSDK = class {
|
|
|
1493
1532
|
getInstanceId() {
|
|
1494
1533
|
return getInstanceId();
|
|
1495
1534
|
}
|
|
1535
|
+
/**
|
|
1536
|
+
* Get session id (30-minute inactivity reset).
|
|
1537
|
+
*/
|
|
1538
|
+
getSessionId() {
|
|
1539
|
+
return getSessionId();
|
|
1540
|
+
}
|
|
1496
1541
|
/**
|
|
1497
1542
|
* Get user ID
|
|
1498
1543
|
*/
|
|
@@ -3014,6 +3059,7 @@ var setProfileFields = (fields) => getSDK().setProfileFields(fields);
|
|
|
3014
3059
|
var trackContentEngagement = (contentId, engagementType) => getSDK().trackContentEngagement(contentId, engagementType);
|
|
3015
3060
|
var reset = () => getSDK().reset();
|
|
3016
3061
|
var getInstanceId2 = () => getSDK().getInstanceId();
|
|
3062
|
+
var getSessionId2 = () => getSDK().getSessionId();
|
|
3017
3063
|
var getUserId2 = () => getSDK().getUserId();
|
|
3018
3064
|
var getTrackingId = () => getSDK().getTrackingId();
|
|
3019
3065
|
var getTarget = () => getSDK().getTarget();
|
|
@@ -3040,10 +3086,12 @@ var verifyAWSConnection = () => {
|
|
|
3040
3086
|
};
|
|
3041
3087
|
var index_default = getSDK();
|
|
3042
3088
|
|
|
3089
|
+
exports.ANON_COOKIE_NAME = ANON_COOKIE_NAME;
|
|
3043
3090
|
exports.AmplifyUpSDK = AmplifyUpSDK;
|
|
3044
3091
|
exports.DWELL_ACTIVITY_IDLE_MS = DWELL_ACTIVITY_IDLE_MS;
|
|
3045
3092
|
exports.EdgeResolveError = EdgeResolveError;
|
|
3046
3093
|
exports.QueryContentError = QueryContentError;
|
|
3094
|
+
exports.SESSION_COOKIE_NAME = SESSION_COOKIE_NAME;
|
|
3047
3095
|
exports.SESSION_IDLE_GAP_MS = SESSION_IDLE_GAP_MS;
|
|
3048
3096
|
exports.SelectVariantsError = SelectVariantsError;
|
|
3049
3097
|
exports.buildLayoutProviderUrl = buildLayoutProviderUrl;
|
|
@@ -3059,6 +3107,7 @@ exports.getDiagnostics = getDiagnostics;
|
|
|
3059
3107
|
exports.getInstanceId = getInstanceId2;
|
|
3060
3108
|
exports.getOrchestratorUrl = getOrchestratorUrl;
|
|
3061
3109
|
exports.getSDK = getSDK;
|
|
3110
|
+
exports.getSessionId = getSessionId2;
|
|
3062
3111
|
exports.getStatus = getStatus;
|
|
3063
3112
|
exports.getTarget = getTarget;
|
|
3064
3113
|
exports.getTrackingId = getTrackingId;
|