@amplifyup/sdk 0.1.25 → 0.1.27
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.js +47 -35
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +47 -35
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +8 -12
- package/dist/index.d.ts +8 -12
- package/dist/index.js +47 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -36
- package/dist/index.mjs.map +1 -1
- package/dist/react.js +232 -37
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +233 -38
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -109,14 +109,10 @@ declare function normalizeRoute(route: string): string;
|
|
|
109
109
|
*/
|
|
110
110
|
declare const SESSION_IDLE_GAP_MS: number;
|
|
111
111
|
/**
|
|
112
|
-
* Time
|
|
113
|
-
*
|
|
114
|
-
*
|
|
112
|
+
* Time on Page: one event per page visit, sent when the visit ends
|
|
113
|
+
* (SPA navigation, tab close, or 30-minute idle resume). Switching tabs
|
|
114
|
+
* pauses the clock; abandoned-but-visible tabs freeze after this idle gap.
|
|
115
115
|
*/
|
|
116
|
-
declare const DWELL_MILESTONES_SEC: readonly [15, 30, 60, 120, 300];
|
|
117
|
-
/** After the last milestone, emit at most once per this many seconds. */
|
|
118
|
-
declare const DWELL_CHECKPOINT_SEC: number;
|
|
119
|
-
/** Stop accruing dwell while visible but without user activity. */
|
|
120
116
|
declare const DWELL_ACTIVITY_IDLE_MS: number;
|
|
121
117
|
interface EventTrackingConfig {
|
|
122
118
|
eventName: string;
|
|
@@ -205,14 +201,14 @@ declare class AmplifyUpSDK {
|
|
|
205
201
|
private currentPath;
|
|
206
202
|
/**
|
|
207
203
|
* Automatic page-level Scroll Depth + Time on Page.
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
204
|
+
* Time on Page fires once per visit when the visit ends (route change,
|
|
205
|
+
* tab close, or 30-minute idle resume). Hidden tabs pause the clock;
|
|
206
|
+
* visible-but-idle tabs freeze after DWELL_ACTIVITY_IDLE_MS.
|
|
211
207
|
*/
|
|
212
208
|
private setupPageEngagement;
|
|
213
209
|
/** Flush dwell then reset — used on SPA route changes. */
|
|
214
210
|
private resetEngagementForNewPage;
|
|
215
|
-
/** Reset dwell/scroll state without emitting (idle resume already flushed
|
|
211
|
+
/** Reset dwell/scroll state without emitting (idle resume already flushed). */
|
|
216
212
|
private resetEngagementQuiet;
|
|
217
213
|
/**
|
|
218
214
|
* SPA / soft navigation: fire a page view and reset engagement.
|
|
@@ -517,4 +513,4 @@ declare const verifyAWSConnection: () => {
|
|
|
517
513
|
|
|
518
514
|
declare const _default: AmplifyUpSDK;
|
|
519
515
|
|
|
520
|
-
export { AmplifyContentMeta, AmplifyUpConfig, AmplifyUpSDK, AmplifyUpTarget, CDPAdapter, ContentSource, DWELL_ACTIVITY_IDLE_MS,
|
|
516
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -109,14 +109,10 @@ declare function normalizeRoute(route: string): string;
|
|
|
109
109
|
*/
|
|
110
110
|
declare const SESSION_IDLE_GAP_MS: number;
|
|
111
111
|
/**
|
|
112
|
-
* Time
|
|
113
|
-
*
|
|
114
|
-
*
|
|
112
|
+
* Time on Page: one event per page visit, sent when the visit ends
|
|
113
|
+
* (SPA navigation, tab close, or 30-minute idle resume). Switching tabs
|
|
114
|
+
* pauses the clock; abandoned-but-visible tabs freeze after this idle gap.
|
|
115
115
|
*/
|
|
116
|
-
declare const DWELL_MILESTONES_SEC: readonly [15, 30, 60, 120, 300];
|
|
117
|
-
/** After the last milestone, emit at most once per this many seconds. */
|
|
118
|
-
declare const DWELL_CHECKPOINT_SEC: number;
|
|
119
|
-
/** Stop accruing dwell while visible but without user activity. */
|
|
120
116
|
declare const DWELL_ACTIVITY_IDLE_MS: number;
|
|
121
117
|
interface EventTrackingConfig {
|
|
122
118
|
eventName: string;
|
|
@@ -205,14 +201,14 @@ declare class AmplifyUpSDK {
|
|
|
205
201
|
private currentPath;
|
|
206
202
|
/**
|
|
207
203
|
* Automatic page-level Scroll Depth + Time on Page.
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
204
|
+
* Time on Page fires once per visit when the visit ends (route change,
|
|
205
|
+
* tab close, or 30-minute idle resume). Hidden tabs pause the clock;
|
|
206
|
+
* visible-but-idle tabs freeze after DWELL_ACTIVITY_IDLE_MS.
|
|
211
207
|
*/
|
|
212
208
|
private setupPageEngagement;
|
|
213
209
|
/** Flush dwell then reset — used on SPA route changes. */
|
|
214
210
|
private resetEngagementForNewPage;
|
|
215
|
-
/** Reset dwell/scroll state without emitting (idle resume already flushed
|
|
211
|
+
/** Reset dwell/scroll state without emitting (idle resume already flushed). */
|
|
216
212
|
private resetEngagementQuiet;
|
|
217
213
|
/**
|
|
218
214
|
* SPA / soft navigation: fire a page view and reset engagement.
|
|
@@ -517,4 +513,4 @@ declare const verifyAWSConnection: () => {
|
|
|
517
513
|
|
|
518
514
|
declare const _default: AmplifyUpSDK;
|
|
519
515
|
|
|
520
|
-
export { AmplifyContentMeta, AmplifyUpConfig, AmplifyUpSDK, AmplifyUpTarget, CDPAdapter, ContentSource, DWELL_ACTIVITY_IDLE_MS,
|
|
516
|
+
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 };
|
package/dist/index.js
CHANGED
|
@@ -51,7 +51,10 @@ var AWSAdapter = class {
|
|
|
51
51
|
headers: {
|
|
52
52
|
"Content-Type": "application/json"
|
|
53
53
|
},
|
|
54
|
-
body: JSON.stringify(eventData)
|
|
54
|
+
body: JSON.stringify(eventData),
|
|
55
|
+
// Keep the request alive through tab close so the single Time on Page
|
|
56
|
+
// flush on pagehide is not cancelled with the document.
|
|
57
|
+
keepalive: true
|
|
55
58
|
});
|
|
56
59
|
if (!response.ok) {
|
|
57
60
|
if (this.config.debug) {
|
|
@@ -510,8 +513,6 @@ async function fetchContent(options) {
|
|
|
510
513
|
|
|
511
514
|
// src/index.ts
|
|
512
515
|
var SESSION_IDLE_GAP_MS = 30 * 60 * 1e3;
|
|
513
|
-
var DWELL_MILESTONES_SEC = [15, 30, 60, 120, 300];
|
|
514
|
-
var DWELL_CHECKPOINT_SEC = 15 * 60;
|
|
515
516
|
var DWELL_ACTIVITY_IDLE_MS = 2 * 60 * 1e3;
|
|
516
517
|
var DWELL_POLL_MS = 5e3;
|
|
517
518
|
function readPreviewQueryOverrides() {
|
|
@@ -582,7 +583,8 @@ var AmplifyUpSDK = class {
|
|
|
582
583
|
reached: /* @__PURE__ */ new Set(),
|
|
583
584
|
visibleMs: 0,
|
|
584
585
|
visibleSince: null,
|
|
585
|
-
|
|
586
|
+
/** True after Time on Page has been sent for the current visit. */
|
|
587
|
+
dwellEmitted: false,
|
|
586
588
|
/** When the tab last became hidden — used for idle-resume re-page. */
|
|
587
589
|
hiddenAt: null,
|
|
588
590
|
/** Last user interaction — freezes dwell when stale while visible. */
|
|
@@ -811,9 +813,9 @@ var AmplifyUpSDK = class {
|
|
|
811
813
|
}
|
|
812
814
|
/**
|
|
813
815
|
* Automatic page-level Scroll Depth + Time on Page.
|
|
814
|
-
*
|
|
815
|
-
*
|
|
816
|
-
*
|
|
816
|
+
* Time on Page fires once per visit when the visit ends (route change,
|
|
817
|
+
* tab close, or 30-minute idle resume). Hidden tabs pause the clock;
|
|
818
|
+
* visible-but-idle tabs freeze after DWELL_ACTIVITY_IDLE_MS.
|
|
817
819
|
*/
|
|
818
820
|
setupPageEngagement() {
|
|
819
821
|
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
@@ -824,7 +826,7 @@ var AmplifyUpSDK = class {
|
|
|
824
826
|
state.reached = /* @__PURE__ */ new Set();
|
|
825
827
|
state.visibleMs = 0;
|
|
826
828
|
state.visibleSince = document.visibilityState === "visible" ? Date.now() : null;
|
|
827
|
-
state.
|
|
829
|
+
state.dwellEmitted = false;
|
|
828
830
|
state.hiddenAt = document.visibilityState === "hidden" ? Date.now() : null;
|
|
829
831
|
state.lastActivityAt = Date.now();
|
|
830
832
|
state.activityIdle = false;
|
|
@@ -886,48 +888,34 @@ var AmplifyUpSDK = class {
|
|
|
886
888
|
}
|
|
887
889
|
}
|
|
888
890
|
};
|
|
889
|
-
const
|
|
890
|
-
for (const m of DWELL_MILESTONES_SEC) {
|
|
891
|
-
if (m > lastSent) return { seconds: m, reason: "milestone" };
|
|
892
|
-
}
|
|
893
|
-
const nextCheckpoint = Math.floor(lastSent / DWELL_CHECKPOINT_SEC) * DWELL_CHECKPOINT_SEC + DWELL_CHECKPOINT_SEC;
|
|
894
|
-
const target = nextCheckpoint > lastSent ? nextCheckpoint : lastSent + DWELL_CHECKPOINT_SEC;
|
|
895
|
-
return { seconds: target, reason: "checkpoint" };
|
|
896
|
-
};
|
|
897
|
-
const emitDwell = (reason, force = false) => {
|
|
891
|
+
const emitDwell = (reason) => {
|
|
898
892
|
if (this.isPreviewMode()) return;
|
|
893
|
+
if (state.dwellEmitted) return;
|
|
899
894
|
if (!state.activityIdle) {
|
|
900
895
|
accumulateVisible();
|
|
901
896
|
}
|
|
902
897
|
const seconds = Math.floor(state.visibleMs / 1e3);
|
|
903
898
|
if (seconds <= 0) return;
|
|
904
|
-
|
|
905
|
-
if (!force) {
|
|
906
|
-
const target = nextEmitTarget(state.lastDwellSecondsSent);
|
|
907
|
-
if (!target || seconds < target.seconds) return;
|
|
908
|
-
reason = target.reason;
|
|
909
|
-
}
|
|
910
|
-
state.lastDwellSecondsSent = seconds;
|
|
899
|
+
state.dwellEmitted = true;
|
|
911
900
|
this.track("Time on Page", {
|
|
912
901
|
seconds,
|
|
913
902
|
path: this.lastTrackedPath || path(),
|
|
914
903
|
reason
|
|
915
904
|
});
|
|
916
905
|
};
|
|
917
|
-
const
|
|
906
|
+
const evaluateIdle = () => {
|
|
918
907
|
if (document.visibilityState !== "visible") return;
|
|
919
908
|
if (Date.now() - state.lastActivityAt >= DWELL_ACTIVITY_IDLE_MS) {
|
|
920
909
|
freezeActivityIdle();
|
|
921
|
-
return;
|
|
922
910
|
}
|
|
923
|
-
emitDwell("milestone", false);
|
|
924
911
|
};
|
|
925
|
-
this._emitPageDwell = (
|
|
912
|
+
this._emitPageDwell = () => emitDwell("route");
|
|
926
913
|
const onVisibility = () => {
|
|
927
914
|
if (document.visibilityState === "visible") {
|
|
928
915
|
const idleMs = state.hiddenAt != null ? Date.now() - state.hiddenAt : 0;
|
|
929
916
|
state.hiddenAt = null;
|
|
930
917
|
if (idleMs >= SESSION_IDLE_GAP_MS) {
|
|
918
|
+
emitDwell("idle-resume");
|
|
931
919
|
this.resetEngagementQuiet();
|
|
932
920
|
const resumePath = path();
|
|
933
921
|
this.page(resumePath, { resumed: true });
|
|
@@ -944,14 +932,14 @@ var AmplifyUpSDK = class {
|
|
|
944
932
|
state.visibleSince = Date.now();
|
|
945
933
|
state.activityIdle = false;
|
|
946
934
|
} else {
|
|
947
|
-
|
|
935
|
+
accumulateVisible();
|
|
948
936
|
state.hiddenAt = Date.now();
|
|
949
937
|
state.visibleSince = null;
|
|
950
938
|
state.activityIdle = false;
|
|
951
939
|
}
|
|
952
940
|
};
|
|
953
941
|
const onPageHide = () => {
|
|
954
|
-
emitDwell("unload"
|
|
942
|
+
emitDwell("unload");
|
|
955
943
|
if (state.hiddenAt == null) {
|
|
956
944
|
state.hiddenAt = Date.now();
|
|
957
945
|
}
|
|
@@ -972,10 +960,10 @@ var AmplifyUpSDK = class {
|
|
|
972
960
|
window.addEventListener(evt, onActivity, { passive: true });
|
|
973
961
|
}
|
|
974
962
|
checkScroll();
|
|
975
|
-
const
|
|
976
|
-
|
|
963
|
+
const idlePoll = setInterval(() => {
|
|
964
|
+
evaluateIdle();
|
|
977
965
|
}, DWELL_POLL_MS);
|
|
978
|
-
this.trackingIntervals.push(
|
|
966
|
+
this.trackingIntervals.push(idlePoll);
|
|
979
967
|
const previousCleanup = this.trackingCleanup;
|
|
980
968
|
this.trackingCleanup = () => {
|
|
981
969
|
window.removeEventListener("scroll", onScroll);
|
|
@@ -1003,12 +991,12 @@ var AmplifyUpSDK = class {
|
|
|
1003
991
|
emit?.(true);
|
|
1004
992
|
this.resetEngagementQuiet();
|
|
1005
993
|
}
|
|
1006
|
-
/** Reset dwell/scroll state without emitting (idle resume already flushed
|
|
994
|
+
/** Reset dwell/scroll state without emitting (idle resume already flushed). */
|
|
1007
995
|
resetEngagementQuiet() {
|
|
1008
996
|
const state = this.pageEngagementState;
|
|
1009
997
|
state.reached = /* @__PURE__ */ new Set();
|
|
1010
998
|
state.visibleMs = 0;
|
|
1011
|
-
state.
|
|
999
|
+
state.dwellEmitted = false;
|
|
1012
1000
|
state.hiddenAt = null;
|
|
1013
1001
|
state.lastActivityAt = Date.now();
|
|
1014
1002
|
state.activityIdle = false;
|
|
@@ -1786,6 +1774,12 @@ Available Console Commands:
|
|
|
1786
1774
|
return;
|
|
1787
1775
|
}
|
|
1788
1776
|
try {
|
|
1777
|
+
if (event.data?.type === "AMPLIFYUP_FIELD_PATCH") {
|
|
1778
|
+
window.dispatchEvent(
|
|
1779
|
+
new CustomEvent("amplifyup:field-patch", { detail: event.data })
|
|
1780
|
+
);
|
|
1781
|
+
return;
|
|
1782
|
+
}
|
|
1789
1783
|
if (event.data?.type === "COMPONENT_DELETABLE_STATUS") {
|
|
1790
1784
|
const { componentId, deletable, nodeId } = event.data;
|
|
1791
1785
|
const element = document.querySelector(`[data-component-id="${componentId}"]`);
|
|
@@ -1972,6 +1966,10 @@ Available Console Commands:
|
|
|
1972
1966
|
setEventSelectionMode(enabled) {
|
|
1973
1967
|
if (typeof document === "undefined") return;
|
|
1974
1968
|
this.eventSelectionMode = enabled;
|
|
1969
|
+
if (typeof window !== "undefined") {
|
|
1970
|
+
window.__AMPLIFYUP_EVENT_SELECTION__ = enabled;
|
|
1971
|
+
window.dispatchEvent(new CustomEvent("amplifyup:composer-edit"));
|
|
1972
|
+
}
|
|
1975
1973
|
if (this.eventSelectionClickHandler) {
|
|
1976
1974
|
document.removeEventListener("click", this.eventSelectionClickHandler, true);
|
|
1977
1975
|
this.eventSelectionClickHandler = null;
|
|
@@ -2209,6 +2207,14 @@ Available Console Commands:
|
|
|
2209
2207
|
el.classList.add("amplifyup-selected");
|
|
2210
2208
|
}
|
|
2211
2209
|
});
|
|
2210
|
+
if (typeof window !== "undefined") {
|
|
2211
|
+
window.__AMPLIFYUP_COMPOSER_EDIT__ = highlightComponents;
|
|
2212
|
+
window.dispatchEvent(
|
|
2213
|
+
new CustomEvent("amplifyup:composer-edit", {
|
|
2214
|
+
detail: { enabled: highlightComponents }
|
|
2215
|
+
})
|
|
2216
|
+
);
|
|
2217
|
+
}
|
|
2212
2218
|
}
|
|
2213
2219
|
/** Document-level drag/drop for cross-iframe drags from Composer sidebar. */
|
|
2214
2220
|
setupComposerDragDrop() {
|
|
@@ -2517,6 +2523,12 @@ Available Console Commands:
|
|
|
2517
2523
|
const clearSelection = opts?.clearSelection !== false;
|
|
2518
2524
|
this.highlightingEnabled = false;
|
|
2519
2525
|
this.teardownComposerDragDrop();
|
|
2526
|
+
if (opts?.clearSelection !== false && typeof window !== "undefined") {
|
|
2527
|
+
window.__AMPLIFYUP_COMPOSER_EDIT__ = false;
|
|
2528
|
+
window.dispatchEvent(
|
|
2529
|
+
new CustomEvent("amplifyup:composer-edit", { detail: { enabled: false } })
|
|
2530
|
+
);
|
|
2531
|
+
}
|
|
2520
2532
|
if (this.mutationObserver) {
|
|
2521
2533
|
this.mutationObserver.disconnect();
|
|
2522
2534
|
this.mutationObserver = null;
|
|
@@ -2763,8 +2775,6 @@ var index_default = getSDK();
|
|
|
2763
2775
|
|
|
2764
2776
|
exports.AmplifyUpSDK = AmplifyUpSDK;
|
|
2765
2777
|
exports.DWELL_ACTIVITY_IDLE_MS = DWELL_ACTIVITY_IDLE_MS;
|
|
2766
|
-
exports.DWELL_CHECKPOINT_SEC = DWELL_CHECKPOINT_SEC;
|
|
2767
|
-
exports.DWELL_MILESTONES_SEC = DWELL_MILESTONES_SEC;
|
|
2768
2778
|
exports.EdgeResolveError = EdgeResolveError;
|
|
2769
2779
|
exports.SESSION_IDLE_GAP_MS = SESSION_IDLE_GAP_MS;
|
|
2770
2780
|
exports.buildLayoutProviderUrl = buildLayoutProviderUrl;
|