@datadog/browser-rum-shopify 7.14.0 → 7.16.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.
@@ -1,7 +1,7 @@
1
1
  const require_patchSandboxedIframeApis = require("../boot/patchSandboxedIframeApis.js");
2
2
  const require_shopifyAnalytics = require("./shopifyAnalytics.js");
3
3
  const require_shopifyBindings = require("./shopifyBindings.js");
4
- let _datadog_browser_core = require("@datadog/browser-core");
4
+ let _datadog_js_core_util = require("@datadog/js-core/util");
5
5
  //#region src/domain/shopifyPlugin.ts
6
6
  /**
7
7
  * Adapts the RUM SDK to run inside a Shopify Custom Pixel sandbox. When `shopifyAnalytics` (the
@@ -17,8 +17,8 @@ function shopifyPlugin(configuration) {
17
17
  if (!analytics) return false;
18
18
  const pageViewedEvent = await require_shopifyAnalytics.waitForPageViewedEvent(analytics);
19
19
  if (!require_shopifyBindings.isCheckoutPage(pageViewedEvent)) return false;
20
- (0, _datadog_browser_core.mockable)(require_patchSandboxedIframeApis.patchSandboxedIframeApis)();
21
- (0, _datadog_browser_core.mockable)(require_shopifyBindings.initShopifyBindings)(publicApi, analytics);
20
+ (0, _datadog_js_core_util.mockable)(require_patchSandboxedIframeApis.patchSandboxedIframeApis)();
21
+ (0, _datadog_js_core_util.mockable)(require_shopifyBindings.initShopifyBindings)(publicApi, analytics);
22
22
  initConfiguration.trackViewsManually = true;
23
23
  initConfiguration.sessionReplaySampleRate = 0;
24
24
  initConfiguration.profilingSampleRate = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"shopifyPlugin.js","names":["waitForPageViewedEvent","isCheckoutPage","patchSandboxedIframeApis","initShopifyBindings"],"sources":["../../src/domain/shopifyPlugin.ts"],"sourcesContent":["import { mockable } from '@datadog/browser-core'\nimport type { RumPlugin } from '@datadog/browser-rum-core'\nimport { patchSandboxedIframeApis } from '../boot/patchSandboxedIframeApis'\nimport type { ShopifyAnalyticsApi } from './shopifyAnalytics'\nimport { initShopifyBindings, isCheckoutPage } from './shopifyBindings'\nimport { waitForPageViewedEvent } from './shopifyAnalytics'\n\nexport interface ShopifyPluginConfiguration {\n shopifyAnalytics: ShopifyAnalyticsApi\n}\n\n/**\n * Adapts the RUM SDK to run inside a Shopify Custom Pixel sandbox. When `shopifyAnalytics` (the\n * sandbox's `analytics` global) is provided, patches the sandboxed iframe's APIs, wires Shopify\n * Web Pixel events to the RUM public API, and forces configuration suited to that iframe (see\n * below). Storefront pages don't provide `shopifyAnalytics` and shouldn't include this plugin.\n */\nexport function shopifyPlugin(configuration: ShopifyPluginConfiguration): RumPlugin {\n return {\n name: 'shopify',\n async onInit({ initConfiguration, publicApi }) {\n const analytics = configuration.shopifyAnalytics\n if (!analytics) {\n return false\n }\n\n const pageViewedEvent = await waitForPageViewedEvent(analytics)\n\n if (!isCheckoutPage(pageViewedEvent)) {\n return false\n }\n\n mockable(patchSandboxedIframeApis)()\n mockable(initShopifyBindings)(publicApi, analytics)\n\n initConfiguration.trackViewsManually = true // Views are started explicitly via startView()\n initConfiguration.sessionReplaySampleRate = 0 // Session Replay is not usable in the Pixel sandbox iframe\n initConfiguration.profilingSampleRate = 0 // Profiling is not usable in the Pixel sandbox iframe\n initConfiguration.trackUserInteractions = false // Pixel sandbox iframe has no real DOM to interact with\n initConfiguration.trackResources = false // Iframe resources are not meaningful\n initConfiguration.trackLongTasks = false // PerformanceObserver tracks the empty iframe\n initConfiguration.sessionPersistence = 'cookie'\n },\n }\n}\n"],"mappings":";;;;;;;;;;;AAiBA,SAAgB,cAAc,eAAsD;CAClF,OAAO;EACL,MAAM;EACN,MAAM,OAAO,EAAE,mBAAmB,aAAa;GAC7C,MAAM,YAAY,cAAc;GAChC,IAAI,CAAC,WACH,OAAO;GAGT,MAAM,kBAAkB,MAAMA,yBAAAA,uBAAuB,SAAS;GAE9D,IAAI,CAACC,wBAAAA,eAAe,eAAe,GACjC,OAAO;GAGT,CAAA,GAAA,sBAAA,SAAA,CAASC,iCAAAA,wBAAwB,CAAC,CAAC;GACnC,CAAA,GAAA,sBAAA,SAAA,CAASC,wBAAAA,mBAAmB,CAAC,CAAC,WAAW,SAAS;GAElD,kBAAkB,qBAAqB;GACvC,kBAAkB,0BAA0B;GAC5C,kBAAkB,sBAAsB;GACxC,kBAAkB,wBAAwB;GAC1C,kBAAkB,iBAAiB;GACnC,kBAAkB,iBAAiB;GACnC,kBAAkB,qBAAqB;EACzC;CACF;AACF"}
1
+ {"version":3,"file":"shopifyPlugin.js","names":["waitForPageViewedEvent","isCheckoutPage","patchSandboxedIframeApis","initShopifyBindings"],"sources":["../../src/domain/shopifyPlugin.ts"],"sourcesContent":["import { mockable } from '@datadog/js-core/util'\nimport type { RumPlugin } from '@datadog/browser-rum-core'\nimport { patchSandboxedIframeApis } from '../boot/patchSandboxedIframeApis'\nimport type { ShopifyAnalyticsApi } from './shopifyAnalytics'\nimport { initShopifyBindings, isCheckoutPage } from './shopifyBindings'\nimport { waitForPageViewedEvent } from './shopifyAnalytics'\n\nexport interface ShopifyPluginConfiguration {\n shopifyAnalytics: ShopifyAnalyticsApi\n}\n\n/**\n * Adapts the RUM SDK to run inside a Shopify Custom Pixel sandbox. When `shopifyAnalytics` (the\n * sandbox's `analytics` global) is provided, patches the sandboxed iframe's APIs, wires Shopify\n * Web Pixel events to the RUM public API, and forces configuration suited to that iframe (see\n * below). Storefront pages don't provide `shopifyAnalytics` and shouldn't include this plugin.\n */\nexport function shopifyPlugin(configuration: ShopifyPluginConfiguration): RumPlugin {\n return {\n name: 'shopify',\n async onInit({ initConfiguration, publicApi }) {\n const analytics = configuration.shopifyAnalytics\n if (!analytics) {\n return false\n }\n\n const pageViewedEvent = await waitForPageViewedEvent(analytics)\n\n if (!isCheckoutPage(pageViewedEvent)) {\n return false\n }\n\n mockable(patchSandboxedIframeApis)()\n mockable(initShopifyBindings)(publicApi, analytics)\n\n initConfiguration.trackViewsManually = true // Views are started explicitly via startView()\n initConfiguration.sessionReplaySampleRate = 0 // Session Replay is not usable in the Pixel sandbox iframe\n initConfiguration.profilingSampleRate = 0 // Profiling is not usable in the Pixel sandbox iframe\n initConfiguration.trackUserInteractions = false // Pixel sandbox iframe has no real DOM to interact with\n initConfiguration.trackResources = false // Iframe resources are not meaningful\n initConfiguration.trackLongTasks = false // PerformanceObserver tracks the empty iframe\n initConfiguration.sessionPersistence = 'cookie'\n },\n }\n}\n"],"mappings":";;;;;;;;;;;AAiBA,SAAgB,cAAc,eAAsD;CAClF,OAAO;EACL,MAAM;EACN,MAAM,OAAO,EAAE,mBAAmB,aAAa;GAC7C,MAAM,YAAY,cAAc;GAChC,IAAI,CAAC,WACH,OAAO;GAGT,MAAM,kBAAkB,MAAMA,yBAAAA,uBAAuB,SAAS;GAE9D,IAAI,CAACC,wBAAAA,eAAe,eAAe,GACjC,OAAO;GAGT,CAAA,GAAA,sBAAA,SAAA,CAASC,iCAAAA,wBAAwB,CAAC,CAAC;GACnC,CAAA,GAAA,sBAAA,SAAA,CAASC,wBAAAA,mBAAmB,CAAC,CAAC,WAAW,SAAS;GAElD,kBAAkB,qBAAqB;GACvC,kBAAkB,0BAA0B;GAC5C,kBAAkB,sBAAsB;GACxC,kBAAkB,wBAAwB;GAC1C,kBAAkB,iBAAiB;GACnC,kBAAkB,iBAAiB;GACnC,kBAAkB,qBAAqB;EACzC;CACF;AACF"}
@@ -1,7 +1,7 @@
1
1
  import { patchSandboxedIframeApis } from "../boot/patchSandboxedIframeApis.mjs";
2
2
  import { waitForPageViewedEvent } from "./shopifyAnalytics.mjs";
3
3
  import { initShopifyBindings, isCheckoutPage } from "./shopifyBindings.mjs";
4
- import { mockable } from "@datadog/browser-core";
4
+ import { mockable } from "@datadog/js-core/util";
5
5
  //#region src/domain/shopifyPlugin.ts
6
6
  /**
7
7
  * Adapts the RUM SDK to run inside a Shopify Custom Pixel sandbox. When `shopifyAnalytics` (the
@@ -1 +1 @@
1
- {"version":3,"file":"shopifyPlugin.mjs","names":[],"sources":["../../src/domain/shopifyPlugin.ts"],"sourcesContent":["import { mockable } from '@datadog/browser-core'\nimport type { RumPlugin } from '@datadog/browser-rum-core'\nimport { patchSandboxedIframeApis } from '../boot/patchSandboxedIframeApis'\nimport type { ShopifyAnalyticsApi } from './shopifyAnalytics'\nimport { initShopifyBindings, isCheckoutPage } from './shopifyBindings'\nimport { waitForPageViewedEvent } from './shopifyAnalytics'\n\nexport interface ShopifyPluginConfiguration {\n shopifyAnalytics: ShopifyAnalyticsApi\n}\n\n/**\n * Adapts the RUM SDK to run inside a Shopify Custom Pixel sandbox. When `shopifyAnalytics` (the\n * sandbox's `analytics` global) is provided, patches the sandboxed iframe's APIs, wires Shopify\n * Web Pixel events to the RUM public API, and forces configuration suited to that iframe (see\n * below). Storefront pages don't provide `shopifyAnalytics` and shouldn't include this plugin.\n */\nexport function shopifyPlugin(configuration: ShopifyPluginConfiguration): RumPlugin {\n return {\n name: 'shopify',\n async onInit({ initConfiguration, publicApi }) {\n const analytics = configuration.shopifyAnalytics\n if (!analytics) {\n return false\n }\n\n const pageViewedEvent = await waitForPageViewedEvent(analytics)\n\n if (!isCheckoutPage(pageViewedEvent)) {\n return false\n }\n\n mockable(patchSandboxedIframeApis)()\n mockable(initShopifyBindings)(publicApi, analytics)\n\n initConfiguration.trackViewsManually = true // Views are started explicitly via startView()\n initConfiguration.sessionReplaySampleRate = 0 // Session Replay is not usable in the Pixel sandbox iframe\n initConfiguration.profilingSampleRate = 0 // Profiling is not usable in the Pixel sandbox iframe\n initConfiguration.trackUserInteractions = false // Pixel sandbox iframe has no real DOM to interact with\n initConfiguration.trackResources = false // Iframe resources are not meaningful\n initConfiguration.trackLongTasks = false // PerformanceObserver tracks the empty iframe\n initConfiguration.sessionPersistence = 'cookie'\n },\n }\n}\n"],"mappings":";;;;;;;;;;;AAiBA,SAAgB,cAAc,eAAsD;CAClF,OAAO;EACL,MAAM;EACN,MAAM,OAAO,EAAE,mBAAmB,aAAa;GAC7C,MAAM,YAAY,cAAc;GAChC,IAAI,CAAC,WACH,OAAO;GAGT,MAAM,kBAAkB,MAAM,uBAAuB,SAAS;GAE9D,IAAI,CAAC,eAAe,eAAe,GACjC,OAAO;GAGT,SAAS,wBAAwB,CAAC,CAAC;GACnC,SAAS,mBAAmB,CAAC,CAAC,WAAW,SAAS;GAElD,kBAAkB,qBAAqB;GACvC,kBAAkB,0BAA0B;GAC5C,kBAAkB,sBAAsB;GACxC,kBAAkB,wBAAwB;GAC1C,kBAAkB,iBAAiB;GACnC,kBAAkB,iBAAiB;GACnC,kBAAkB,qBAAqB;EACzC;CACF;AACF"}
1
+ {"version":3,"file":"shopifyPlugin.mjs","names":[],"sources":["../../src/domain/shopifyPlugin.ts"],"sourcesContent":["import { mockable } from '@datadog/js-core/util'\nimport type { RumPlugin } from '@datadog/browser-rum-core'\nimport { patchSandboxedIframeApis } from '../boot/patchSandboxedIframeApis'\nimport type { ShopifyAnalyticsApi } from './shopifyAnalytics'\nimport { initShopifyBindings, isCheckoutPage } from './shopifyBindings'\nimport { waitForPageViewedEvent } from './shopifyAnalytics'\n\nexport interface ShopifyPluginConfiguration {\n shopifyAnalytics: ShopifyAnalyticsApi\n}\n\n/**\n * Adapts the RUM SDK to run inside a Shopify Custom Pixel sandbox. When `shopifyAnalytics` (the\n * sandbox's `analytics` global) is provided, patches the sandboxed iframe's APIs, wires Shopify\n * Web Pixel events to the RUM public API, and forces configuration suited to that iframe (see\n * below). Storefront pages don't provide `shopifyAnalytics` and shouldn't include this plugin.\n */\nexport function shopifyPlugin(configuration: ShopifyPluginConfiguration): RumPlugin {\n return {\n name: 'shopify',\n async onInit({ initConfiguration, publicApi }) {\n const analytics = configuration.shopifyAnalytics\n if (!analytics) {\n return false\n }\n\n const pageViewedEvent = await waitForPageViewedEvent(analytics)\n\n if (!isCheckoutPage(pageViewedEvent)) {\n return false\n }\n\n mockable(patchSandboxedIframeApis)()\n mockable(initShopifyBindings)(publicApi, analytics)\n\n initConfiguration.trackViewsManually = true // Views are started explicitly via startView()\n initConfiguration.sessionReplaySampleRate = 0 // Session Replay is not usable in the Pixel sandbox iframe\n initConfiguration.profilingSampleRate = 0 // Profiling is not usable in the Pixel sandbox iframe\n initConfiguration.trackUserInteractions = false // Pixel sandbox iframe has no real DOM to interact with\n initConfiguration.trackResources = false // Iframe resources are not meaningful\n initConfiguration.trackLongTasks = false // PerformanceObserver tracks the empty iframe\n initConfiguration.sessionPersistence = 'cookie'\n },\n }\n}\n"],"mappings":";;;;;;;;;;;AAiBA,SAAgB,cAAc,eAAsD;CAClF,OAAO;EACL,MAAM;EACN,MAAM,OAAO,EAAE,mBAAmB,aAAa;GAC7C,MAAM,YAAY,cAAc;GAChC,IAAI,CAAC,WACH,OAAO;GAGT,MAAM,kBAAkB,MAAM,uBAAuB,SAAS;GAE9D,IAAI,CAAC,eAAe,eAAe,GACjC,OAAO;GAGT,SAAS,wBAAwB,CAAC,CAAC;GACnC,SAAS,mBAAmB,CAAC,CAAC,WAAW,SAAS;GAElD,kBAAkB,qBAAqB;GACvC,kBAAkB,0BAA0B;GAC5C,kBAAkB,sBAAsB;GACxC,kBAAkB,wBAAwB;GAC1C,kBAAkB,iBAAiB;GACnC,kBAAkB,iBAAiB;GACnC,kBAAkB,qBAAqB;EACzC;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/browser-rum-shopify",
3
- "version": "7.14.0",
3
+ "version": "7.16.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "cjs/entries/main.js",
6
6
  "module": "esm/entries/main.mjs",
@@ -19,10 +19,10 @@
19
19
  "prepack": "yarn build"
20
20
  },
21
21
  "dependencies": {
22
- "@datadog/browser-core": "7.14.0",
23
- "@datadog/browser-rum": "7.14.0",
24
- "@datadog/browser-rum-core": "7.14.0",
25
- "@datadog/js-core": "0.0.15"
22
+ "@datadog/browser-core": "7.16.0",
23
+ "@datadog/browser-rum": "7.16.0",
24
+ "@datadog/browser-rum-core": "7.16.0",
25
+ "@datadog/js-core": "0.0.17"
26
26
  },
27
27
  "repository": {
28
28
  "type": "git",
@@ -1,4 +1,4 @@
1
- import { mockable } from '@datadog/browser-core'
1
+ import { mockable } from '@datadog/js-core/util'
2
2
  import type { RumPlugin } from '@datadog/browser-rum-core'
3
3
  import { patchSandboxedIframeApis } from '../boot/patchSandboxedIframeApis'
4
4
  import type { ShopifyAnalyticsApi } from './shopifyAnalytics'
@@ -1 +0,0 @@
1
- export const __webpack_esm_ids__=["datadogProfiler"];export const __webpack_esm_modules__={7492(e,t,n){n.d(t,{createRumProfiler:()=>P});var s=n(2128),a=n(8333),i=n(9305),o=n(4490),r=n(4215),l=n(3236),c=n(5648),u=n(9671),d=n(1e3);function p(){const e=(0,i.Y9)();return t=>{e.send("profile",t)}}var v=n(8633);function f(e,t,n){const s=(0,v.wP)(e,t,n,6);return({profile:e,trace:t})=>{const n={event:e,"wall-time.json":t};s.send(n)}}const m=/\/(?![vV]\d{1,2}\/)([^/\d?]*\d+[^/?]*)/g,k=(e,t)=>e||function(e){return e?e.replace(m,"/?"):"/"}(t);var b=n(98);function g(e,t,n){const s=(0,b.m5)(t),i=function(e,t,n){const{ids:s,names:a}=function(e){const t={ids:[],names:[]};for(const n of e)t.ids.push(n.viewId),n.viewName&&t.names.push(n.viewName);return t.names=Array.from(new Set(t.names)),t}(e.views),i=e.longTasks.map(e=>e.id).filter(e=>void 0!==e),o=e.actions?.map(e=>e.id).filter(e=>void 0!==e)??[],{ids:r,labels:l}=function(e){const t={ids:[],labels:[]};if(!e)return t;for(const n of e)t.ids.push(n.id),t.labels.push(n.label);return t.labels=Array.from(new Set(t.labels)),t}(e.vitals),c={application:{id:t}};return n&&(c.session={id:n}),s.length&&(c.view={id:s,name:a}),i.length&&(c.long_task={id:i}),o.length&&(c.action={id:o,label:[]}),r.length&&(c.vital={id:r,label:l}),c}(e,t.applicationId,n),o=function(e){return e.concat(["language:javascript","runtime:chrome","family:chrome","host:browser"])}(s);return{...i,attachments:["wall-time.json"],start:new Date(e.startClocks.timeStamp).toISOString(),end:new Date(e.endClocks.timeStamp).toISOString(),family:"chrome",runtime:"chrome",format:"json",version:4,tags_profiler:o.join(","),_dd:{clock_drift:(0,a._O)()}}}var _=n(603),h=n(2511);const w=_.AQ;function y(e){const t=(0,h.qj)({expireDelay:w});return e.subscribe(13,({rawRumEvent:e,startClocks:n,duration:s})=>{"long_task"===e.type&&t.add({id:e.long_task.id,startClocks:n,duration:s,entryType:e.long_task.entry_type===v.K.LONG_TASK?v.do.LONG_TASK:v.do.LONG_ANIMATION_FRAME},n.relative).close((0,a.Gw)(n.relative,s))}),t}const I=_.AQ;function C(e){const t=(0,h.qj)({expireDelay:I});return e.subscribe(16,e=>{t.add({id:e.id,label:"",startClocks:e.startClocks,duration:void 0},e.startClocks.relative)}),e.subscribe(13,({rawRumEvent:e,startClocks:n,duration:s})=>{if("action"===e.type){const i=t.getEntries(n.relative).find(t=>t.value.id===e.action.id),o=s??0;i?(i.value.duration=o,i.close((0,a.Gw)(n.relative,o))):t.add({id:e.action.id,label:"",startClocks:n,duration:s},n.relative).close((0,a.Gw)(n.relative,o))}}),t}const T=_.AQ;function D(e){const t=(0,h.qj)({expireDelay:T});return e.subscribe(17,e=>{t.add({id:e.id,type:v.DL.DURATION,startClocks:e.startClocks,duration:void 0,label:e.name},e.startClocks.relative)}),e.subscribe(13,({rawRumEvent:e,startClocks:n,duration:s})=>{if("vital"!==e.type)return;if(e.vital.type===v.DL.OPERATION_STEP){if("start"===e.vital.step_type)t.add({id:e.vital.id,type:e.vital.type,operationKey:e.vital.operation_key,startClocks:n,label:e.vital.name},n.relative);else if("end"===e.vital.step_type){const s=t.findAllEntries().find(t=>t.value.type===v.DL.OPERATION_STEP&&t.value.label===e.vital.name&&t.value.operationKey===e.vital.operation_key);if(!s)return;s.value.duration=(0,a.vk)(s.value.startClocks.relative,n.relative),s.close(n.relative)}return}const i=t.getEntries(n.relative).find(t=>t.value.id===e.vital.id);if(i)return i.value.duration=s,void i.close((0,a.Gw)(n.relative,s));t.add({id:e.vital.id,type:e.vital.type,operationKey:e.vital.operation_key,startClocks:n,duration:s,label:e.vital.name},n.relative).close((0,a.Gw)(n.relative,s))}),t}var E=n(465),S=n(5387);function q(e,t,n=5e3){const s=function(e,t){return(0,S.Hg)({proxy:e.proxy,site:e.site,path:"/api/v2/profiling/quota",parameters:"session_id="+t,subdomain:"quota"})}(e,t),a=new AbortController;let i;const o=(0,E.h)(s,{credentials:"omit",signal:a.signal,headers:new Headers({"DD-CLIENT-TOKEN":e.clientToken})}).then(e=>{const t=429===e.status?{decision:"quota_ko",reason:"quota_exceeded"}:{decision:"quota_ok",reason:"api-error"};return e.json().then(e=>((0,u.DJ)(i),function(e,t){const n=e?.data?.attributes;if(!n||"boolean"!=typeof n.admitted||"string"!=typeof n.reason)return t;const s="backend_client_not_initialized"===n.reason?"backend_unavailable":n.reason;return{decision:n.admitted?"quota_ok":"quota_ko",reason:s}}(e,t)),()=>((0,u.DJ)(i),t))}).catch(()=>((0,u.DJ)(i),{decision:"quota_ok",reason:"api-error"})),r=new Promise(e=>{i=(0,u.wg)(()=>{a.abort(),e({decision:"quota_ok",reason:"timeout"})},n)});return Promise.race([o,r])}var A=n(8032);function M(e){const t=new Map((0,A.Jv)(e)?.map(e=>[e.url,e.id])),n=[];return e.forEach((e,s)=>{const a=t.get(e);void 0!==a&&n.push({resourceId:s,debugId:a})}),n.length?n:void 0}const R={sampleIntervalMs:10,collectIntervalMs:6e4,minProfileDurationMs:5e3};function P(e,t,n,v,m,b,_=R){const h=(0,i.d0)()?(0,o.B)(p)():(0,o.B)(f)(e,t,m);let w;const I=[],T=(0,o.B)(y)(t),E=(0,o.B)(C)(t),S=(0,o.B)(D)(t);let A={state:"stopped",stateReason:"initializing"},P=0;function x(){if("running"===A.state)return;const t=b.findView();w=t?{startClocks:t.startClocks,viewId:t.id,viewName:k(t.name,document.location.pathname)}:void 0,I.push((0,l.q2)(window,"visibilitychange",B).stop,(0,l.q2)(window,"beforeunload",J).stop),N(),function(){if((0,i.d0)())return;const t=++P,s=n.findTrackedSession()?.id;s&&(0,o.B)(q)(e,s).then(e=>{t===P&&("running"!==A.state&&"paused"!==A.state||"quota_ko"===e.decision&&O("quota_ko",e.reason))}).catch(d.Dx)}()}function O(e,t){!function(e){if("running"!==A.state)return void(("paused"===A.state||"stopped"===A.state&&"stopped-by-user"===e)&&(A={state:"stopped",stateReason:e}));const t=A;A={state:"stopped",stateReason:e},t.cleanupTasks.forEach(e=>e()),"quota_ko"===e?((0,u.DJ)(t.timeoutId),t.profiler.removeEventListener("samplebufferfull",G),t.profiler.stop().catch(d.Dx)):j(t)}(e),I.forEach(e=>e()),I.length=0,v.set({status:"stopped",error_reason:void 0,quota_reason:t})}function N(){const e=s.J.Profiler;if(!e)throw v.set({status:"error",error_reason:"not-supported-by-browser"}),Error("RUM Profiler is not supported in this browser.");"running"===A.state&&j(A);const{cleanupTasks:i}=function(e){if("running"===e.state)return{cleanupTasks:e.cleanupTasks};const n=[],s=t.subscribe(2,e=>{const t={viewId:e.id,viewName:k(e.name,document.location.pathname),startClocks:e.startClocks};L(t),w=t});return n.push(s.unsubscribe),{cleanupTasks:n}}(A);let o;try{o=new e({sampleInterval:_.sampleIntervalMs,maxBufferSize:Math.round(1.5*_.collectIntervalMs/_.sampleIntervalMs)})}catch(e){return void(e instanceof Error&&e.message.includes("disabled by Document Policy")?(c.V.warn("[DD_RUM] Profiler startup failed. Ensure your server includes the `Document-Policy: js-profiling` response header when serving HTML pages.",e),v.set({status:"error",error_reason:"missing-document-policy-header"})):v.set({status:"error",error_reason:"unexpected-exception"}))}v.set({status:"running",error_reason:void 0}),A={state:"running",startClocks:(0,a.M8)(),profiler:o,timeoutId:(0,u.wg)(N,_.collectIntervalMs),views:[],cleanupTasks:i,longTasks:[],sessionId:n.findTrackedSession()?.id},L(w),o.addEventListener("samplebufferfull",G)}function j(t){(0,u.DJ)(t.timeoutId),t.profiler.removeEventListener("samplebufferfull",G);const{startClocks:n,views:s,sessionId:i}=t;t.profiler.stop().then(t=>{const o=(0,a.M8)(),r=(0,a.vk)(n.relative,o.relative),l=T.findAll(n.relative,r),c=E.findAll(n.relative,r),u=S.findAll(n.relative,r).map(e=>({id:e.id,label:e.label,startClocks:e.startClocks,duration:e.duration})),d=r<_.minProfileDurationMs;0===l.length&&d||function(t,n){const s={profile:g(t,e,n),trace:t};h(s)}(Object.assign({},t,{startClocks:n,endClocks:o,clocksOrigin:(0,a.Oc)(),longTasks:l,actions:c,vitals:u,views:s,sampleInterval:_.sampleIntervalMs,debugIds:M(t.resources)}),i)}).catch(d.Dx)}function L(e){"running"===A.state&&e&&A.views.push(e)}function G(){N()}function B(){"hidden"===document.visibilityState&&"running"===A.state?function(){if("running"!==A.state)return;const e=A;A={state:"paused"},e.cleanupTasks.forEach(e=>e()),j(e)}():"visible"===document.visibilityState&&"paused"===A.state&&N()}function J(){N()}return t.subscribe(10,()=>{O("session-expired")}),t.subscribe(11,()=>{if("stopped"===A.state&&("session-expired"===A.stateReason||"quota_ko"===A.stateReason)){const t=n.findTrackedSession();if(!t||!(0,r.$5)(t.id,(0,r.it)(e.sessionSampleRate,e.profilingSampleRate)))return;x()}}),{start:x,stop(){O("stopped-by-user")},isStopped:()=>"stopped"===A.state,isRunning:()=>"running"===A.state,isPaused:()=>"paused"===A.state}}}};
@@ -1 +0,0 @@
1
- export const __webpack_esm_ids__=["datadogRecorder"];export const __webpack_esm_modules__={8647(e,t,s){s.d(t,{startRecording:()=>y});var n=s(4023),o=s(7003),i=s(1776),a=s(2729),r=s(9305),c=s(8333),u=s(5387),d=s(7060),p=s(6448),l=s(9671),m=s(979),h=s(728);function f({context:e,creationReason:t,encoder:s}){let n=0;const o=e.view.id,i={start:1/0,end:-1/0,creation_reason:t,records_count:0,has_full_snapshot:!1,index_in_view:h.K_(o),source:"browser",...e},a=(0,d.CB)();return h.H5(o),{addRecord(e,t){i.start=Math.min(i.start,e.timestamp),i.end=Math.max(i.end,e.timestamp),i.records_count+=1,i.has_full_snapshot||(i.has_full_snapshot=e.type===m.ee.FullSnapshot||e.type===m.ee.Change&&0===i.index_in_view);const o=s.isEmpty?'{"records":[':",";s.write(o+JSON.stringify(e),e=>{n+=e,t(n)})},addStats(e){(0,d.BJ)(a,e)},flush(e){if(s.isEmpty)throw Error("Empty segment flushed");s.write(`],${JSON.stringify(i).slice(1)}\n`),s.finish(t=>{h.L7(i.view.id,t.rawBytesCount),e(i,a,t)})}}}function y(e,t,s,m,h,y,g,b){const _=[],w=t=>{e.notify(15,{error:{message:t,source:n.g.AGENT,startClocks:(0,c.M8)()}}),(0,o.A2)("Error reported to customer",{"error.message":t})},S=g||(0,i.sA)([(0,u.ns)(t,"replay")],w,6e4),x=b||(0,i.sA)([(0,u.ns)(t,"replay")],w,0);let R,D,C=a.l,v=a.l;const{unsubscribe:E}=e.subscribe(12,()=>v());if(_.push(E),(0,r.d0)())({addRecord:R}=function(e){const t=(0,r.Y9)();return{addRecord(s){const n=e.findView();t.send("record",s,n.id)}}}(m)),D=a.l;else{const n=function(e,t,s,n,o,i){return function(e,o,i,a){let r={status:0,nextSegmentCreationReason:"init"};const{unsubscribe:c}=e.subscribe(2,()=>{d("view_change")}),{unsubscribe:u}=e.subscribe(12,e=>{d(e)});function d(e){1===r.status&&(r.segment.flush((t,s,n)=>{const o=function(e,t,s,n){const o=new FormData;o.append("segment",new Blob([e],{type:"application/octet-stream"}),`${t.session.id}-${t.start}`);const i={raw_segment_size:n,compressed_segment_size:e.byteLength,...t},a=JSON.stringify(i);return o.append("event",new Blob([a],{type:"application/json"})),{data:o,bytesCount:e.byteLength,cssText:s.cssText,isFullSnapshot:0===t.index_in_view,rawSize:n,recordCount:t.records_count,serializationDuration:s.serializationDuration}}(n.output,t,s,n.rawBytesCount);(0,p.Kp)(e)&&e!==p.y5.HIDDEN?i.sendOnExit(o):i.send(o)}),(0,l.DJ)(r.expirationTimeoutId)),r="stop"!==e?{status:0,nextSegmentCreationReason:e}:{status:2}}return{addRecord(e){if(2!==r.status){if(0===r.status){const e=function(e,t,s){const n=t.findTrackedSession(),o=s.findView();if(n&&o)return{application:{id:e},session:{id:n.id},view:{id:o.id}}}(t.applicationId,s,n);if(!e)return;r={status:1,segment:f({encoder:a,context:e,creationReason:r.nextSegmentCreationReason}),expirationTimeoutId:(0,l.wg)(()=>{d("segment_duration_limit")},5e3)}}r.segment.addRecord(e,e=>{e>6e4&&d("segment_bytes_limit")})}},addStats(e){1===r.status&&r.segment.addStats(e)},stop(){d("stop"),c(),u()}}}(e,0,o,i)}(e,t,s,m,S,h);R=n.addRecord,D=n.addStats,_.push(n.stop);const i=function(e,t){if(!e.metricsEnabled)return{stop:a.l};const{unsubscribe:s}=t.subscribe(e=>{if("failure"===e.type||"queue-full"===e.type||"success"===e.type&&e.payload.isFullSnapshot){const i=(t=e.type,s=e.bandwidth,{cssText:{count:(n=e.payload).cssText.count,max:n.cssText.max,sum:n.cssText.sum},encoding:{fullSnapshot:"change",incrementalSnapshot:"change"},isFullSnapshot:n.isFullSnapshot,ongoingRequests:{count:s.ongoingRequestCount,totalSize:s.ongoingByteCount},recordCount:n.recordCount,result:t,serializationDuration:{count:n.serializationDuration.count,max:n.serializationDuration.max,sum:n.serializationDuration.sum},size:{compressed:n.bytesCount,raw:n.rawSize}});(0,o.Gk)("Segment network request metrics",{metrics:i})}var t,s,n});return{stop:s}}(y,S.observable);_.push(i.stop);const r=function(e,t,s){const n=new Set,o=new Map,{unsubscribe:i}=s.observable.subscribe(e=>{if("success"===e.type){const t=o.get(e.payload.hash);o.delete(e.payload.hash),t&&t.onDiscards.clear()}else if("queue-full"===e.type){const t=o.get(e.payload.hash);o.delete(e.payload.hash),t&&(n.delete(e.payload.hash),t.onDiscards.forEach(e=>e()))}}),{unsubscribe:a}=t.subscribe(12,e=>{(0,p.Kp)(e)&&e!==p.y5.HIDDEN&&o.forEach(({payload:e})=>s.sendOnExit(e))});return{emitResource(t,i,a){if(n.has(t))return void(a&&o.get(t)?.onDiscards.add(a));n.add(t);const r=function(e,t,s){const n=new FormData;n.append("image",t,e);const o={application:{id:s},type:"resource"};return n.append("event",new Blob([JSON.stringify(o)],{type:"application/json"})),{data:n,bytesCount:t.size,hash:e}}(t,i,e),c={payload:r,onDiscards:new Set};a&&c.onDiscards.add(a),o.set(t,c),s.send(r)},stop(){i(),a(),o.clear(),n.clear()}}}(t.applicationId,e,x);C=r.emitResource,_.push(r.stop)}const z=(0,d.g1)({emitRecord:R,emitResource:C,emitStats:D,configuration:t,lifeCycle:e,viewHistory:m});return v=z.flushMutations,{stop(){z.flushMutations(),z.stop(),_.forEach(e=>e())}}}}};