@amplifyup/sdk 0.1.74 → 0.1.75
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 +76 -3
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +76 -3
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +22 -5
- package/dist/index.d.ts +22 -5
- package/dist/index.js +78 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -25
- package/dist/index.mjs.map +1 -1
- package/dist/{query-NcrxJQvI.d.ts → query-B23UsNIv.d.ts} +1 -1
- package/dist/{query-_SMo6VRf.d.mts → query-CV8x3oQT.d.mts} +1 -1
- package/dist/react.d.mts +3 -3
- package/dist/react.d.ts +3 -3
- package/dist/react.js +83 -26
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +83 -26
- 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 +2 -1
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +2 -1
- package/dist/server.mjs.map +1 -1
- package/dist/{types-BGZYaFxP.d.mts → types-D4TSd2Yt.d.mts} +8 -2
- package/dist/{types-BGZYaFxP.d.ts → types-D4TSd2Yt.d.ts} +8 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as EventTrackingConfig$1, a as PageDataSnapshot, R as ResolvedPageResourceRef, b as
|
|
2
|
-
export { Z as ZoneConfig,
|
|
1
|
+
import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as EventTrackingConfig$1, a as PageDataSnapshot, R as ResolvedPageResourceRef, b as PageTaxonomies, c as CDPAdapter, d as AmplifyUpConfig, e as EventProperties, f as AmplifyPageContextInput, g as AttachedPageEventContext, I as IdentifyInput, h as IdentifyTraits, i as ProfileFieldsInput, j as AmplifyUpTarget } from './types-D4TSd2Yt.mjs';
|
|
2
|
+
export { Z as ZoneConfig, l as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, k as resolveAmplifyUpUrls } from './types-D4TSd2Yt.mjs';
|
|
3
3
|
export { i as isComposerPreview, a as isPreviewRequest, b as isWorkingContentRequest } from './preview-_vHmzRen.mjs';
|
|
4
4
|
export { A as AMPLIFYUP_EDITOR_ROUTE, i as isAmplifyUpEditorRoute } from './reservedRoutes-aGgViBDM.mjs';
|
|
5
|
-
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-
|
|
5
|
+
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-CV8x3oQT.mjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Storage utilities for instance ID and user ID
|
|
@@ -73,6 +73,8 @@ interface EdgeResolvedPayload {
|
|
|
73
73
|
pageData?: PageDataSnapshot;
|
|
74
74
|
/** resource name → document this URL resolved to. */
|
|
75
75
|
pageResources?: Record<string, ResolvedPageResourceRef>;
|
|
76
|
+
/** taxonomy key → term ids this page is tagged with. */
|
|
77
|
+
pageTaxonomies?: PageTaxonomies;
|
|
76
78
|
meta: {
|
|
77
79
|
variantKeys: Record<string, string>;
|
|
78
80
|
audienceLookup?: {
|
|
@@ -205,6 +207,12 @@ declare class AmplifyUpSDK {
|
|
|
205
207
|
private resolvedPageResource;
|
|
206
208
|
private resolvedPageRoute;
|
|
207
209
|
private resolvedRouteParams;
|
|
210
|
+
/** Path whose delivery response is in flight; page_view for it is held. */
|
|
211
|
+
private pendingResolvePath;
|
|
212
|
+
private heldPageView;
|
|
213
|
+
private resolvedPageTaxonomies;
|
|
214
|
+
/** Path the taxonomies above were resolved for. */
|
|
215
|
+
private resolvedTaxonomiesPath;
|
|
208
216
|
private historyHooksInstalled;
|
|
209
217
|
private pageEngagementState;
|
|
210
218
|
constructor(adapter?: CDPAdapter);
|
|
@@ -274,15 +282,24 @@ declare class AmplifyUpSDK {
|
|
|
274
282
|
* Apply published pageData (from /v1/resolve) so field validation and
|
|
275
283
|
* mapped page fields can run.
|
|
276
284
|
*/
|
|
277
|
-
applyResolvedPageData(pageData: PageDataSnapshot | null | undefined, pageRoute?: string, routeParams?: Record<string, string>, pageResources?: Record<string, ResolvedPageResourceRef> | null): void;
|
|
285
|
+
applyResolvedPageData(pageData: PageDataSnapshot | null | undefined, pageRoute?: string, routeParams?: Record<string, string>, pageResources?: Record<string, ResolvedPageResourceRef> | null, pageTaxonomies?: PageTaxonomies | null): void;
|
|
278
286
|
private recomputeAttachedContext;
|
|
279
287
|
/** Stamp the resolved entry onto the context so events carry it. */
|
|
280
288
|
private withPageResource;
|
|
281
289
|
getAttachedPageContext(): AttachedPageEventContext | null;
|
|
290
|
+
/**
|
|
291
|
+
* The page's delivery response for `path` is on its way. A page_view for the
|
|
292
|
+
* same path waits for it (up to PAGE_VIEW_HOLD_MS) so it carries the page's
|
|
293
|
+
* taxonomies.
|
|
294
|
+
*/
|
|
295
|
+
beginPageResolve(path: string): void;
|
|
296
|
+
endPageResolve(path: string): void;
|
|
297
|
+
private flushHeldPageView;
|
|
282
298
|
/**
|
|
283
299
|
* Track a page view
|
|
284
300
|
*/
|
|
285
301
|
page(url: string, properties?: EventProperties): void;
|
|
302
|
+
private sendPageView;
|
|
286
303
|
/**
|
|
287
304
|
* Track an event
|
|
288
305
|
*/
|
|
@@ -576,4 +593,4 @@ declare const verifyAWSConnection: () => {
|
|
|
576
593
|
|
|
577
594
|
declare const _default: AmplifyUpSDK;
|
|
578
595
|
|
|
579
|
-
export { ANON_COOKIE_NAME, AmplifyContentMeta, AmplifyPageContextInput, AmplifyUpConfig, AmplifyUpSDK, AmplifyUpTarget, CDPAdapter, ContentSource, DWELL_ACTIVITY_IDLE_MS, EdgeResolveError, EventProperties, EventTrackingConfig$1 as EventTrackingConfig, type FetchContentOptions, type FetchContentResult, IdentifyInput, IdentifyTraits, PageConfig, PageDataSnapshot, 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 };
|
|
596
|
+
export { ANON_COOKIE_NAME, AmplifyContentMeta, AmplifyPageContextInput, AmplifyUpConfig, AmplifyUpSDK, AmplifyUpTarget, CDPAdapter, ContentSource, DWELL_ACTIVITY_IDLE_MS, EdgeResolveError, EventProperties, EventTrackingConfig$1 as EventTrackingConfig, type FetchContentOptions, type FetchContentResult, IdentifyInput, IdentifyTraits, PageConfig, PageDataSnapshot, PageTaxonomies, 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,8 +1,8 @@
|
|
|
1
|
-
import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as EventTrackingConfig$1, a as PageDataSnapshot, R as ResolvedPageResourceRef, b as
|
|
2
|
-
export { Z as ZoneConfig,
|
|
1
|
+
import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as EventTrackingConfig$1, a as PageDataSnapshot, R as ResolvedPageResourceRef, b as PageTaxonomies, c as CDPAdapter, d as AmplifyUpConfig, e as EventProperties, f as AmplifyPageContextInput, g as AttachedPageEventContext, I as IdentifyInput, h as IdentifyTraits, i as ProfileFieldsInput, j as AmplifyUpTarget } from './types-D4TSd2Yt.js';
|
|
2
|
+
export { Z as ZoneConfig, l as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, k as resolveAmplifyUpUrls } from './types-D4TSd2Yt.js';
|
|
3
3
|
export { i as isComposerPreview, a as isPreviewRequest, b as isWorkingContentRequest } from './preview-_vHmzRen.js';
|
|
4
4
|
export { A as AMPLIFYUP_EDITOR_ROUTE, i as isAmplifyUpEditorRoute } from './reservedRoutes-aGgViBDM.js';
|
|
5
|
-
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-
|
|
5
|
+
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-B23UsNIv.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Storage utilities for instance ID and user ID
|
|
@@ -73,6 +73,8 @@ interface EdgeResolvedPayload {
|
|
|
73
73
|
pageData?: PageDataSnapshot;
|
|
74
74
|
/** resource name → document this URL resolved to. */
|
|
75
75
|
pageResources?: Record<string, ResolvedPageResourceRef>;
|
|
76
|
+
/** taxonomy key → term ids this page is tagged with. */
|
|
77
|
+
pageTaxonomies?: PageTaxonomies;
|
|
76
78
|
meta: {
|
|
77
79
|
variantKeys: Record<string, string>;
|
|
78
80
|
audienceLookup?: {
|
|
@@ -205,6 +207,12 @@ declare class AmplifyUpSDK {
|
|
|
205
207
|
private resolvedPageResource;
|
|
206
208
|
private resolvedPageRoute;
|
|
207
209
|
private resolvedRouteParams;
|
|
210
|
+
/** Path whose delivery response is in flight; page_view for it is held. */
|
|
211
|
+
private pendingResolvePath;
|
|
212
|
+
private heldPageView;
|
|
213
|
+
private resolvedPageTaxonomies;
|
|
214
|
+
/** Path the taxonomies above were resolved for. */
|
|
215
|
+
private resolvedTaxonomiesPath;
|
|
208
216
|
private historyHooksInstalled;
|
|
209
217
|
private pageEngagementState;
|
|
210
218
|
constructor(adapter?: CDPAdapter);
|
|
@@ -274,15 +282,24 @@ declare class AmplifyUpSDK {
|
|
|
274
282
|
* Apply published pageData (from /v1/resolve) so field validation and
|
|
275
283
|
* mapped page fields can run.
|
|
276
284
|
*/
|
|
277
|
-
applyResolvedPageData(pageData: PageDataSnapshot | null | undefined, pageRoute?: string, routeParams?: Record<string, string>, pageResources?: Record<string, ResolvedPageResourceRef> | null): void;
|
|
285
|
+
applyResolvedPageData(pageData: PageDataSnapshot | null | undefined, pageRoute?: string, routeParams?: Record<string, string>, pageResources?: Record<string, ResolvedPageResourceRef> | null, pageTaxonomies?: PageTaxonomies | null): void;
|
|
278
286
|
private recomputeAttachedContext;
|
|
279
287
|
/** Stamp the resolved entry onto the context so events carry it. */
|
|
280
288
|
private withPageResource;
|
|
281
289
|
getAttachedPageContext(): AttachedPageEventContext | null;
|
|
290
|
+
/**
|
|
291
|
+
* The page's delivery response for `path` is on its way. A page_view for the
|
|
292
|
+
* same path waits for it (up to PAGE_VIEW_HOLD_MS) so it carries the page's
|
|
293
|
+
* taxonomies.
|
|
294
|
+
*/
|
|
295
|
+
beginPageResolve(path: string): void;
|
|
296
|
+
endPageResolve(path: string): void;
|
|
297
|
+
private flushHeldPageView;
|
|
282
298
|
/**
|
|
283
299
|
* Track a page view
|
|
284
300
|
*/
|
|
285
301
|
page(url: string, properties?: EventProperties): void;
|
|
302
|
+
private sendPageView;
|
|
286
303
|
/**
|
|
287
304
|
* Track an event
|
|
288
305
|
*/
|
|
@@ -576,4 +593,4 @@ declare const verifyAWSConnection: () => {
|
|
|
576
593
|
|
|
577
594
|
declare const _default: AmplifyUpSDK;
|
|
578
595
|
|
|
579
|
-
export { ANON_COOKIE_NAME, AmplifyContentMeta, AmplifyPageContextInput, AmplifyUpConfig, AmplifyUpSDK, AmplifyUpTarget, CDPAdapter, ContentSource, DWELL_ACTIVITY_IDLE_MS, EdgeResolveError, EventProperties, EventTrackingConfig$1 as EventTrackingConfig, type FetchContentOptions, type FetchContentResult, IdentifyInput, IdentifyTraits, PageConfig, PageDataSnapshot, 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 };
|
|
596
|
+
export { ANON_COOKIE_NAME, AmplifyContentMeta, AmplifyPageContextInput, AmplifyUpConfig, AmplifyUpSDK, AmplifyUpTarget, CDPAdapter, ContentSource, DWELL_ACTIVITY_IDLE_MS, EdgeResolveError, EventProperties, EventTrackingConfig$1 as EventTrackingConfig, type FetchContentOptions, type FetchContentResult, IdentifyInput, IdentifyTraits, PageConfig, PageDataSnapshot, PageTaxonomies, 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
|
@@ -747,6 +747,7 @@ function applyPageContext(input, opts) {
|
|
|
747
747
|
}
|
|
748
748
|
const pageFields = {};
|
|
749
749
|
for (const pf of opts.pageData?.pageFields || []) {
|
|
750
|
+
if (pf.dataType === "taxonomy") continue;
|
|
750
751
|
if (pf.source === "static") {
|
|
751
752
|
if (pf.value !== void 0) pageFields[pf.key] = pf.value;
|
|
752
753
|
continue;
|
|
@@ -769,6 +770,7 @@ function applyPageContext(input, opts) {
|
|
|
769
770
|
function staticPageFieldsFromSnapshot(pageData) {
|
|
770
771
|
const pageFields = {};
|
|
771
772
|
for (const pf of pageData?.pageFields || []) {
|
|
773
|
+
if (pf.dataType === "taxonomy") continue;
|
|
772
774
|
if (pf.source === "static" && pf.value !== void 0) {
|
|
773
775
|
pageFields[pf.key] = pf.value;
|
|
774
776
|
}
|
|
@@ -786,6 +788,11 @@ function attachStaticPageContext(pageData, pageRoute) {
|
|
|
786
788
|
pageRoute: pageRoute || ""
|
|
787
789
|
};
|
|
788
790
|
}
|
|
791
|
+
function withPageTaxonomies(properties, taxonomies) {
|
|
792
|
+
if (!taxonomies || Object.keys(taxonomies).length === 0) return properties;
|
|
793
|
+
const page2 = properties.page && typeof properties.page === "object" && !Array.isArray(properties.page) ? properties.page : { fields: {} };
|
|
794
|
+
return { ...properties, page: { ...page2, taxonomies } };
|
|
795
|
+
}
|
|
789
796
|
function mergeEventContext(properties, attached) {
|
|
790
797
|
if (!attached) return properties;
|
|
791
798
|
return {
|
|
@@ -796,6 +803,27 @@ function mergeEventContext(properties, attached) {
|
|
|
796
803
|
...attached.pageResource ? { pageResource: attached.pageResource } : {}
|
|
797
804
|
};
|
|
798
805
|
}
|
|
806
|
+
|
|
807
|
+
// src/edge/normalizeRoute.ts
|
|
808
|
+
function normalizeRoute(route) {
|
|
809
|
+
let path = String(route || "").trim();
|
|
810
|
+
if (!path) return "/";
|
|
811
|
+
try {
|
|
812
|
+
if (/^https?:\/\//i.test(path)) {
|
|
813
|
+
path = new URL(path).pathname;
|
|
814
|
+
}
|
|
815
|
+
} catch {
|
|
816
|
+
}
|
|
817
|
+
const q = path.indexOf("?");
|
|
818
|
+
if (q >= 0) path = path.slice(0, q);
|
|
819
|
+
const h = path.indexOf("#");
|
|
820
|
+
if (h >= 0) path = path.slice(0, h);
|
|
821
|
+
if (!path.startsWith("/")) path = `/${path}`;
|
|
822
|
+
if (path.length > 1 && path.endsWith("/")) {
|
|
823
|
+
path = path.replace(/\/+$/, "");
|
|
824
|
+
}
|
|
825
|
+
return path || "/";
|
|
826
|
+
}
|
|
799
827
|
function setPageResourceFields(fields) {
|
|
800
828
|
}
|
|
801
829
|
|
|
@@ -873,27 +901,6 @@ function isAmplifyUpEditorRoute(pathname) {
|
|
|
873
901
|
return pathname === AMPLIFYUP_EDITOR_ROUTE || pathname.startsWith(`${AMPLIFYUP_EDITOR_ROUTE}/`);
|
|
874
902
|
}
|
|
875
903
|
|
|
876
|
-
// src/edge/normalizeRoute.ts
|
|
877
|
-
function normalizeRoute(route) {
|
|
878
|
-
let path = String(route || "").trim();
|
|
879
|
-
if (!path) return "/";
|
|
880
|
-
try {
|
|
881
|
-
if (/^https?:\/\//i.test(path)) {
|
|
882
|
-
path = new URL(path).pathname;
|
|
883
|
-
}
|
|
884
|
-
} catch {
|
|
885
|
-
}
|
|
886
|
-
const q = path.indexOf("?");
|
|
887
|
-
if (q >= 0) path = path.slice(0, q);
|
|
888
|
-
const h = path.indexOf("#");
|
|
889
|
-
if (h >= 0) path = path.slice(0, h);
|
|
890
|
-
if (!path.startsWith("/")) path = `/${path}`;
|
|
891
|
-
if (path.length > 1 && path.endsWith("/")) {
|
|
892
|
-
path = path.replace(/\/+$/, "");
|
|
893
|
-
}
|
|
894
|
-
return path || "/";
|
|
895
|
-
}
|
|
896
|
-
|
|
897
904
|
// src/edge/variantKeys.ts
|
|
898
905
|
function serializeVariantKeys(keys) {
|
|
899
906
|
if (!keys) return "";
|
|
@@ -1015,7 +1022,8 @@ function mapResolvedToPageConfig(payload) {
|
|
|
1015
1022
|
},
|
|
1016
1023
|
...payload.eventTracking && payload.eventTracking.length > 0 ? { eventTracking: payload.eventTracking } : {},
|
|
1017
1024
|
...payload.pageData ? { pageData: payload.pageData } : {},
|
|
1018
|
-
...payload.pageResources ? { pageResources: payload.pageResources } : {}
|
|
1025
|
+
...payload.pageResources ? { pageResources: payload.pageResources } : {},
|
|
1026
|
+
...payload.pageTaxonomies ? { pageTaxonomies: payload.pageTaxonomies } : {}
|
|
1019
1027
|
};
|
|
1020
1028
|
}
|
|
1021
1029
|
function collectDegraded(payload) {
|
|
@@ -1247,6 +1255,7 @@ function searchSpec(pagination, field, term) {
|
|
|
1247
1255
|
}
|
|
1248
1256
|
|
|
1249
1257
|
// src/index.ts
|
|
1258
|
+
var PAGE_VIEW_HOLD_MS = 1500;
|
|
1250
1259
|
var DWELL_ACTIVITY_IDLE_MS = 2 * 60 * 1e3;
|
|
1251
1260
|
var DWELL_POLL_MS = 5e3;
|
|
1252
1261
|
function readPreviewQueryOverrides() {
|
|
@@ -1320,6 +1329,12 @@ var AmplifyUpSDK = class {
|
|
|
1320
1329
|
this.resolvedPageResource = null;
|
|
1321
1330
|
this.resolvedPageRoute = "";
|
|
1322
1331
|
this.resolvedRouteParams = {};
|
|
1332
|
+
/** Path whose delivery response is in flight; page_view for it is held. */
|
|
1333
|
+
this.pendingResolvePath = null;
|
|
1334
|
+
this.heldPageView = null;
|
|
1335
|
+
this.resolvedPageTaxonomies = null;
|
|
1336
|
+
/** Path the taxonomies above were resolved for. */
|
|
1337
|
+
this.resolvedTaxonomiesPath = null;
|
|
1323
1338
|
this.historyHooksInstalled = false;
|
|
1324
1339
|
this.pageEngagementState = {
|
|
1325
1340
|
reached: /* @__PURE__ */ new Set(),
|
|
@@ -1850,8 +1865,10 @@ var AmplifyUpSDK = class {
|
|
|
1850
1865
|
* Apply published pageData (from /v1/resolve) so field validation and
|
|
1851
1866
|
* mapped page fields can run.
|
|
1852
1867
|
*/
|
|
1853
|
-
applyResolvedPageData(pageData, pageRoute, routeParams, pageResources) {
|
|
1868
|
+
applyResolvedPageData(pageData, pageRoute, routeParams, pageResources, pageTaxonomies) {
|
|
1854
1869
|
this.resolvedPageData = pageData || null;
|
|
1870
|
+
this.resolvedPageTaxonomies = pageTaxonomies || null;
|
|
1871
|
+
this.resolvedTaxonomiesPath = this.pendingResolvePath;
|
|
1855
1872
|
if (pageRoute) this.resolvedPageRoute = pageRoute;
|
|
1856
1873
|
if (routeParams) this.resolvedRouteParams = routeParams;
|
|
1857
1874
|
const firstResourceName = pageData?.resources?.[0]?.name;
|
|
@@ -1884,6 +1901,28 @@ var AmplifyUpSDK = class {
|
|
|
1884
1901
|
getAttachedPageContext() {
|
|
1885
1902
|
return this.attachedPageContext;
|
|
1886
1903
|
}
|
|
1904
|
+
/**
|
|
1905
|
+
* The page's delivery response for `path` is on its way. A page_view for the
|
|
1906
|
+
* same path waits for it (up to PAGE_VIEW_HOLD_MS) so it carries the page's
|
|
1907
|
+
* taxonomies.
|
|
1908
|
+
*/
|
|
1909
|
+
beginPageResolve(path) {
|
|
1910
|
+
this.pendingResolvePath = normalizeRoute(path);
|
|
1911
|
+
this.resolvedPageTaxonomies = null;
|
|
1912
|
+
this.resolvedTaxonomiesPath = null;
|
|
1913
|
+
}
|
|
1914
|
+
endPageResolve(path) {
|
|
1915
|
+
if (this.pendingResolvePath !== normalizeRoute(path)) return;
|
|
1916
|
+
this.pendingResolvePath = null;
|
|
1917
|
+
this.flushHeldPageView();
|
|
1918
|
+
}
|
|
1919
|
+
flushHeldPageView() {
|
|
1920
|
+
const held = this.heldPageView;
|
|
1921
|
+
if (!held) return;
|
|
1922
|
+
clearTimeout(held.timer);
|
|
1923
|
+
this.heldPageView = null;
|
|
1924
|
+
this.sendPageView(held.url, held.properties);
|
|
1925
|
+
}
|
|
1887
1926
|
/**
|
|
1888
1927
|
* Track a page view
|
|
1889
1928
|
*/
|
|
@@ -1894,6 +1933,21 @@ var AmplifyUpSDK = class {
|
|
|
1894
1933
|
if (!this.isInitialized()) {
|
|
1895
1934
|
return;
|
|
1896
1935
|
}
|
|
1936
|
+
this.lastTrackedPath = url;
|
|
1937
|
+
if (this.pendingResolvePath && this.pendingResolvePath === normalizeRoute(url)) {
|
|
1938
|
+
this.flushHeldPageView();
|
|
1939
|
+
this.heldPageView = {
|
|
1940
|
+
url,
|
|
1941
|
+
properties,
|
|
1942
|
+
timer: setTimeout(() => this.flushHeldPageView(), PAGE_VIEW_HOLD_MS)
|
|
1943
|
+
};
|
|
1944
|
+
return;
|
|
1945
|
+
}
|
|
1946
|
+
this.flushHeldPageView();
|
|
1947
|
+
this.sendPageView(url, properties);
|
|
1948
|
+
}
|
|
1949
|
+
sendPageView(url, properties) {
|
|
1950
|
+
const taxonomies = this.resolvedTaxonomiesPath && this.resolvedTaxonomiesPath === normalizeRoute(url) ? this.resolvedPageTaxonomies : null;
|
|
1897
1951
|
const instanceId = getInstanceId();
|
|
1898
1952
|
const sessionId = getSessionId();
|
|
1899
1953
|
const pageProperties = {
|
|
@@ -1905,10 +1959,9 @@ var AmplifyUpSDK = class {
|
|
|
1905
1959
|
sessionId,
|
|
1906
1960
|
trackingId: this.config?.trackingId,
|
|
1907
1961
|
// Timestamp is included in event payload
|
|
1908
|
-
...mergeEventContext(properties || {}, this.attachedPageContext)
|
|
1962
|
+
...withPageTaxonomies(mergeEventContext(properties || {}, this.attachedPageContext), taxonomies)
|
|
1909
1963
|
};
|
|
1910
1964
|
this.adapter.page(pageProperties);
|
|
1911
|
-
this.lastTrackedPath = url;
|
|
1912
1965
|
}
|
|
1913
1966
|
/**
|
|
1914
1967
|
* Track an event
|