@amplifyup/sdk 0.1.73 → 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 +97 -12
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +97 -12
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +27 -5
- package/dist/index.d.ts +27 -5
- package/dist/index.js +100 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +100 -34
- package/dist/index.mjs.map +1 -1
- package/dist/{query-Hay-oVYp.d.ts → query-B23UsNIv.d.ts} +1 -1
- package/dist/{query-B_DU7yEm.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 +106 -35
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +106 -35
- 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 +3 -1
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +3 -1
- package/dist/server.mjs.map +1 -1
- package/dist/{types-CGeBbx84.d.mts → types-D4TSd2Yt.d.mts} +23 -2
- package/dist/{types-CGeBbx84.d.ts → types-D4TSd2Yt.d.ts} +23 -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, 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
|
|
@@ -71,6 +71,10 @@ interface EdgeResolvedPayload {
|
|
|
71
71
|
/** Composer event bindings baked into the published snapshot. */
|
|
72
72
|
eventTracking?: EventTrackingConfig$1[];
|
|
73
73
|
pageData?: PageDataSnapshot;
|
|
74
|
+
/** resource name → document this URL resolved to. */
|
|
75
|
+
pageResources?: Record<string, ResolvedPageResourceRef>;
|
|
76
|
+
/** taxonomy key → term ids this page is tagged with. */
|
|
77
|
+
pageTaxonomies?: PageTaxonomies;
|
|
74
78
|
meta: {
|
|
75
79
|
variantKeys: Record<string, string>;
|
|
76
80
|
audienceLookup?: {
|
|
@@ -200,8 +204,15 @@ declare class AmplifyUpSDK {
|
|
|
200
204
|
private pendingPageContext;
|
|
201
205
|
private attachedPageContext;
|
|
202
206
|
private resolvedPageData;
|
|
207
|
+
private resolvedPageResource;
|
|
203
208
|
private resolvedPageRoute;
|
|
204
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;
|
|
205
216
|
private historyHooksInstalled;
|
|
206
217
|
private pageEngagementState;
|
|
207
218
|
constructor(adapter?: CDPAdapter);
|
|
@@ -271,13 +282,24 @@ declare class AmplifyUpSDK {
|
|
|
271
282
|
* Apply published pageData (from /v1/resolve) so field validation and
|
|
272
283
|
* mapped page fields can run.
|
|
273
284
|
*/
|
|
274
|
-
applyResolvedPageData(pageData: PageDataSnapshot | null | undefined, pageRoute?: string, routeParams?: Record<string, string>): void;
|
|
285
|
+
applyResolvedPageData(pageData: PageDataSnapshot | null | undefined, pageRoute?: string, routeParams?: Record<string, string>, pageResources?: Record<string, ResolvedPageResourceRef> | null, pageTaxonomies?: PageTaxonomies | null): void;
|
|
275
286
|
private recomputeAttachedContext;
|
|
287
|
+
/** Stamp the resolved entry onto the context so events carry it. */
|
|
288
|
+
private withPageResource;
|
|
276
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;
|
|
277
298
|
/**
|
|
278
299
|
* Track a page view
|
|
279
300
|
*/
|
|
280
301
|
page(url: string, properties?: EventProperties): void;
|
|
302
|
+
private sendPageView;
|
|
281
303
|
/**
|
|
282
304
|
* Track an event
|
|
283
305
|
*/
|
|
@@ -571,4 +593,4 @@ declare const verifyAWSConnection: () => {
|
|
|
571
593
|
|
|
572
594
|
declare const _default: AmplifyUpSDK;
|
|
573
595
|
|
|
574
|
-
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, 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
|
|
@@ -71,6 +71,10 @@ interface EdgeResolvedPayload {
|
|
|
71
71
|
/** Composer event bindings baked into the published snapshot. */
|
|
72
72
|
eventTracking?: EventTrackingConfig$1[];
|
|
73
73
|
pageData?: PageDataSnapshot;
|
|
74
|
+
/** resource name → document this URL resolved to. */
|
|
75
|
+
pageResources?: Record<string, ResolvedPageResourceRef>;
|
|
76
|
+
/** taxonomy key → term ids this page is tagged with. */
|
|
77
|
+
pageTaxonomies?: PageTaxonomies;
|
|
74
78
|
meta: {
|
|
75
79
|
variantKeys: Record<string, string>;
|
|
76
80
|
audienceLookup?: {
|
|
@@ -200,8 +204,15 @@ declare class AmplifyUpSDK {
|
|
|
200
204
|
private pendingPageContext;
|
|
201
205
|
private attachedPageContext;
|
|
202
206
|
private resolvedPageData;
|
|
207
|
+
private resolvedPageResource;
|
|
203
208
|
private resolvedPageRoute;
|
|
204
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;
|
|
205
216
|
private historyHooksInstalled;
|
|
206
217
|
private pageEngagementState;
|
|
207
218
|
constructor(adapter?: CDPAdapter);
|
|
@@ -271,13 +282,24 @@ declare class AmplifyUpSDK {
|
|
|
271
282
|
* Apply published pageData (from /v1/resolve) so field validation and
|
|
272
283
|
* mapped page fields can run.
|
|
273
284
|
*/
|
|
274
|
-
applyResolvedPageData(pageData: PageDataSnapshot | null | undefined, pageRoute?: string, routeParams?: Record<string, string>): void;
|
|
285
|
+
applyResolvedPageData(pageData: PageDataSnapshot | null | undefined, pageRoute?: string, routeParams?: Record<string, string>, pageResources?: Record<string, ResolvedPageResourceRef> | null, pageTaxonomies?: PageTaxonomies | null): void;
|
|
275
286
|
private recomputeAttachedContext;
|
|
287
|
+
/** Stamp the resolved entry onto the context so events carry it. */
|
|
288
|
+
private withPageResource;
|
|
276
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;
|
|
277
298
|
/**
|
|
278
299
|
* Track a page view
|
|
279
300
|
*/
|
|
280
301
|
page(url: string, properties?: EventProperties): void;
|
|
302
|
+
private sendPageView;
|
|
281
303
|
/**
|
|
282
304
|
* Track an event
|
|
283
305
|
*/
|
|
@@ -571,4 +593,4 @@ declare const verifyAWSConnection: () => {
|
|
|
571
593
|
|
|
572
594
|
declare const _default: AmplifyUpSDK;
|
|
573
595
|
|
|
574
|
-
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,15 +788,42 @@ 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 {
|
|
792
799
|
...properties,
|
|
793
800
|
...attached.resource ? { resource: attached.resource } : {},
|
|
794
801
|
page: attached.page,
|
|
795
|
-
...attached.pageRoute ? { pageRoute: attached.pageRoute } : {}
|
|
802
|
+
...attached.pageRoute ? { pageRoute: attached.pageRoute } : {},
|
|
803
|
+
...attached.pageResource ? { pageResource: attached.pageResource } : {}
|
|
796
804
|
};
|
|
797
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
|
+
}
|
|
798
827
|
function setPageResourceFields(fields) {
|
|
799
828
|
}
|
|
800
829
|
|
|
@@ -872,27 +901,6 @@ function isAmplifyUpEditorRoute(pathname) {
|
|
|
872
901
|
return pathname === AMPLIFYUP_EDITOR_ROUTE || pathname.startsWith(`${AMPLIFYUP_EDITOR_ROUTE}/`);
|
|
873
902
|
}
|
|
874
903
|
|
|
875
|
-
// src/edge/normalizeRoute.ts
|
|
876
|
-
function normalizeRoute(route) {
|
|
877
|
-
let path = String(route || "").trim();
|
|
878
|
-
if (!path) return "/";
|
|
879
|
-
try {
|
|
880
|
-
if (/^https?:\/\//i.test(path)) {
|
|
881
|
-
path = new URL(path).pathname;
|
|
882
|
-
}
|
|
883
|
-
} catch {
|
|
884
|
-
}
|
|
885
|
-
const q = path.indexOf("?");
|
|
886
|
-
if (q >= 0) path = path.slice(0, q);
|
|
887
|
-
const h = path.indexOf("#");
|
|
888
|
-
if (h >= 0) path = path.slice(0, h);
|
|
889
|
-
if (!path.startsWith("/")) path = `/${path}`;
|
|
890
|
-
if (path.length > 1 && path.endsWith("/")) {
|
|
891
|
-
path = path.replace(/\/+$/, "");
|
|
892
|
-
}
|
|
893
|
-
return path || "/";
|
|
894
|
-
}
|
|
895
|
-
|
|
896
904
|
// src/edge/variantKeys.ts
|
|
897
905
|
function serializeVariantKeys(keys) {
|
|
898
906
|
if (!keys) return "";
|
|
@@ -1013,7 +1021,9 @@ function mapResolvedToPageConfig(payload) {
|
|
|
1013
1021
|
description: payload.meta?.degraded ? "degraded" : void 0
|
|
1014
1022
|
},
|
|
1015
1023
|
...payload.eventTracking && payload.eventTracking.length > 0 ? { eventTracking: payload.eventTracking } : {},
|
|
1016
|
-
...payload.pageData ? { pageData: payload.pageData } : {}
|
|
1024
|
+
...payload.pageData ? { pageData: payload.pageData } : {},
|
|
1025
|
+
...payload.pageResources ? { pageResources: payload.pageResources } : {},
|
|
1026
|
+
...payload.pageTaxonomies ? { pageTaxonomies: payload.pageTaxonomies } : {}
|
|
1017
1027
|
};
|
|
1018
1028
|
}
|
|
1019
1029
|
function collectDegraded(payload) {
|
|
@@ -1245,6 +1255,7 @@ function searchSpec(pagination, field, term) {
|
|
|
1245
1255
|
}
|
|
1246
1256
|
|
|
1247
1257
|
// src/index.ts
|
|
1258
|
+
var PAGE_VIEW_HOLD_MS = 1500;
|
|
1248
1259
|
var DWELL_ACTIVITY_IDLE_MS = 2 * 60 * 1e3;
|
|
1249
1260
|
var DWELL_POLL_MS = 5e3;
|
|
1250
1261
|
function readPreviewQueryOverrides() {
|
|
@@ -1315,8 +1326,15 @@ var AmplifyUpSDK = class {
|
|
|
1315
1326
|
this.pendingPageContext = null;
|
|
1316
1327
|
this.attachedPageContext = null;
|
|
1317
1328
|
this.resolvedPageData = null;
|
|
1329
|
+
this.resolvedPageResource = null;
|
|
1318
1330
|
this.resolvedPageRoute = "";
|
|
1319
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;
|
|
1320
1338
|
this.historyHooksInstalled = false;
|
|
1321
1339
|
this.pageEngagementState = {
|
|
1322
1340
|
reached: /* @__PURE__ */ new Set(),
|
|
@@ -1847,30 +1865,64 @@ var AmplifyUpSDK = class {
|
|
|
1847
1865
|
* Apply published pageData (from /v1/resolve) so field validation and
|
|
1848
1866
|
* mapped page fields can run.
|
|
1849
1867
|
*/
|
|
1850
|
-
applyResolvedPageData(pageData, pageRoute, routeParams) {
|
|
1868
|
+
applyResolvedPageData(pageData, pageRoute, routeParams, pageResources, pageTaxonomies) {
|
|
1851
1869
|
this.resolvedPageData = pageData || null;
|
|
1870
|
+
this.resolvedPageTaxonomies = pageTaxonomies || null;
|
|
1871
|
+
this.resolvedTaxonomiesPath = this.pendingResolvePath;
|
|
1852
1872
|
if (pageRoute) this.resolvedPageRoute = pageRoute;
|
|
1853
1873
|
if (routeParams) this.resolvedRouteParams = routeParams;
|
|
1874
|
+
const firstResourceName = pageData?.resources?.[0]?.name;
|
|
1875
|
+
const resolvedForPage = (firstResourceName ? pageResources?.[firstResourceName] : void 0) || (pageResources ? Object.values(pageResources)[0] : void 0);
|
|
1876
|
+
this.resolvedPageResource = resolvedForPage || null;
|
|
1854
1877
|
this.recomputeAttachedContext();
|
|
1855
1878
|
}
|
|
1856
1879
|
recomputeAttachedContext() {
|
|
1857
1880
|
if (!this.pendingPageContext) {
|
|
1858
|
-
this.attachedPageContext =
|
|
1859
|
-
this.resolvedPageData,
|
|
1860
|
-
this.resolvedPageRoute
|
|
1881
|
+
this.attachedPageContext = this.withPageResource(
|
|
1882
|
+
attachStaticPageContext(this.resolvedPageData, this.resolvedPageRoute)
|
|
1861
1883
|
);
|
|
1862
1884
|
return;
|
|
1863
1885
|
}
|
|
1864
|
-
this.attachedPageContext =
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1886
|
+
this.attachedPageContext = this.withPageResource(
|
|
1887
|
+
applyPageContext(this.pendingPageContext, {
|
|
1888
|
+
pageData: this.resolvedPageData,
|
|
1889
|
+
routeParams: this.resolvedRouteParams,
|
|
1890
|
+
pageRoute: this.resolvedPageRoute
|
|
1891
|
+
})
|
|
1892
|
+
);
|
|
1869
1893
|
setPageResourceFields(this.attachedPageContext?.resource?.fields || null);
|
|
1870
1894
|
}
|
|
1895
|
+
/** Stamp the resolved entry onto the context so events carry it. */
|
|
1896
|
+
withPageResource(context) {
|
|
1897
|
+
if (!context || !this.resolvedPageResource) return context;
|
|
1898
|
+
const { entity, providerId, docId } = this.resolvedPageResource;
|
|
1899
|
+
return { ...context, pageResource: { entity, providerId, docId } };
|
|
1900
|
+
}
|
|
1871
1901
|
getAttachedPageContext() {
|
|
1872
1902
|
return this.attachedPageContext;
|
|
1873
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
|
+
}
|
|
1874
1926
|
/**
|
|
1875
1927
|
* Track a page view
|
|
1876
1928
|
*/
|
|
@@ -1881,6 +1933,21 @@ var AmplifyUpSDK = class {
|
|
|
1881
1933
|
if (!this.isInitialized()) {
|
|
1882
1934
|
return;
|
|
1883
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;
|
|
1884
1951
|
const instanceId = getInstanceId();
|
|
1885
1952
|
const sessionId = getSessionId();
|
|
1886
1953
|
const pageProperties = {
|
|
@@ -1892,10 +1959,9 @@ var AmplifyUpSDK = class {
|
|
|
1892
1959
|
sessionId,
|
|
1893
1960
|
trackingId: this.config?.trackingId,
|
|
1894
1961
|
// Timestamp is included in event payload
|
|
1895
|
-
...mergeEventContext(properties || {}, this.attachedPageContext)
|
|
1962
|
+
...withPageTaxonomies(mergeEventContext(properties || {}, this.attachedPageContext), taxonomies)
|
|
1896
1963
|
};
|
|
1897
1964
|
this.adapter.page(pageProperties);
|
|
1898
|
-
this.lastTrackedPath = url;
|
|
1899
1965
|
}
|
|
1900
1966
|
/**
|
|
1901
1967
|
* Track an event
|