@syntrologie/runtime-sdk 2.8.0-canary.186 → 2.8.0-canary.187
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/index.js +48 -1
- package/dist/index.js.map +2 -2
- package/dist/platform/ShopifyPixelBridge.d.ts +39 -15
- package/dist/platform/shopify-cookie-contract.d.ts +12 -0
- package/dist/shopify-pixel-entry.d.ts +23 -4
- package/dist/shopify-pixel.js +19 -3
- package/dist/shopify-pixel.js.map +2 -2
- package/dist/shopify-pixel.min.js +1 -1
- package/dist/shopify-pixel.min.js.map +3 -3
- package/dist/smart-canvas.esm.js +50 -50
- package/dist/smart-canvas.esm.js.map +3 -3
- package/dist/smart-canvas.js +49 -2
- package/dist/smart-canvas.js.map +2 -2
- package/dist/smart-canvas.min.js +50 -50
- package/dist/smart-canvas.min.js.map +3 -3
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9577,7 +9577,7 @@ function error(prefix, message, data) {
|
|
|
9577
9577
|
}
|
|
9578
9578
|
|
|
9579
9579
|
// src/version.ts
|
|
9580
|
-
var SDK_VERSION = "2.8.0-canary.
|
|
9580
|
+
var SDK_VERSION = "2.8.0-canary.187";
|
|
9581
9581
|
|
|
9582
9582
|
// src/types.ts
|
|
9583
9583
|
var SDK_SCHEMA_VERSION = "2.0";
|
|
@@ -15231,6 +15231,11 @@ function detectPlatform() {
|
|
|
15231
15231
|
// src/platform/shopify-cookie-contract.ts
|
|
15232
15232
|
var COOKIE_NAME = "syntro_experiments";
|
|
15233
15233
|
var COOKIE_VERSION = 1;
|
|
15234
|
+
var CART_ATTRIBUTE_KEY = {
|
|
15235
|
+
distinctId: "_syntro_distinct_id",
|
|
15236
|
+
telemetryHost: "_syntro_telemetry_host",
|
|
15237
|
+
telemetryKey: "_syntro_telemetry_key"
|
|
15238
|
+
};
|
|
15234
15239
|
|
|
15235
15240
|
// src/platform/ShopifyPixelBridge.ts
|
|
15236
15241
|
var MAX_AGE_SECONDS = 30 * 24 * 60 * 60;
|
|
@@ -15239,12 +15244,14 @@ var ShopifyPixelBridge = class {
|
|
|
15239
15244
|
__publicField(this, "context");
|
|
15240
15245
|
this.context = { ...context, telemetryHost: context.telemetryHost.replace(/\/$/, "") };
|
|
15241
15246
|
this.writeCookie();
|
|
15247
|
+
this.writeCartAttributes();
|
|
15242
15248
|
}
|
|
15243
15249
|
/** Update the telemetry context (e.g., after consent is granted and
|
|
15244
15250
|
* PostHog finally initializes and a real distinct_id becomes available). */
|
|
15245
15251
|
updateContext(context) {
|
|
15246
15252
|
this.context = { ...context, telemetryHost: context.telemetryHost.replace(/\/$/, "") };
|
|
15247
15253
|
this.writeCookie();
|
|
15254
|
+
this.writeCartAttributes();
|
|
15248
15255
|
}
|
|
15249
15256
|
destroy() {
|
|
15250
15257
|
document.cookie = `${COOKIE_NAME}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; SameSite=Lax`;
|
|
@@ -15260,6 +15267,46 @@ var ShopifyPixelBridge = class {
|
|
|
15260
15267
|
const cookieString = `${COOKIE_NAME}=${value}; max-age=${MAX_AGE_SECONDS}; path=/; SameSite=Lax`;
|
|
15261
15268
|
document.cookie = cookieString;
|
|
15262
15269
|
}
|
|
15270
|
+
/**
|
|
15271
|
+
* Mirror identity into Shopify cart attributes. The Web Pixel reads these
|
|
15272
|
+
* from `event.data.checkout.attributes` on `checkout_completed`, which is
|
|
15273
|
+
* the only context that survives every checkout topology Shopify supports
|
|
15274
|
+
* (one-page checkout, Shop Pay, accelerated wallets).
|
|
15275
|
+
*
|
|
15276
|
+
* Best-effort: Cart Ajax API isn't available outside an online-store-2.0
|
|
15277
|
+
* storefront and may 404 in test harnesses or non-Shopify hosts. A failure
|
|
15278
|
+
* here must not break the storefront SDK's other work — the cookie path
|
|
15279
|
+
* still covers the storefront-side `product_added_to_cart` event.
|
|
15280
|
+
*/
|
|
15281
|
+
writeCartAttributes() {
|
|
15282
|
+
const { distinctId, telemetryHost, telemetryKey } = this.context;
|
|
15283
|
+
if (!distinctId) return;
|
|
15284
|
+
const attributes = {};
|
|
15285
|
+
attributes[CART_ATTRIBUTE_KEY.distinctId] = distinctId;
|
|
15286
|
+
attributes[CART_ATTRIBUTE_KEY.telemetryHost] = telemetryHost;
|
|
15287
|
+
attributes[CART_ATTRIBUTE_KEY.telemetryKey] = telemetryKey;
|
|
15288
|
+
const body = JSON.stringify({ attributes });
|
|
15289
|
+
try {
|
|
15290
|
+
void fetch("/cart/update.js", {
|
|
15291
|
+
method: "POST",
|
|
15292
|
+
headers: { "Content-Type": "application/json", Accept: "application/json" },
|
|
15293
|
+
credentials: "same-origin",
|
|
15294
|
+
body
|
|
15295
|
+
}).then((response) => {
|
|
15296
|
+
if (!response.ok) {
|
|
15297
|
+
console.warn(
|
|
15298
|
+
`[shopify-pixel-bridge] /cart/update.js returned ${response.status}; checkout_completed events will fall back to cookie (likely to drop).`
|
|
15299
|
+
);
|
|
15300
|
+
}
|
|
15301
|
+
}).catch((err) => {
|
|
15302
|
+
console.warn(
|
|
15303
|
+
"[shopify-pixel-bridge] /cart/update.js request failed; checkout_completed events will fall back to cookie (likely to drop).",
|
|
15304
|
+
err
|
|
15305
|
+
);
|
|
15306
|
+
});
|
|
15307
|
+
} catch {
|
|
15308
|
+
}
|
|
15309
|
+
}
|
|
15263
15310
|
};
|
|
15264
15311
|
|
|
15265
15312
|
// src/context/ContextManager.ts
|