@datadog/browser-rum-shopify 7.7.0 → 7.9.0
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/bundle/chunks/{datadogProfiler-34fb088461c1f74ab1c4-datadog-rum-shopify.js → datadogProfiler-ea9cf7f4c1fddfbb968d-datadog-rum-shopify.js} +1 -1
- package/bundle/chunks/{datadogRecorder-c4b4900255dcf6e7d61e-datadog-rum-shopify.js → datadogRecorder-dce037d0a946ad6ec7a9-datadog-rum-shopify.js} +1 -1
- package/bundle/datadog-rum-shopify.js +1 -1
- package/cjs/boot/patchSandboxedIframeApis.d.ts +3 -1
- package/cjs/boot/patchSandboxedIframeApis.js +8 -1
- package/cjs/boot/patchSandboxedIframeApis.js.map +1 -1
- package/cjs/domain/shopifyBindings.d.ts +2 -0
- package/cjs/domain/shopifyBindings.js +8 -6
- package/cjs/domain/shopifyBindings.js.map +1 -1
- package/cjs/entries/main.js +3 -1
- package/cjs/entries/main.js.map +1 -1
- package/esm/boot/patchSandboxedIframeApis.mjs +8 -1
- package/esm/boot/patchSandboxedIframeApis.mjs.map +1 -1
- package/esm/domain/shopifyBindings.mjs +8 -6
- package/esm/domain/shopifyBindings.mjs.map +1 -1
- package/esm/entries/main.mjs +3 -1
- package/esm/entries/main.mjs.map +1 -1
- package/package.json +7 -7
- package/src/boot/patchSandboxedIframeApis.ts +9 -1
- package/src/domain/shopifyBindings.ts +8 -6
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
* denied without Permissions Policy delegation), but the SDK only catches an async rejection.
|
|
10
10
|
* - `getPristineWindow()` creates a nested iframe to read an unpatched `URL` constructor; that
|
|
11
11
|
* nested iframe's `contentWindow` is cross-origin here, and reading a property off it throws.
|
|
12
|
+
* - `document.hasFocus()` always returns `false`: the pixel iframe has no focusable UI, so it can
|
|
13
|
+
* never hold browser focus regardless of whether the customer is actively looking at the page.
|
|
12
14
|
* Shimming these away makes the SDK fall back to code paths that do work in this context
|
|
13
|
-
* (`document.cookie`, same-document promise chaining, `globalObject.URL
|
|
15
|
+
* (`document.cookie`, same-document promise chaining, `globalObject.URL`, always-focused state).
|
|
14
16
|
*/
|
|
15
17
|
export declare function patchSandboxedIframeApis(): void;
|
|
@@ -11,8 +11,10 @@ let _datadog_browser_core = require("@datadog/browser-core");
|
|
|
11
11
|
* denied without Permissions Policy delegation), but the SDK only catches an async rejection.
|
|
12
12
|
* - `getPristineWindow()` creates a nested iframe to read an unpatched `URL` constructor; that
|
|
13
13
|
* nested iframe's `contentWindow` is cross-origin here, and reading a property off it throws.
|
|
14
|
+
* - `document.hasFocus()` always returns `false`: the pixel iframe has no focusable UI, so it can
|
|
15
|
+
* never hold browser focus regardless of whether the customer is actively looking at the page.
|
|
14
16
|
* Shimming these away makes the SDK fall back to code paths that do work in this context
|
|
15
|
-
* (`document.cookie`, same-document promise chaining, `globalObject.URL
|
|
17
|
+
* (`document.cookie`, same-document promise chaining, `globalObject.URL`, always-focused state).
|
|
16
18
|
*/
|
|
17
19
|
function patchSandboxedIframeApis() {
|
|
18
20
|
disableProperty(_datadog_browser_core.globalObject, "cookieStore");
|
|
@@ -23,6 +25,11 @@ function patchSandboxedIframeApis() {
|
|
|
23
25
|
},
|
|
24
26
|
configurable: true
|
|
25
27
|
});
|
|
28
|
+
Object.defineProperty(document, "hasFocus", {
|
|
29
|
+
value: () => true,
|
|
30
|
+
configurable: true,
|
|
31
|
+
writable: true
|
|
32
|
+
});
|
|
26
33
|
}
|
|
27
34
|
function disableProperty(target, key) {
|
|
28
35
|
Object.defineProperty(target, key, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patchSandboxedIframeApis.js","names":["globalObject"],"sources":["../../src/boot/patchSandboxedIframeApis.ts"],"sourcesContent":["import { globalObject } from '@datadog/browser-core'\n\n/**\n * A Shopify Custom Pixel runs in a \"lax\" sandboxed iframe (`sandbox=\"allow-scripts\"`, no\n * `allow-same-origin`): it shares the parent page's cookie jar (same domain) but has an\n * opaque/`null` origin for its own window/document. Several browser APIs the RUM SDK relies on\n * either don't work there or throw synchronously in ways the SDK doesn't fully guard against,\n * which silently breaks session tracking and view/URL resolution:\n * - `cookieStore.getAll()` is blocked; `document.cookie` works fine as a fallback.\n * - `navigator.locks.request()` throws a synchronous `SecurityError` (the Web Locks API is\n * denied without Permissions Policy delegation), but the SDK only catches an async rejection.\n * - `getPristineWindow()` creates a nested iframe to read an unpatched `URL` constructor; that\n * nested iframe's `contentWindow` is cross-origin here, and reading a property off it throws.\n * Shimming these away makes the SDK fall back to code paths that do work in this context\n * (`document.cookie`, same-document promise chaining, `globalObject.URL
|
|
1
|
+
{"version":3,"file":"patchSandboxedIframeApis.js","names":["globalObject"],"sources":["../../src/boot/patchSandboxedIframeApis.ts"],"sourcesContent":["import { globalObject } from '@datadog/browser-core'\n\n/**\n * A Shopify Custom Pixel runs in a \"lax\" sandboxed iframe (`sandbox=\"allow-scripts\"`, no\n * `allow-same-origin`): it shares the parent page's cookie jar (same domain) but has an\n * opaque/`null` origin for its own window/document. Several browser APIs the RUM SDK relies on\n * either don't work there or throw synchronously in ways the SDK doesn't fully guard against,\n * which silently breaks session tracking and view/URL resolution:\n * - `cookieStore.getAll()` is blocked; `document.cookie` works fine as a fallback.\n * - `navigator.locks.request()` throws a synchronous `SecurityError` (the Web Locks API is\n * denied without Permissions Policy delegation), but the SDK only catches an async rejection.\n * - `getPristineWindow()` creates a nested iframe to read an unpatched `URL` constructor; that\n * nested iframe's `contentWindow` is cross-origin here, and reading a property off it throws.\n * - `document.hasFocus()` always returns `false`: the pixel iframe has no focusable UI, so it can\n * never hold browser focus regardless of whether the customer is actively looking at the page.\n * Shimming these away makes the SDK fall back to code paths that do work in this context\n * (`document.cookie`, same-document promise chaining, `globalObject.URL`, always-focused state).\n */\nexport function patchSandboxedIframeApis() {\n disableProperty(globalObject, 'cookieStore')\n disableProperty(navigator, 'locks')\n\n Object.defineProperty(HTMLIFrameElement.prototype, 'contentWindow', {\n get() {\n return null\n },\n configurable: true,\n })\n\n Object.defineProperty(document, 'hasFocus', {\n value: () => true,\n configurable: true,\n writable: true,\n })\n}\n\nfunction disableProperty(target: object, key: string) {\n Object.defineProperty(target, key, {\n value: undefined,\n configurable: true,\n writable: true,\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,SAAgB,2BAA2B;CACzC,gBAAgBA,sBAAAA,cAAc,aAAa;CAC3C,gBAAgB,WAAW,OAAO;CAElC,OAAO,eAAe,kBAAkB,WAAW,iBAAiB;EAClE,MAAM;GACJ,OAAO;EACT;EACA,cAAc;CAChB,CAAC;CAED,OAAO,eAAe,UAAU,YAAY;EAC1C,aAAa;EACb,cAAc;EACd,UAAU;CACZ,CAAC;AACH;AAEA,SAAS,gBAAgB,QAAgB,KAAa;CACpD,OAAO,eAAe,QAAQ,KAAK;EACjC,OAAO,KAAA;EACP,cAAc;EACd,UAAU;CACZ,CAAC;AACH"}
|
|
@@ -9,7 +9,9 @@ export interface ErrorData {
|
|
|
9
9
|
extensionName?: string;
|
|
10
10
|
extensionTarget?: string;
|
|
11
11
|
type?: string;
|
|
12
|
+
appId?: string;
|
|
12
13
|
appName?: string;
|
|
14
|
+
appVersion?: string;
|
|
13
15
|
}
|
|
14
16
|
/**
|
|
15
17
|
* Wires Shopify Web Pixel standard events to the RUM public API. `analytics` is the sandbox's
|
|
@@ -20,12 +20,14 @@ function initShopifyBindings(rumPublicApi, analytics) {
|
|
|
20
20
|
const error = event.data?.error;
|
|
21
21
|
const err = new Error(error?.message);
|
|
22
22
|
err.stack = error?.trace;
|
|
23
|
-
rumPublicApi.addError(err, {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
rumPublicApi.addError(err, {
|
|
24
|
+
extensionName: error?.extensionName,
|
|
25
|
+
extensionTarget: error?.extensionTarget,
|
|
26
|
+
extensionErrorType: error?.type,
|
|
27
|
+
appId: error?.appId,
|
|
28
|
+
appName: error?.appName,
|
|
29
|
+
appVersion: error?.appVersion
|
|
30
|
+
});
|
|
29
31
|
});
|
|
30
32
|
}
|
|
31
33
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shopifyBindings.js","names":[],"sources":["../../src/domain/shopifyBindings.ts"],"sourcesContent":["import type { RumPublicApi } from '@datadog/browser-rum-core'\nimport type { ShopifyAnalyticsApi, ShopifyPixelEvent } from './shopifyAnalytics'\n\nexport interface ElementData {\n id?: string\n}\n\nexport interface ErrorData {\n message?: string\n trace?: string\n extensionName?: string\n extensionTarget?: string\n type?: string\n appName?: string\n}\n\n// Matches /checkouts/*, /checkout, including locale-prefixed paths.\n// Storefront pages never match, so init() is a no-op there: those pages\n// already get a `DD_RUM` instance from the Theme Liquid snippet, and initializing here too would\n// create a second, independent SDK instance double-tracking the same page view.\nconst CHECKOUT_PATH = /\\/(([a-z]{2}(-[a-z0-9]+)?)\\/)?(checkouts?)(\\/|$)/i\n\n/**\n * Wires Shopify Web Pixel standard events to the RUM public API. `analytics` is the sandbox's\n * `analytics` global (or `undefined` outside the sandbox, in which case bindings are skipped).\n */\nexport function initShopifyBindings(rumPublicApi: RumPublicApi, analytics: ShopifyAnalyticsApi | undefined) {\n if (!analytics) {\n return\n }\n\n analytics.subscribe('page_viewed', (event) => {\n const url = event.context?.document?.location?.href\n\n if (!url || !CHECKOUT_PATH.test(url)) {\n return\n }\n\n rumPublicApi.startView({\n url,\n })\n })\n\n analytics.subscribe('clicked', (event: ShopifyPixelEvent<{ element?: ElementData }>) => {\n const element = event.data?.element\n const name = element?.id ?? 'element-without-id'\n rumPublicApi.startAction(name, { type: 'click' })\n rumPublicApi.stopAction(name, { type: 'click' })\n })\n\n // Fires when a Shopify checkout UI extension crashes.\n analytics.subscribe('ui_extension_errored', (event: ShopifyPixelEvent<{ error?: ErrorData }>) => {\n const error = event.data?.error\n const err = new Error(error?.message)\n err.stack = error?.trace\n rumPublicApi.addError(err, {\n
|
|
1
|
+
{"version":3,"file":"shopifyBindings.js","names":[],"sources":["../../src/domain/shopifyBindings.ts"],"sourcesContent":["import type { RumPublicApi } from '@datadog/browser-rum-core'\nimport type { ShopifyAnalyticsApi, ShopifyPixelEvent } from './shopifyAnalytics'\n\nexport interface ElementData {\n id?: string\n}\n\nexport interface ErrorData {\n message?: string\n trace?: string\n extensionName?: string\n extensionTarget?: string\n type?: string\n appId?: string\n appName?: string\n appVersion?: string\n}\n\n// Matches /checkouts/*, /checkout, including locale-prefixed paths.\n// Storefront pages never match, so init() is a no-op there: those pages\n// already get a `DD_RUM` instance from the Theme Liquid snippet, and initializing here too would\n// create a second, independent SDK instance double-tracking the same page view.\nconst CHECKOUT_PATH = /\\/(([a-z]{2}(-[a-z0-9]+)?)\\/)?(checkouts?)(\\/|$)/i\n\n/**\n * Wires Shopify Web Pixel standard events to the RUM public API. `analytics` is the sandbox's\n * `analytics` global (or `undefined` outside the sandbox, in which case bindings are skipped).\n */\nexport function initShopifyBindings(rumPublicApi: RumPublicApi, analytics: ShopifyAnalyticsApi | undefined) {\n if (!analytics) {\n return\n }\n\n analytics.subscribe('page_viewed', (event) => {\n const url = event.context?.document?.location?.href\n\n if (!url || !CHECKOUT_PATH.test(url)) {\n return\n }\n\n rumPublicApi.startView({\n url,\n })\n })\n\n analytics.subscribe('clicked', (event: ShopifyPixelEvent<{ element?: ElementData }>) => {\n const element = event.data?.element\n const name = element?.id ?? 'element-without-id'\n rumPublicApi.startAction(name, { type: 'click' })\n rumPublicApi.stopAction(name, { type: 'click' })\n })\n\n // Fires when a Shopify checkout UI extension crashes.\n analytics.subscribe('ui_extension_errored', (event: ShopifyPixelEvent<{ error?: ErrorData }>) => {\n const error = event.data?.error\n const err = new Error(error?.message)\n err.stack = error?.trace\n rumPublicApi.addError(err, {\n extensionName: error?.extensionName,\n extensionTarget: error?.extensionTarget,\n extensionErrorType: error?.type,\n appId: error?.appId,\n appName: error?.appName,\n appVersion: error?.appVersion,\n })\n })\n}\n"],"mappings":";AAsBA,MAAM,gBAAgB;;;;;AAMtB,SAAgB,oBAAoB,cAA4B,WAA4C;CAC1G,IAAI,CAAC,WACH;CAGF,UAAU,UAAU,gBAAgB,UAAU;EAC5C,MAAM,MAAM,MAAM,SAAS,UAAU,UAAU;EAE/C,IAAI,CAAC,OAAO,CAAC,cAAc,KAAK,GAAG,GACjC;EAGF,aAAa,UAAU,EACrB,IACF,CAAC;CACH,CAAC;CAED,UAAU,UAAU,YAAY,UAAwD;EAEtF,MAAM,QADU,MAAM,MAAM,QAAA,EACN,MAAM;EAC5B,aAAa,YAAY,MAAM,EAAE,MAAM,QAAQ,CAAC;EAChD,aAAa,WAAW,MAAM,EAAE,MAAM,QAAQ,CAAC;CACjD,CAAC;CAGD,UAAU,UAAU,yBAAyB,UAAoD;EAC/F,MAAM,QAAQ,MAAM,MAAM;EAC1B,MAAM,MAAM,IAAI,MAAM,OAAO,OAAO;EACpC,IAAI,QAAQ,OAAO;EACnB,aAAa,SAAS,KAAK;GACzB,eAAe,OAAO;GACtB,iBAAiB,OAAO;GACxB,oBAAoB,OAAO;GAC3B,OAAO,OAAO;GACd,SAAS,OAAO;GAChB,YAAY,OAAO;EACrB,CAAC;CACH,CAAC;AACH"}
|
package/cjs/entries/main.js
CHANGED
|
@@ -3,7 +3,9 @@ let _datadog_browser_core = require("@datadog/browser-core");
|
|
|
3
3
|
let _datadog_browser_rum_core = require("@datadog/browser-rum-core");
|
|
4
4
|
let _datadog_browser_rum_internal = require("@datadog/browser-rum/internal");
|
|
5
5
|
//#region src/entries/main.ts
|
|
6
|
-
|
|
6
|
+
const global = _datadog_browser_core.globalObject;
|
|
7
|
+
const datadogRum = require_makeShopifyRumPublicApi.makeShopifyRumPublicApi((0, _datadog_browser_rum_core.makeRumPublicApi)((0, _datadog_browser_rum_internal.makeRecorderApi)(), (0, _datadog_browser_rum_internal.makeProfilerApi)(), { sdkName: "rum-shopify" }));
|
|
8
|
+
(0, _datadog_browser_core.defineGlobal)(global, "DD_RUM", datadogRum);
|
|
7
9
|
//#endregion
|
|
8
10
|
|
|
9
11
|
//# sourceMappingURL=main.js.map
|
package/cjs/entries/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","names":["
|
|
1
|
+
{"version":3,"file":"main.js","names":["globalObject","makeShopifyRumPublicApi","makeRumPublicApi","makeRecorderApi","makeProfilerApi","defineGlobal"],"sources":["../../src/entries/main.ts"],"sourcesContent":["import { defineGlobal, globalObject } from '@datadog/browser-core'\nimport type { RumPublicApi } from '@datadog/browser-rum-core'\nimport { makeRumPublicApi } from '@datadog/browser-rum-core'\nimport { makeRecorderApi, makeProfilerApi } from '@datadog/browser-rum/internal'\nimport { makeShopifyRumPublicApi } from '../boot/makeShopifyRumPublicApi'\n\ninterface BrowserWindow {\n DD_RUM?: RumPublicApi\n}\n\nconst global = globalObject as BrowserWindow\n\nconst datadogRum = makeShopifyRumPublicApi(\n makeRumPublicApi(makeRecorderApi(), makeProfilerApi(), {\n sdkName: 'rum-shopify',\n })\n)\n\ndefineGlobal(global, 'DD_RUM', datadogRum)\n"],"mappings":";;;;;AAUA,MAAM,SAASA,sBAAAA;AAEf,MAAM,aAAaC,gCAAAA,yBAAAA,GACjBC,0BAAAA,iBAAAA,EAAAA,GAAiBC,8BAAAA,gBAAAA,CAAgB,IAAA,GAAGC,8BAAAA,gBAAAA,CAAgB,GAAG,EACrD,SAAS,cACX,CAAC,CACH;CAEAC,GAAAA,sBAAAA,aAAAA,CAAa,QAAQ,UAAU,UAAU"}
|
|
@@ -11,8 +11,10 @@ import { globalObject } from "@datadog/browser-core";
|
|
|
11
11
|
* denied without Permissions Policy delegation), but the SDK only catches an async rejection.
|
|
12
12
|
* - `getPristineWindow()` creates a nested iframe to read an unpatched `URL` constructor; that
|
|
13
13
|
* nested iframe's `contentWindow` is cross-origin here, and reading a property off it throws.
|
|
14
|
+
* - `document.hasFocus()` always returns `false`: the pixel iframe has no focusable UI, so it can
|
|
15
|
+
* never hold browser focus regardless of whether the customer is actively looking at the page.
|
|
14
16
|
* Shimming these away makes the SDK fall back to code paths that do work in this context
|
|
15
|
-
* (`document.cookie`, same-document promise chaining, `globalObject.URL
|
|
17
|
+
* (`document.cookie`, same-document promise chaining, `globalObject.URL`, always-focused state).
|
|
16
18
|
*/
|
|
17
19
|
function patchSandboxedIframeApis() {
|
|
18
20
|
disableProperty(globalObject, "cookieStore");
|
|
@@ -23,6 +25,11 @@ function patchSandboxedIframeApis() {
|
|
|
23
25
|
},
|
|
24
26
|
configurable: true
|
|
25
27
|
});
|
|
28
|
+
Object.defineProperty(document, "hasFocus", {
|
|
29
|
+
value: () => true,
|
|
30
|
+
configurable: true,
|
|
31
|
+
writable: true
|
|
32
|
+
});
|
|
26
33
|
}
|
|
27
34
|
function disableProperty(target, key) {
|
|
28
35
|
Object.defineProperty(target, key, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patchSandboxedIframeApis.mjs","names":[],"sources":["../../src/boot/patchSandboxedIframeApis.ts"],"sourcesContent":["import { globalObject } from '@datadog/browser-core'\n\n/**\n * A Shopify Custom Pixel runs in a \"lax\" sandboxed iframe (`sandbox=\"allow-scripts\"`, no\n * `allow-same-origin`): it shares the parent page's cookie jar (same domain) but has an\n * opaque/`null` origin for its own window/document. Several browser APIs the RUM SDK relies on\n * either don't work there or throw synchronously in ways the SDK doesn't fully guard against,\n * which silently breaks session tracking and view/URL resolution:\n * - `cookieStore.getAll()` is blocked; `document.cookie` works fine as a fallback.\n * - `navigator.locks.request()` throws a synchronous `SecurityError` (the Web Locks API is\n * denied without Permissions Policy delegation), but the SDK only catches an async rejection.\n * - `getPristineWindow()` creates a nested iframe to read an unpatched `URL` constructor; that\n * nested iframe's `contentWindow` is cross-origin here, and reading a property off it throws.\n * Shimming these away makes the SDK fall back to code paths that do work in this context\n * (`document.cookie`, same-document promise chaining, `globalObject.URL
|
|
1
|
+
{"version":3,"file":"patchSandboxedIframeApis.mjs","names":[],"sources":["../../src/boot/patchSandboxedIframeApis.ts"],"sourcesContent":["import { globalObject } from '@datadog/browser-core'\n\n/**\n * A Shopify Custom Pixel runs in a \"lax\" sandboxed iframe (`sandbox=\"allow-scripts\"`, no\n * `allow-same-origin`): it shares the parent page's cookie jar (same domain) but has an\n * opaque/`null` origin for its own window/document. Several browser APIs the RUM SDK relies on\n * either don't work there or throw synchronously in ways the SDK doesn't fully guard against,\n * which silently breaks session tracking and view/URL resolution:\n * - `cookieStore.getAll()` is blocked; `document.cookie` works fine as a fallback.\n * - `navigator.locks.request()` throws a synchronous `SecurityError` (the Web Locks API is\n * denied without Permissions Policy delegation), but the SDK only catches an async rejection.\n * - `getPristineWindow()` creates a nested iframe to read an unpatched `URL` constructor; that\n * nested iframe's `contentWindow` is cross-origin here, and reading a property off it throws.\n * - `document.hasFocus()` always returns `false`: the pixel iframe has no focusable UI, so it can\n * never hold browser focus regardless of whether the customer is actively looking at the page.\n * Shimming these away makes the SDK fall back to code paths that do work in this context\n * (`document.cookie`, same-document promise chaining, `globalObject.URL`, always-focused state).\n */\nexport function patchSandboxedIframeApis() {\n disableProperty(globalObject, 'cookieStore')\n disableProperty(navigator, 'locks')\n\n Object.defineProperty(HTMLIFrameElement.prototype, 'contentWindow', {\n get() {\n return null\n },\n configurable: true,\n })\n\n Object.defineProperty(document, 'hasFocus', {\n value: () => true,\n configurable: true,\n writable: true,\n })\n}\n\nfunction disableProperty(target: object, key: string) {\n Object.defineProperty(target, key, {\n value: undefined,\n configurable: true,\n writable: true,\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,SAAgB,2BAA2B;CACzC,gBAAgB,cAAc,aAAa;CAC3C,gBAAgB,WAAW,OAAO;CAElC,OAAO,eAAe,kBAAkB,WAAW,iBAAiB;EAClE,MAAM;GACJ,OAAO;EACT;EACA,cAAc;CAChB,CAAC;CAED,OAAO,eAAe,UAAU,YAAY;EAC1C,aAAa;EACb,cAAc;EACd,UAAU;CACZ,CAAC;AACH;AAEA,SAAS,gBAAgB,QAAgB,KAAa;CACpD,OAAO,eAAe,QAAQ,KAAK;EACjC,OAAO,KAAA;EACP,cAAc;EACd,UAAU;CACZ,CAAC;AACH"}
|
|
@@ -20,12 +20,14 @@ function initShopifyBindings(rumPublicApi, analytics) {
|
|
|
20
20
|
const error = event.data?.error;
|
|
21
21
|
const err = new Error(error?.message);
|
|
22
22
|
err.stack = error?.trace;
|
|
23
|
-
rumPublicApi.addError(err, {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
rumPublicApi.addError(err, {
|
|
24
|
+
extensionName: error?.extensionName,
|
|
25
|
+
extensionTarget: error?.extensionTarget,
|
|
26
|
+
extensionErrorType: error?.type,
|
|
27
|
+
appId: error?.appId,
|
|
28
|
+
appName: error?.appName,
|
|
29
|
+
appVersion: error?.appVersion
|
|
30
|
+
});
|
|
29
31
|
});
|
|
30
32
|
}
|
|
31
33
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shopifyBindings.mjs","names":[],"sources":["../../src/domain/shopifyBindings.ts"],"sourcesContent":["import type { RumPublicApi } from '@datadog/browser-rum-core'\nimport type { ShopifyAnalyticsApi, ShopifyPixelEvent } from './shopifyAnalytics'\n\nexport interface ElementData {\n id?: string\n}\n\nexport interface ErrorData {\n message?: string\n trace?: string\n extensionName?: string\n extensionTarget?: string\n type?: string\n appName?: string\n}\n\n// Matches /checkouts/*, /checkout, including locale-prefixed paths.\n// Storefront pages never match, so init() is a no-op there: those pages\n// already get a `DD_RUM` instance from the Theme Liquid snippet, and initializing here too would\n// create a second, independent SDK instance double-tracking the same page view.\nconst CHECKOUT_PATH = /\\/(([a-z]{2}(-[a-z0-9]+)?)\\/)?(checkouts?)(\\/|$)/i\n\n/**\n * Wires Shopify Web Pixel standard events to the RUM public API. `analytics` is the sandbox's\n * `analytics` global (or `undefined` outside the sandbox, in which case bindings are skipped).\n */\nexport function initShopifyBindings(rumPublicApi: RumPublicApi, analytics: ShopifyAnalyticsApi | undefined) {\n if (!analytics) {\n return\n }\n\n analytics.subscribe('page_viewed', (event) => {\n const url = event.context?.document?.location?.href\n\n if (!url || !CHECKOUT_PATH.test(url)) {\n return\n }\n\n rumPublicApi.startView({\n url,\n })\n })\n\n analytics.subscribe('clicked', (event: ShopifyPixelEvent<{ element?: ElementData }>) => {\n const element = event.data?.element\n const name = element?.id ?? 'element-without-id'\n rumPublicApi.startAction(name, { type: 'click' })\n rumPublicApi.stopAction(name, { type: 'click' })\n })\n\n // Fires when a Shopify checkout UI extension crashes.\n analytics.subscribe('ui_extension_errored', (event: ShopifyPixelEvent<{ error?: ErrorData }>) => {\n const error = event.data?.error\n const err = new Error(error?.message)\n err.stack = error?.trace\n rumPublicApi.addError(err, {\n
|
|
1
|
+
{"version":3,"file":"shopifyBindings.mjs","names":[],"sources":["../../src/domain/shopifyBindings.ts"],"sourcesContent":["import type { RumPublicApi } from '@datadog/browser-rum-core'\nimport type { ShopifyAnalyticsApi, ShopifyPixelEvent } from './shopifyAnalytics'\n\nexport interface ElementData {\n id?: string\n}\n\nexport interface ErrorData {\n message?: string\n trace?: string\n extensionName?: string\n extensionTarget?: string\n type?: string\n appId?: string\n appName?: string\n appVersion?: string\n}\n\n// Matches /checkouts/*, /checkout, including locale-prefixed paths.\n// Storefront pages never match, so init() is a no-op there: those pages\n// already get a `DD_RUM` instance from the Theme Liquid snippet, and initializing here too would\n// create a second, independent SDK instance double-tracking the same page view.\nconst CHECKOUT_PATH = /\\/(([a-z]{2}(-[a-z0-9]+)?)\\/)?(checkouts?)(\\/|$)/i\n\n/**\n * Wires Shopify Web Pixel standard events to the RUM public API. `analytics` is the sandbox's\n * `analytics` global (or `undefined` outside the sandbox, in which case bindings are skipped).\n */\nexport function initShopifyBindings(rumPublicApi: RumPublicApi, analytics: ShopifyAnalyticsApi | undefined) {\n if (!analytics) {\n return\n }\n\n analytics.subscribe('page_viewed', (event) => {\n const url = event.context?.document?.location?.href\n\n if (!url || !CHECKOUT_PATH.test(url)) {\n return\n }\n\n rumPublicApi.startView({\n url,\n })\n })\n\n analytics.subscribe('clicked', (event: ShopifyPixelEvent<{ element?: ElementData }>) => {\n const element = event.data?.element\n const name = element?.id ?? 'element-without-id'\n rumPublicApi.startAction(name, { type: 'click' })\n rumPublicApi.stopAction(name, { type: 'click' })\n })\n\n // Fires when a Shopify checkout UI extension crashes.\n analytics.subscribe('ui_extension_errored', (event: ShopifyPixelEvent<{ error?: ErrorData }>) => {\n const error = event.data?.error\n const err = new Error(error?.message)\n err.stack = error?.trace\n rumPublicApi.addError(err, {\n extensionName: error?.extensionName,\n extensionTarget: error?.extensionTarget,\n extensionErrorType: error?.type,\n appId: error?.appId,\n appName: error?.appName,\n appVersion: error?.appVersion,\n })\n })\n}\n"],"mappings":";AAsBA,MAAM,gBAAgB;;;;;AAMtB,SAAgB,oBAAoB,cAA4B,WAA4C;CAC1G,IAAI,CAAC,WACH;CAGF,UAAU,UAAU,gBAAgB,UAAU;EAC5C,MAAM,MAAM,MAAM,SAAS,UAAU,UAAU;EAE/C,IAAI,CAAC,OAAO,CAAC,cAAc,KAAK,GAAG,GACjC;EAGF,aAAa,UAAU,EACrB,IACF,CAAC;CACH,CAAC;CAED,UAAU,UAAU,YAAY,UAAwD;EAEtF,MAAM,QADU,MAAM,MAAM,QAAA,EACN,MAAM;EAC5B,aAAa,YAAY,MAAM,EAAE,MAAM,QAAQ,CAAC;EAChD,aAAa,WAAW,MAAM,EAAE,MAAM,QAAQ,CAAC;CACjD,CAAC;CAGD,UAAU,UAAU,yBAAyB,UAAoD;EAC/F,MAAM,QAAQ,MAAM,MAAM;EAC1B,MAAM,MAAM,IAAI,MAAM,OAAO,OAAO;EACpC,IAAI,QAAQ,OAAO;EACnB,aAAa,SAAS,KAAK;GACzB,eAAe,OAAO;GACtB,iBAAiB,OAAO;GACxB,oBAAoB,OAAO;GAC3B,OAAO,OAAO;GACd,SAAS,OAAO;GAChB,YAAY,OAAO;EACrB,CAAC;CACH,CAAC;AACH"}
|
package/esm/entries/main.mjs
CHANGED
|
@@ -3,7 +3,9 @@ import { defineGlobal, globalObject } from "@datadog/browser-core";
|
|
|
3
3
|
import { makeRumPublicApi } from "@datadog/browser-rum-core";
|
|
4
4
|
import { makeProfilerApi, makeRecorderApi } from "@datadog/browser-rum/internal";
|
|
5
5
|
//#region src/entries/main.ts
|
|
6
|
-
|
|
6
|
+
const global = globalObject;
|
|
7
|
+
const datadogRum = makeShopifyRumPublicApi(makeRumPublicApi(makeRecorderApi(), makeProfilerApi(), { sdkName: "rum-shopify" }));
|
|
8
|
+
defineGlobal(global, "DD_RUM", datadogRum);
|
|
7
9
|
//#endregion
|
|
8
10
|
|
|
9
11
|
//# sourceMappingURL=main.mjs.map
|
package/esm/entries/main.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.mjs","names":[
|
|
1
|
+
{"version":3,"file":"main.mjs","names":[],"sources":["../../src/entries/main.ts"],"sourcesContent":["import { defineGlobal, globalObject } from '@datadog/browser-core'\nimport type { RumPublicApi } from '@datadog/browser-rum-core'\nimport { makeRumPublicApi } from '@datadog/browser-rum-core'\nimport { makeRecorderApi, makeProfilerApi } from '@datadog/browser-rum/internal'\nimport { makeShopifyRumPublicApi } from '../boot/makeShopifyRumPublicApi'\n\ninterface BrowserWindow {\n DD_RUM?: RumPublicApi\n}\n\nconst global = globalObject as BrowserWindow\n\nconst datadogRum = makeShopifyRumPublicApi(\n makeRumPublicApi(makeRecorderApi(), makeProfilerApi(), {\n sdkName: 'rum-shopify',\n })\n)\n\ndefineGlobal(global, 'DD_RUM', datadogRum)\n"],"mappings":";;;;;AAUA,MAAM,SAAS;AAEf,MAAM,aAAa,wBACjB,iBAAiB,gBAAgB,GAAG,gBAAgB,GAAG,EACrD,SAAS,cACX,CAAC,CACH;AAEA,aAAa,QAAQ,UAAU,UAAU"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/browser-rum-shopify",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.9.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "cjs/entries/main.js",
|
|
6
6
|
"module": "esm/entries/main.mjs",
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
"!src/**/*.specHelper.ts"
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
|
-
"build": "node ../../scripts/build/build-package.ts --modules --bundle datadog-rum-shopify.js",
|
|
18
|
-
"build:bundle": "node ../../scripts/build/build-package.ts --bundle datadog-rum-shopify.js",
|
|
17
|
+
"build": "node ../../scripts/build/build-package.ts --modules --worker-string --bundle datadog-rum-shopify.js",
|
|
18
|
+
"build:bundle": "node ../../scripts/build/build-package.ts --worker-string --bundle datadog-rum-shopify.js",
|
|
19
19
|
"prepack": "yarn build"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@datadog/browser-core": "7.
|
|
23
|
-
"@datadog/browser-rum": "7.
|
|
24
|
-
"@datadog/browser-rum-core": "7.
|
|
25
|
-
"@datadog/js-core": "0.0.
|
|
22
|
+
"@datadog/browser-core": "7.9.0",
|
|
23
|
+
"@datadog/browser-rum": "7.9.0",
|
|
24
|
+
"@datadog/browser-rum-core": "7.9.0",
|
|
25
|
+
"@datadog/js-core": "0.0.10"
|
|
26
26
|
},
|
|
27
27
|
"repository": {
|
|
28
28
|
"type": "git",
|
|
@@ -11,8 +11,10 @@ import { globalObject } from '@datadog/browser-core'
|
|
|
11
11
|
* denied without Permissions Policy delegation), but the SDK only catches an async rejection.
|
|
12
12
|
* - `getPristineWindow()` creates a nested iframe to read an unpatched `URL` constructor; that
|
|
13
13
|
* nested iframe's `contentWindow` is cross-origin here, and reading a property off it throws.
|
|
14
|
+
* - `document.hasFocus()` always returns `false`: the pixel iframe has no focusable UI, so it can
|
|
15
|
+
* never hold browser focus regardless of whether the customer is actively looking at the page.
|
|
14
16
|
* Shimming these away makes the SDK fall back to code paths that do work in this context
|
|
15
|
-
* (`document.cookie`, same-document promise chaining, `globalObject.URL
|
|
17
|
+
* (`document.cookie`, same-document promise chaining, `globalObject.URL`, always-focused state).
|
|
16
18
|
*/
|
|
17
19
|
export function patchSandboxedIframeApis() {
|
|
18
20
|
disableProperty(globalObject, 'cookieStore')
|
|
@@ -24,6 +26,12 @@ export function patchSandboxedIframeApis() {
|
|
|
24
26
|
},
|
|
25
27
|
configurable: true,
|
|
26
28
|
})
|
|
29
|
+
|
|
30
|
+
Object.defineProperty(document, 'hasFocus', {
|
|
31
|
+
value: () => true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true,
|
|
34
|
+
})
|
|
27
35
|
}
|
|
28
36
|
|
|
29
37
|
function disableProperty(target: object, key: string) {
|
|
@@ -11,7 +11,9 @@ export interface ErrorData {
|
|
|
11
11
|
extensionName?: string
|
|
12
12
|
extensionTarget?: string
|
|
13
13
|
type?: string
|
|
14
|
+
appId?: string
|
|
14
15
|
appName?: string
|
|
16
|
+
appVersion?: string
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
// Matches /checkouts/*, /checkout, including locale-prefixed paths.
|
|
@@ -54,12 +56,12 @@ export function initShopifyBindings(rumPublicApi: RumPublicApi, analytics: Shopi
|
|
|
54
56
|
const err = new Error(error?.message)
|
|
55
57
|
err.stack = error?.trace
|
|
56
58
|
rumPublicApi.addError(err, {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
extensionName: error?.extensionName,
|
|
60
|
+
extensionTarget: error?.extensionTarget,
|
|
61
|
+
extensionErrorType: error?.type,
|
|
62
|
+
appId: error?.appId,
|
|
63
|
+
appName: error?.appName,
|
|
64
|
+
appVersion: error?.appVersion,
|
|
63
65
|
})
|
|
64
66
|
})
|
|
65
67
|
}
|