@zonos/elements 1.3.261 → 1.3.262
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/cjs/index.cjs.js +12 -9
- package/dist/cjs/{paypal-73a542cb.js → paypal-e278f405.js} +140 -6
- package/dist/cjs/submitGtag-4241212b.js +167 -0
- package/dist/cjs/zonos-card_5.cjs.entry.js +2 -2
- package/dist/cjs/zonos-cart-items_12.cjs.entry.js +30 -21
- package/dist/cjs/zonos-checkout.cjs.entry.js +7 -7
- package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +8 -8
- package/dist/cjs/zonos-collect.cjs.entry.js +2 -2
- package/dist/cjs/zonos-controller.cjs.entry.js +3 -3
- package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +8 -8
- package/dist/cjs/zonos-invoice.cjs.entry.js +2 -2
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +12 -12
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-payment/zonos-checkout-payment.css +7 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-payment/zonos-checkout-payment.js +7 -3
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +6 -6
- package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.css +7 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.js +5 -1
- package/dist/collection/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.css +7 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.js +6 -3
- package/dist/collection/components/checkout/zonos-collect/zonos-collect-finish/zonos-collect-finish.js +6 -6
- package/dist/collection/components/checkout/zonos-collect/zonos-collect-payment/zonos-collect-payment.js +2 -2
- package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-finish/zonos-invoice-finish.js +6 -6
- package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-payment/zonos-invoice-payment.js +2 -2
- package/dist/collection/components/main/zonos-controller.js +2 -2
- package/dist/collection/components/store/checkout/paypal.js +4 -4
- package/dist/collection/components/utils/analytics/analyticsRelayState.js +112 -0
- package/dist/collection/components/utils/analytics/mapToFbEvent.js +66 -0
- package/dist/collection/components/utils/submitAnalytics.js +16 -0
- package/dist/collection/components/utils/submitFbq.js +56 -0
- package/dist/collection/components/utils/submitGtag.js +15 -78
- package/dist/collection/scripts/_zonosBase.js +5 -2
- package/dist/collection/types/analyticsRelay.js +2 -2
- package/dist/esm/index.js +12 -9
- package/dist/esm/{paypal-38ca5d21.js → paypal-d8804da5.js} +142 -9
- package/dist/esm/submitGtag-7f5c5bb5.js +162 -0
- package/dist/esm/zonos-card_5.entry.js +2 -2
- package/dist/esm/zonos-cart-items_12.entry.js +30 -21
- package/dist/esm/zonos-checkout.entry.js +7 -7
- package/dist/esm/zonos-collect-finish_6.entry.js +8 -8
- package/dist/esm/zonos-collect.entry.js +2 -2
- package/dist/esm/zonos-controller.entry.js +3 -3
- package/dist/esm/zonos-invoice-finish_5.entry.js +8 -8
- package/dist/esm/zonos-invoice.entry.js +2 -2
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/paypal-d8804da5.js +17 -0
- package/dist/esm-es5/submitGtag-7f5c5bb5.js +1 -0
- package/dist/esm-es5/zonos-card_5.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_12.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
- package/dist/esm-es5/zonos-collect.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice-finish_5.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice.entry.js +1 -1
- package/dist/scripts/analyticsRelayOnInit.js +1 -1
- package/dist/scripts/index.d.ts +11 -0
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/types/components/utils/analytics/analyticsRelayState.d.ts +43 -0
- package/dist/types/components/utils/analytics/mapToFbEvent.d.ts +11 -0
- package/dist/types/components/utils/submitAnalytics.d.ts +12 -0
- package/dist/types/components/utils/submitFbq.d.ts +14 -0
- package/dist/types/components/utils/submitGtag.d.ts +4 -9
- package/dist/types/scripts/_zonosBase.d.ts +11 -0
- package/dist/types/types/analyticsRelay.d.ts +19 -3
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/p-022ddd4a.system.entry.js +1 -0
- package/dist/zonos-elements/{p-6726fee0.entry.js → p-06ef4d79.entry.js} +1 -1
- package/dist/zonos-elements/p-29b60bf3.system.js +1 -1
- package/dist/zonos-elements/{p-e684e68f.entry.js → p-3deb91cb.entry.js} +1 -1
- package/dist/zonos-elements/{p-eca03303.system.entry.js → p-56c11359.system.entry.js} +1 -1
- package/dist/zonos-elements/p-5dd78b4b.js +1 -0
- package/dist/zonos-elements/{p-d2ef0416.system.entry.js → p-66934a78.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-e14f421d.system.entry.js → p-7237f43b.system.entry.js} +1 -1
- package/dist/zonos-elements/p-72a181b5.entry.js +1 -0
- package/dist/zonos-elements/p-75a27c68.entry.js +1 -0
- package/dist/zonos-elements/{p-3c3139d2.system.entry.js → p-7df3e44b.system.entry.js} +1 -1
- package/dist/zonos-elements/p-838e335c.entry.js +1 -0
- package/dist/zonos-elements/p-947f5092.js +17 -0
- package/dist/zonos-elements/{p-1917202e.system.entry.js → p-9de27162.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-be1032ab.system.entry.js → p-a2b3c1ef.system.entry.js} +1 -1
- package/dist/zonos-elements/p-a98b8b68.system.js +18 -0
- package/dist/zonos-elements/p-ca411d97.entry.js +1 -0
- package/dist/zonos-elements/p-cab6bd98.system.js +1 -0
- package/dist/zonos-elements/p-dee6adff.system.js +1 -0
- package/dist/zonos-elements/{p-2c9714e8.system.entry.js → p-e36e724b.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-8df3c6a0.entry.js → p-e673a4d9.entry.js} +1 -1
- package/dist/zonos-elements/{p-7793d334.entry.js → p-f2909fb8.entry.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/submitGtag-9ac5a42e.js +0 -116
- package/dist/esm/submitGtag-543058f9.js +0 -113
- package/dist/esm-es5/paypal-38ca5d21.js +0 -17
- package/dist/esm-es5/submitGtag-543058f9.js +0 -1
- package/dist/zonos-elements/p-03e53ef5.entry.js +0 -1
- package/dist/zonos-elements/p-17a8a514.system.js +0 -1
- package/dist/zonos-elements/p-24407504.js +0 -17
- package/dist/zonos-elements/p-31bd3851.system.js +0 -1
- package/dist/zonos-elements/p-387f6a4d.js +0 -1
- package/dist/zonos-elements/p-47bde0ba.system.js +0 -18
- package/dist/zonos-elements/p-5dff9d51.system.entry.js +0 -1
- package/dist/zonos-elements/p-9cfd1dc3.entry.js +0 -1
- package/dist/zonos-elements/p-eeff2b04.entry.js +0 -1
- package/dist/zonos-elements/p-f4030586.entry.js +0 -1
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -133,7 +133,7 @@ const getZonosQaUrl = () => {
|
|
|
133
133
|
return null;
|
|
134
134
|
}
|
|
135
135
|
const qaUrl = extractZonosQaUrl(window.location.href);
|
|
136
|
-
const cdnUrl = "https://v1.3.
|
|
136
|
+
const cdnUrl = "https://v1.3.262.js.zonos.com";
|
|
137
137
|
// when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
|
|
138
138
|
if (!qaUrl &&
|
|
139
139
|
(cdnUrl.includes('test.') ||
|
|
@@ -381,10 +381,10 @@ const zonosLoadUrl = (() => {
|
|
|
381
381
|
return null;
|
|
382
382
|
})();
|
|
383
383
|
const startLoadTime = Date.now();
|
|
384
|
-
const ZONOS_URL = "https://v1.3.
|
|
385
|
-
const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.
|
|
386
|
-
const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.
|
|
387
|
-
const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.
|
|
384
|
+
const ZONOS_URL = "https://v1.3.262.js.zonos.com";
|
|
385
|
+
const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.262";
|
|
386
|
+
const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.262";
|
|
387
|
+
const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.262";
|
|
388
388
|
const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
|
|
389
389
|
const GOOGLE_FONT_REGEX = /^https:\/\/fonts\.googleapis\.com/;
|
|
390
390
|
class Zonos {
|
|
@@ -402,10 +402,12 @@ Zonos.iframeLogType = typeof window !== 'undefined'
|
|
|
402
402
|
? new URLSearchParams(window.location.search).get('iframeLogType')
|
|
403
403
|
: null;
|
|
404
404
|
Zonos.isBigCommerce = false;
|
|
405
|
-
Zonos.releaseDate = "
|
|
405
|
+
Zonos.releaseDate = "1777585626922";
|
|
406
406
|
Zonos.isLegacyCheckout = false;
|
|
407
407
|
Zonos.googleAnalyticId = null;
|
|
408
408
|
Zonos.googleAnalyticReady = false;
|
|
409
|
+
Zonos.facebookPixelId = null;
|
|
410
|
+
Zonos.facebookPixelReady = false;
|
|
409
411
|
Zonos.startLoadTime = startLoadTime;
|
|
410
412
|
Zonos.domain = typeof window !== 'undefined'
|
|
411
413
|
? // domain that embeds the iframe
|
|
@@ -425,7 +427,7 @@ Zonos.isNpm = true;
|
|
|
425
427
|
Zonos.zonosQaUrl = null;
|
|
426
428
|
Zonos.zonosQaUrlApi = null;
|
|
427
429
|
Zonos.trackEventLogs = [];
|
|
428
|
-
Zonos.version = `v${"1.3.
|
|
430
|
+
Zonos.version = `v${"1.3.262"}`;
|
|
429
431
|
Zonos.modeAlerted = false;
|
|
430
432
|
Zonos.cartData = null;
|
|
431
433
|
Zonos.paypal = null;
|
|
@@ -445,9 +447,10 @@ Zonos.init = async (params) => {
|
|
|
445
447
|
VarianceTest.log(`====== ZONOS DEBUG MODE: on (${_a.version}) ======`);
|
|
446
448
|
_a.zonosApiKey = zonosApiKey;
|
|
447
449
|
_a.storeId = storeId;
|
|
448
|
-
// When not in iframe,
|
|
450
|
+
// When not in iframe, providers are ready (gtag/fbq work directly). When in iframe, relay sets these after parent configures.
|
|
449
451
|
if (typeof window !== 'undefined' && window.parent === window) {
|
|
450
452
|
_a.googleAnalyticReady = true;
|
|
453
|
+
_a.facebookPixelReady = true;
|
|
451
454
|
}
|
|
452
455
|
if (_a.isNpm) {
|
|
453
456
|
VarianceTest.log('====== ZONOS LOADING FROM NPM ======');
|
|
@@ -553,7 +556,7 @@ Zonos.injectCustomScriptForHostedCheckout = () => {
|
|
|
553
556
|
const metadata = (cartData === null || cartData === void 0 ? void 0 : cartData.metadata) || [];
|
|
554
557
|
const headerScript = metadata.find(meta => meta.key === 'customHeaderScript');
|
|
555
558
|
const footerScript = metadata.find(meta => meta.key === 'customFooterScript');
|
|
556
|
-
// googleAnalyticId
|
|
559
|
+
// googleAnalyticId / facebookPixelId are set by customHTML in checkoutSettings (e.g. <script>window.Zonos.googleAnalyticId = "G-XXX"; window.Zonos.facebookPixelId = "1234567890";</script>), injected by zonos-controller
|
|
557
560
|
// Only inject the script if checkout is on Zonos hosted checkout and custom script is available
|
|
558
561
|
if (!window.Zonos.isLegacyCheckout || (!headerScript && !footerScript)) {
|
|
559
562
|
VarianceTest.log('Skip injecting custom script for hosted checkout', 'info', {
|
|
@@ -6,7 +6,7 @@ const localization = require('./localization-a7fac4b4.js');
|
|
|
6
6
|
const handleFetch = require('./handleFetch-954f30e1.js');
|
|
7
7
|
const isContrastColor = require('./isContrastColor-6a17f408.js');
|
|
8
8
|
const VarianceTest = require('./VarianceTest-bec00ea8.js');
|
|
9
|
-
const submitGtag = require('./submitGtag-
|
|
9
|
+
const submitGtag = require('./submitGtag-4241212b.js');
|
|
10
10
|
|
|
11
11
|
/*!
|
|
12
12
|
* paypal-js v8.4.2 (2025-09-04T17:21:30.135Z)
|
|
@@ -41,7 +41,7 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
41
41
|
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
function __rest(s, e) {
|
|
44
|
+
function __rest$1(s, e) {
|
|
45
45
|
var t = {};
|
|
46
46
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
47
47
|
t[p] = s[p];
|
|
@@ -88,7 +88,7 @@ function insertScriptElement(_a) {
|
|
|
88
88
|
document.head.insertBefore(newScript, document.head.firstElementChild);
|
|
89
89
|
}
|
|
90
90
|
function processOptions(_a) {
|
|
91
|
-
var customSdkBaseUrl = _a.sdkBaseUrl, environment = _a.environment, options = __rest(_a, ["sdkBaseUrl", "environment"]);
|
|
91
|
+
var customSdkBaseUrl = _a.sdkBaseUrl, environment = _a.environment, options = __rest$1(_a, ["sdkBaseUrl", "environment"]);
|
|
92
92
|
var sdkBaseUrl = customSdkBaseUrl || processSdkBaseUrl(environment);
|
|
93
93
|
var optionsWithStringIndex = options;
|
|
94
94
|
var _b = Object.keys(optionsWithStringIndex)
|
|
@@ -258,6 +258,139 @@ const paypalCreateOrder = async ({ checkoutSessionId, intent, }) => {
|
|
|
258
258
|
return { errors, json };
|
|
259
259
|
};
|
|
260
260
|
|
|
261
|
+
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
262
|
+
var t = {};
|
|
263
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
264
|
+
t[p] = s[p];
|
|
265
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
266
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
267
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
268
|
+
t[p[i]] = s[p[i]];
|
|
269
|
+
}
|
|
270
|
+
return t;
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* Mapping from our internal event names (GA-style) to Facebook Pixel standard event names.
|
|
274
|
+
* @see https://developers.facebook.com/docs/meta-pixel/reference#standard-events
|
|
275
|
+
*
|
|
276
|
+
* Events without an entry have no FB standard equivalent — they are still fired as a custom event
|
|
277
|
+
* via `fbq('trackCustom', ...)` so merchants can target them.
|
|
278
|
+
*/
|
|
279
|
+
const FB_STANDARD_EVENT_BY_INTERNAL_EVENT = {
|
|
280
|
+
purchase: 'Purchase',
|
|
281
|
+
'zonos-checkout-payment-info': 'AddPaymentInfo',
|
|
282
|
+
'zonos-checkout-start': 'InitiateCheckout',
|
|
283
|
+
};
|
|
284
|
+
const getFbStandardEventName = (event) => { var _a; return (_a = FB_STANDARD_EVENT_BY_INTERNAL_EVENT[event]) !== null && _a !== void 0 ? _a : null; };
|
|
285
|
+
const isPurchaseMetadata = (metadata) => {
|
|
286
|
+
if (!metadata)
|
|
287
|
+
return false;
|
|
288
|
+
return Array.isArray(metadata.items);
|
|
289
|
+
};
|
|
290
|
+
/**
|
|
291
|
+
* Convert a GA-style event payload into a Facebook Pixel parameter object.
|
|
292
|
+
*
|
|
293
|
+
* GA `items: [{ item_id, item_name, price, quantity }]` is converted into FB's
|
|
294
|
+
* `contents: [{ id, quantity, item_price }]` with derived `content_ids`, `num_items`,
|
|
295
|
+
* and `content_type: 'product'`. Other primitive params (e.g. `checkoutSessionId`,
|
|
296
|
+
* `paymentMethod`, `serviceLevelId`) are forwarded as-is so merchants can build
|
|
297
|
+
* custom audiences on them.
|
|
298
|
+
*/
|
|
299
|
+
const buildFbqParams = (metadata) => {
|
|
300
|
+
if (!metadata)
|
|
301
|
+
return {};
|
|
302
|
+
if (!isPurchaseMetadata(metadata)) {
|
|
303
|
+
// Forward primitive metadata as-is for custom events
|
|
304
|
+
return Object.assign({}, metadata);
|
|
305
|
+
}
|
|
306
|
+
const { currency, items, transaction_id, value } = metadata, rest = __rest(metadata, ["currency", "items", "transaction_id", "value"]);
|
|
307
|
+
const contents = items.map(item => ({
|
|
308
|
+
id: item.item_id,
|
|
309
|
+
item_price: item.price,
|
|
310
|
+
quantity: item.quantity,
|
|
311
|
+
}));
|
|
312
|
+
const contentIds = items.map(item => item.item_id);
|
|
313
|
+
const numItems = items.reduce((acc, item) => acc + item.quantity, 0);
|
|
314
|
+
const params = Object.assign(Object.assign({}, rest), { content_ids: contentIds, content_type: 'product', contents, num_items: numItems });
|
|
315
|
+
if (transaction_id) {
|
|
316
|
+
params.order_id = transaction_id;
|
|
317
|
+
}
|
|
318
|
+
if (currency !== undefined) {
|
|
319
|
+
params.currency = currency;
|
|
320
|
+
}
|
|
321
|
+
if (value !== undefined) {
|
|
322
|
+
params.value = value;
|
|
323
|
+
}
|
|
324
|
+
return params;
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
const isFacebookPixelEnabled = () => {
|
|
328
|
+
const provider = zonosStore.zonosStore.checkoutSettings.analyticsProviders.find(item => item.type === 'FACEBOOK_PIXEL');
|
|
329
|
+
return !!provider && provider.status === 'ENABLED';
|
|
330
|
+
};
|
|
331
|
+
const fireFbq = (mode, event, params) => {
|
|
332
|
+
if (submitGtag.isAnalyticsRelayInIframe()) {
|
|
333
|
+
// fbq does not work in the iframe (Facebook Pixel must be on the parent for proper attribution).
|
|
334
|
+
// Relay to parent which will call fbq() once the FB Pixel script is ready.
|
|
335
|
+
submitGtag.enqueueRelayEvent({
|
|
336
|
+
event,
|
|
337
|
+
fbqMode: mode,
|
|
338
|
+
payload: params,
|
|
339
|
+
provider: 'fbq',
|
|
340
|
+
});
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
if (typeof window.fbq === 'function') {
|
|
344
|
+
VarianceTest.log('Zonos submits fbq event', 'log', `${mode}:${event}`);
|
|
345
|
+
window.fbq(mode, event, params);
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
/**
|
|
349
|
+
* Submit a Facebook Pixel event matching the gtag event payload shape.
|
|
350
|
+
*
|
|
351
|
+
* Behavior:
|
|
352
|
+
* - Always fires `fbq('trackCustom', event, params)` so merchants see `zonos-xxx` events.
|
|
353
|
+
* - If the event has a Facebook standard equivalent (e.g. `purchase` → `Purchase`,
|
|
354
|
+
* `zonos-checkout-start` → `InitiateCheckout`, `zonos-checkout-payment-info` →
|
|
355
|
+
* `AddPaymentInfo`), additionally fires `fbq('track', standardEvent, params)` with
|
|
356
|
+
* FB-formatted parameters.
|
|
357
|
+
*
|
|
358
|
+
* @see https://developers.facebook.com/docs/meta-pixel/reference
|
|
359
|
+
*/
|
|
360
|
+
const submitFbq = ({ event, metadata }) => {
|
|
361
|
+
if (!isFacebookPixelEnabled()) {
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
const isTestMode = handleFetch.getIsTestMode();
|
|
365
|
+
const baseParams = buildFbqParams(metadata);
|
|
366
|
+
const params = Object.assign(Object.assign({}, baseParams), (isTestMode && { isTestMode: true }));
|
|
367
|
+
// filter null values
|
|
368
|
+
const filteredParams = Object.fromEntries(Object.entries(params).filter(([_, value]) => value !== null));
|
|
369
|
+
// 1) Always emit the original event as a custom event so merchants can target zonos-xxx names.
|
|
370
|
+
fireFbq('trackCustom', event, filteredParams);
|
|
371
|
+
// 2) Emit FB standard equivalent if one exists. Skipped when the event itself is the standard
|
|
372
|
+
// name to avoid double-firing (e.g. 'purchase' -> 'Purchase').
|
|
373
|
+
const fbStandardEvent = getFbStandardEventName(event);
|
|
374
|
+
if (fbStandardEvent && fbStandardEvent !== event) {
|
|
375
|
+
fireFbq('track', fbStandardEvent, filteredParams);
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Fan out an analytics event to every enabled provider.
|
|
381
|
+
*
|
|
382
|
+
* - Calls `submitGtag` (Google Analytics) — always sends the original event name.
|
|
383
|
+
* - Calls `submitFbq` (Facebook Pixel) — sends the original event name as a custom event,
|
|
384
|
+
* and additionally fires the matching FB standard event when one exists
|
|
385
|
+
* (e.g. `purchase` → `Purchase`, `zonos-checkout-start` → `InitiateCheckout`).
|
|
386
|
+
*
|
|
387
|
+
* Each submitter no-ops when its provider is disabled in `analyticsProviders` settings.
|
|
388
|
+
*/
|
|
389
|
+
const submitAnalytics = (input) => {
|
|
390
|
+
submitGtag.submitGtag(input);
|
|
391
|
+
submitFbq(input);
|
|
392
|
+
};
|
|
393
|
+
|
|
261
394
|
const { onChange: paypalStoreOnChange, reset: paypalStoreReset, state: paypalStore, } = zonosStore.createStore(() => ({
|
|
262
395
|
intent: 'capture',
|
|
263
396
|
orderIdCreated: null,
|
|
@@ -338,7 +471,7 @@ const paypalButtonOptions = ({ checkoutSessionId, onPaypalFail, onPaypalSessionD
|
|
|
338
471
|
// reset stripe error message
|
|
339
472
|
cart.stripeStore.hasPaymentError = false;
|
|
340
473
|
cart.stripeStore.customErrorMessage = null;
|
|
341
|
-
|
|
474
|
+
submitAnalytics({
|
|
342
475
|
event: 'zonos-checkout-payment-fail',
|
|
343
476
|
metadata: {
|
|
344
477
|
checkoutSessionId,
|
|
@@ -403,7 +536,7 @@ const paypalButtonOptions = ({ checkoutSessionId, onPaypalFail, onPaypalSessionD
|
|
|
403
536
|
// reset stripe error message
|
|
404
537
|
cart.stripeStore.hasPaymentError = false;
|
|
405
538
|
cart.stripeStore.customErrorMessage = null;
|
|
406
|
-
|
|
539
|
+
submitAnalytics({
|
|
407
540
|
event: 'zonos-checkout-payment-fail',
|
|
408
541
|
metadata: {
|
|
409
542
|
checkoutSessionId,
|
|
@@ -419,7 +552,7 @@ const paypalButtonOptions = ({ checkoutSessionId, onPaypalFail, onPaypalSessionD
|
|
|
419
552
|
// reset paypal error banner
|
|
420
553
|
paypalStore.paypalErrorMessage = null;
|
|
421
554
|
// submit google tag when the form is complete
|
|
422
|
-
|
|
555
|
+
submitAnalytics({
|
|
423
556
|
event: 'zonos-checkout-payment-info',
|
|
424
557
|
metadata: {
|
|
425
558
|
checkoutSessionId,
|
|
@@ -546,3 +679,4 @@ exports.paypalStoreHasPaypalEnabled = paypalStoreHasPaypalEnabled;
|
|
|
546
679
|
exports.paypalStoreInitButtons = paypalStoreInitButtons;
|
|
547
680
|
exports.paypalStoreOnChange = paypalStoreOnChange;
|
|
548
681
|
exports.paypalStoreReset = paypalStoreReset;
|
|
682
|
+
exports.submitAnalytics = submitAnalytics;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const zonosStore = require('./zonosStore-1c517e55.js');
|
|
4
|
+
const handleFetch = require('./handleFetch-954f30e1.js');
|
|
5
|
+
const VarianceTest = require('./VarianceTest-bec00ea8.js');
|
|
6
|
+
|
|
7
|
+
/** Message type for zonos-analytic events sent from iframe to parent. */
|
|
8
|
+
const ZONOS_ANALYTIC_TYPE = 'zonos-analytic';
|
|
9
|
+
/** Ping sent by iframe to configure parent's analytics relay (e.g. GA, FB Pixel) and get ready signal. */
|
|
10
|
+
const RELAY_PING_TYPE = 'zonos-analytics-relay-ping';
|
|
11
|
+
/** Response from parent when an analytics relay (e.g. gtag, fbq) is ready. */
|
|
12
|
+
const RELAY_READY_TYPE = 'zonos-analytics-relay-ready';
|
|
13
|
+
|
|
14
|
+
const providerReady = {
|
|
15
|
+
fbq: false,
|
|
16
|
+
gtag: false,
|
|
17
|
+
};
|
|
18
|
+
const queue = [];
|
|
19
|
+
let listenerAdded = false;
|
|
20
|
+
const isInIframe = () => typeof window !== 'undefined' && window.parent !== window;
|
|
21
|
+
const flushQueue = () => {
|
|
22
|
+
// Walk a copy and rebuild to keep events whose provider isn't ready yet
|
|
23
|
+
const remaining = [];
|
|
24
|
+
while (queue.length > 0) {
|
|
25
|
+
const event = queue.shift();
|
|
26
|
+
if (!providerReady[event.provider]) {
|
|
27
|
+
remaining.push(event);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
window.parent.postMessage({
|
|
32
|
+
event: event.event,
|
|
33
|
+
fbqMode: event.fbqMode,
|
|
34
|
+
metadata: event.payload,
|
|
35
|
+
provider: event.provider,
|
|
36
|
+
type: ZONOS_ANALYTIC_TYPE,
|
|
37
|
+
}, '*');
|
|
38
|
+
}
|
|
39
|
+
catch (_a) {
|
|
40
|
+
// Ignore postMessage failures
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
queue.push(...remaining);
|
|
44
|
+
};
|
|
45
|
+
const ensureListener = () => {
|
|
46
|
+
if (listenerAdded)
|
|
47
|
+
return;
|
|
48
|
+
listenerAdded = true;
|
|
49
|
+
window.addEventListener('message', (e) => {
|
|
50
|
+
var _a;
|
|
51
|
+
if (((_a = e.data) === null || _a === void 0 ? void 0 : _a.type) !== RELAY_READY_TYPE)
|
|
52
|
+
return;
|
|
53
|
+
// Older parent scripts may omit `provider`; treat as gtag for backward compatibility.
|
|
54
|
+
const provider = e.data.provider || 'gtag';
|
|
55
|
+
providerReady[provider] = true;
|
|
56
|
+
if (typeof window.Zonos !== 'undefined') {
|
|
57
|
+
if (provider === 'gtag') {
|
|
58
|
+
window.Zonos.googleAnalyticReady = true;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
window.Zonos.facebookPixelReady = true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
flushQueue();
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Send a ping to the parent so it can inject/configure analytics relays for the providers we care about.
|
|
69
|
+
* Picks up `googleAnalyticId` and `facebookPixelId` from `window.Zonos`, both of which may be set by `customHTML`.
|
|
70
|
+
*/
|
|
71
|
+
const sendRelayPing = () => {
|
|
72
|
+
if (!isInIframe())
|
|
73
|
+
return;
|
|
74
|
+
ensureListener();
|
|
75
|
+
try {
|
|
76
|
+
const z = typeof window.Zonos !== 'undefined' ? window.Zonos : undefined;
|
|
77
|
+
window.parent.postMessage({
|
|
78
|
+
facebookPixelId: z === null || z === void 0 ? void 0 : z.facebookPixelId,
|
|
79
|
+
googleAnalyticId: z === null || z === void 0 ? void 0 : z.googleAnalyticId,
|
|
80
|
+
type: RELAY_PING_TYPE,
|
|
81
|
+
}, '*');
|
|
82
|
+
}
|
|
83
|
+
catch (_a) {
|
|
84
|
+
// Ignore postMessage failures
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Sends ping to parent so it can inject/configure analytics relays and respond with ready.
|
|
89
|
+
* Call after customHTML or custom script sets `window.Zonos.googleAnalyticId` / `window.Zonos.facebookPixelId`.
|
|
90
|
+
*/
|
|
91
|
+
const ensureAnalyticsRelayPing$1 = () => {
|
|
92
|
+
if (!isInIframe())
|
|
93
|
+
return;
|
|
94
|
+
// If both providers are already ready, no need to ping again
|
|
95
|
+
if (providerReady.gtag && providerReady.fbq)
|
|
96
|
+
return;
|
|
97
|
+
sendRelayPing();
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Queue an analytic event for relay to parent. If the provider's relay is already ready,
|
|
101
|
+
* the event is forwarded immediately; otherwise it waits for the ready signal.
|
|
102
|
+
*/
|
|
103
|
+
const enqueueRelayEvent = (event) => {
|
|
104
|
+
ensureListener();
|
|
105
|
+
if (providerReady[event.provider]) {
|
|
106
|
+
try {
|
|
107
|
+
window.parent.postMessage({
|
|
108
|
+
event: event.event,
|
|
109
|
+
fbqMode: event.fbqMode,
|
|
110
|
+
metadata: event.payload,
|
|
111
|
+
provider: event.provider,
|
|
112
|
+
type: ZONOS_ANALYTIC_TYPE,
|
|
113
|
+
}, '*');
|
|
114
|
+
}
|
|
115
|
+
catch (_a) {
|
|
116
|
+
// Ignore postMessage failures
|
|
117
|
+
}
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
queue.push(event);
|
|
121
|
+
// Re-ping in case the parent hasn't received the ID yet (e.g. customHTML set it after init)
|
|
122
|
+
sendRelayPing();
|
|
123
|
+
};
|
|
124
|
+
const isAnalyticsRelayInIframe = isInIframe;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Re-export of the shared relay ping helper. Kept here for backward compatibility with
|
|
128
|
+
* existing import paths (e.g. `zonos-controller`).
|
|
129
|
+
*/
|
|
130
|
+
const ensureAnalyticsRelayPing = ensureAnalyticsRelayPing$1;
|
|
131
|
+
const isGoogleAnalyticsEnabled = () => {
|
|
132
|
+
const provider = zonosStore.zonosStore.checkoutSettings.analyticsProviders.find(item => item.type === 'GOOGLE_ANALYTICS');
|
|
133
|
+
return !!provider && provider.status === 'ENABLED';
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Submit a gtag event if the gtag function is available.
|
|
137
|
+
* When running inside an iframe, only posts to parent after the parent has
|
|
138
|
+
* confirmed (via analyticsRelayOnInit) that gtag is available.
|
|
139
|
+
*/
|
|
140
|
+
const submitGtag = ({ event, metadata }) => {
|
|
141
|
+
if (!isGoogleAnalyticsEnabled()) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const isTestMode = handleFetch.getIsTestMode();
|
|
145
|
+
const payload = Object.assign(Object.assign({}, metadata), (isTestMode && { isTestMode: true }));
|
|
146
|
+
// filter null key
|
|
147
|
+
const filteredPayload = Object.fromEntries(Object.entries(payload).filter(([_, value]) => value !== null));
|
|
148
|
+
if (isAnalyticsRelayInIframe()) {
|
|
149
|
+
// gtag does not work in iframe; must relay to parent via postMessage
|
|
150
|
+
enqueueRelayEvent({
|
|
151
|
+
event,
|
|
152
|
+
payload: filteredPayload,
|
|
153
|
+
provider: 'gtag',
|
|
154
|
+
});
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
// Not in iframe: call gtag directly
|
|
158
|
+
if (typeof window.gtag === 'function') {
|
|
159
|
+
VarianceTest.log('Zonos submits gtag event', 'log', event);
|
|
160
|
+
window.gtag('event', event, filteredPayload);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
exports.enqueueRelayEvent = enqueueRelayEvent;
|
|
165
|
+
exports.ensureAnalyticsRelayPing = ensureAnalyticsRelayPing;
|
|
166
|
+
exports.isAnalyticsRelayInIframe = isAnalyticsRelayInIframe;
|
|
167
|
+
exports.submitGtag = submitGtag;
|
|
@@ -9,11 +9,11 @@ const getBorderRadius = require('./getBorderRadius-db55a464.js');
|
|
|
9
9
|
const cart = require('./cart-d08c87e2.js');
|
|
10
10
|
const localization = require('./localization-a7fac4b4.js');
|
|
11
11
|
const handleFetch = require('./handleFetch-954f30e1.js');
|
|
12
|
-
const paypal = require('./paypal-
|
|
12
|
+
const paypal = require('./paypal-e278f405.js');
|
|
13
13
|
const VarianceTest = require('./VarianceTest-bec00ea8.js');
|
|
14
14
|
require('./isDarkColor-bfe6d1eb.js');
|
|
15
15
|
require('./isContrastColor-6a17f408.js');
|
|
16
|
-
require('./submitGtag-
|
|
16
|
+
require('./submitGtag-4241212b.js');
|
|
17
17
|
|
|
18
18
|
const zonosCardCss = ":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host .styled-card{border:var(--zonos-elements-border);border-radius:var(--zonos--border-radius, var(--zonos-elements-radius-6));padding:var(--spacing, 24px);text-align:left;background-color:var(--zonos--background-color);overflow:hidden}:host .styled-card hr{margin-left:calc(var(--spacing, 24px) * -1);margin-right:calc(var(--spacing, 24px) * -1)}:host .styled-card .card-header{margin:calc(var(--spacing, 24px) * -1);padding:var(--spacing, 24px);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;margin-bottom:var(--spacing, 24px);border-bottom:var(--zonos-elements-border);height:65px;line-height:65px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}:host .styled-card .card-header h5{margin-bottom:0;-ms-flex:1;flex:1}:host .styled-card .card-footer{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:justify;justify-content:space-between;margin:calc(var(--spacing, 24px) * -1);padding:var(--spacing, 24px);border-top:var(--zonos-elements-border);background:var(--zonos-elements-surface-color-secondary);margin-top:var(--spacing, 24px);border-bottom-left-radius:var(--zonos-elements-radius-8);border-bottom-right-radius:var(--zonos-elements-radius-8);height:var(--footerHeight)}";
|
|
19
19
|
const ZonosCardStyle0 = zonosCardCss;
|