@tokenoftrust/storefront-runner 2.2.5 → 2.2.7
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.7",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"description": "World-shareable storefront runner: multi-tenant renderer on Astro/Cloudflare. No control plane.",
|
|
6
6
|
"packageManager": "pnpm@11.9.0",
|
|
@@ -51,6 +51,8 @@ export interface AmplitudeHttpEvent {
|
|
|
51
51
|
event_type: "page_view" | (typeof APPROVED_MARKETING_ACTION_NAMES)[number];
|
|
52
52
|
device_id: typeof ANONYMOUS_DEVICE_ID;
|
|
53
53
|
insert_id: string;
|
|
54
|
+
/** Occurrence time, epoch milliseconds. */
|
|
55
|
+
time: number;
|
|
54
56
|
event_properties: GovernedEventProperties & { page_path?: string };
|
|
55
57
|
}
|
|
56
58
|
|
|
@@ -108,6 +110,12 @@ function isSafePagePath(value: unknown): value is string {
|
|
|
108
110
|
!resemblesManagedAnalyticsPii(value);
|
|
109
111
|
}
|
|
110
112
|
|
|
113
|
+
/** Epoch ms as hex digits mapped to a-p, so the id carries no digit run the PII heuristic could flag. */
|
|
114
|
+
function opaqueEventTime(epochMs: number): string {
|
|
115
|
+
return Math.max(0, Math.trunc(epochMs)).toString(16)
|
|
116
|
+
.replace(/[0-9a-f]/g, (digit) => String.fromCharCode(97 + parseInt(digit, 16)));
|
|
117
|
+
}
|
|
118
|
+
|
|
111
119
|
/**
|
|
112
120
|
* Reduce a broker event to the complete Amplitude allowlist. Returning null is
|
|
113
121
|
* fail-closed for unknown events, invalid/extra data, consent loss, environment
|
|
@@ -136,9 +144,16 @@ export function mapCommerceEventToAmplitude(
|
|
|
136
144
|
const governed = buildGovernedEventProperties(environmentResult.value, tenantPublicId);
|
|
137
145
|
if (!governed) return null;
|
|
138
146
|
|
|
147
|
+
// The logical id is shared by every visitor and page of a release, and Amplitude drops
|
|
148
|
+
// any later event with the same device_id + insert_id for 7 days while still answering
|
|
149
|
+
// 200. The occurrence time makes each occurrence distinct; a re-delivery of the same
|
|
150
|
+
// occurrence carries the same time and so still deduplicates.
|
|
151
|
+
const time = Date.parse(event.time);
|
|
152
|
+
if (!Number.isFinite(time)) return null;
|
|
139
153
|
const base = {
|
|
140
154
|
device_id: ANONYMOUS_DEVICE_ID,
|
|
141
|
-
insert_id: eventDedupeKey(event)
|
|
155
|
+
insert_id: `${eventDedupeKey(event)}-${opaqueEventTime(time)}`,
|
|
156
|
+
time,
|
|
142
157
|
};
|
|
143
158
|
if (event.type === "storefront.action.activated.v1") {
|
|
144
159
|
const name = event.data["name"];
|