@datadog/browser-rum-shopify 7.17.1 → 7.19.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.
@@ -0,0 +1,7 @@
1
+ import type { RumPlugin } from '@datadog/browser-rum-core';
2
+ /**
3
+ * Runs the RUM SDK in the Datadog Shopify app Web Pixel extension, which Shopify runs in a Web
4
+ * Worker. Forces the configuration that works without a page: views are started manually and the
5
+ * features that need a DOM or the checkout main thread are disabled.
6
+ */
7
+ export declare function shopifyAppPixelPlugin(): RumPlugin;
@@ -0,0 +1,24 @@
1
+ // src/domain/shopifyAppPixelPlugin.ts
2
+ /**
3
+ * Runs the RUM SDK in the Datadog Shopify app Web Pixel extension, which Shopify runs in a Web
4
+ * Worker. Forces the configuration that works without a page: views are started manually and the
5
+ * features that need a DOM or the checkout main thread are disabled.
6
+ */
7
+ function shopifyAppPixelPlugin() {
8
+ return {
9
+ name: "shopify-app-pixel",
10
+ onInit({ initConfiguration }) {
11
+ initConfiguration.trackViewsManually = true;
12
+ initConfiguration.trackUserInteractions = false;
13
+ initConfiguration.trackResources = false;
14
+ initConfiguration.trackLongTasks = false;
15
+ initConfiguration.trackViewMetricsManually = true;
16
+ initConfiguration.sessionReplaySampleRate = 0;
17
+ initConfiguration.profilingSampleRate = 0;
18
+ initConfiguration.sessionPersistence = "memory";
19
+ }
20
+ };
21
+ }
22
+ exports.shopifyAppPixelPlugin = shopifyAppPixelPlugin;
23
+
24
+ //# sourceMappingURL=shopifyAppPixelPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shopifyAppPixelPlugin.js","names":[],"sources":["../../src/domain/shopifyAppPixelPlugin.ts"],"sourcesContent":["import type { RumPlugin } from '@datadog/browser-rum-core'\n\n/**\n * Runs the RUM SDK in the Datadog Shopify app Web Pixel extension, which Shopify runs in a Web\n * Worker. Forces the configuration that works without a page: views are started manually and the\n * features that need a DOM or the checkout main thread are disabled.\n */\nexport function shopifyAppPixelPlugin(): RumPlugin {\n return {\n name: 'shopify-app-pixel',\n onInit({ initConfiguration }) {\n initConfiguration.trackViewsManually = true // Views are started from Shopify `page_viewed` events\n initConfiguration.trackUserInteractions = false // The worker has no DOM to interact with\n initConfiguration.trackResources = false // The worker only sees its own requests\n initConfiguration.trackLongTasks = false // The worker does not run on the checkout main thread\n initConfiguration.trackViewMetricsManually = true // The worker has no page to measure\n initConfiguration.sessionReplaySampleRate = 0 // Session Replay needs a DOM\n initConfiguration.profilingSampleRate = 0 // Profiling does not see the checkout main thread\n initConfiguration.sessionPersistence = 'memory' // The worker has no cookies\n },\n }\n}\n"],"mappings":";;;;;;AAOA,SAAgB,wBAAmC;CACjD,OAAO;EACL,MAAM;EACN,OAAO,EAAE,qBAAqB;GAC5B,kBAAkB,qBAAqB;GACvC,kBAAkB,wBAAwB;GAC1C,kBAAkB,iBAAiB;GACnC,kBAAkB,iBAAiB;GACnC,kBAAkB,2BAA2B;GAC7C,kBAAkB,0BAA0B;GAC5C,kBAAkB,sBAAsB;GACxC,kBAAkB,qBAAqB;EACzC;CACF;AACF"}
@@ -1,6 +1,6 @@
1
1
  const require_patchSandboxedIframeApis = require("../boot/patchSandboxedIframeApis.js");
2
- const require_shopifyAnalytics = require("./shopifyAnalytics.js");
3
2
  const require_shopifyBindings = require("./shopifyBindings.js");
3
+ const require_shopifyAnalytics = require("./shopifyAnalytics.js");
4
4
  let _datadog_js_core_util = require("@datadog/js-core/util");
5
5
  // src/domain/shopifyPlugin.ts
6
6
  /**
@@ -1,4 +1,5 @@
1
1
  const require_shopifyPlugin = require("../domain/shopifyPlugin.js");
2
+ const require_shopifyAppPixelPlugin = require("../domain/shopifyAppPixelPlugin.js");
2
3
  let _datadog_js_core_util = require("@datadog/js-core/util");
3
4
  let _datadog_browser_core = require("@datadog/browser-core");
4
5
  let _datadog_browser_rum_core = require("@datadog/browser-rum-core");
@@ -7,6 +8,7 @@ let _datadog_browser_rum_internal = require("@datadog/browser-rum/internal");
7
8
  const global = _datadog_js_core_util.globalObject;
8
9
  const datadogRum = (0, _datadog_browser_rum_core.makeRumPublicApi)((0, _datadog_browser_rum_internal.makeRecorderApi)(), (0, _datadog_browser_rum_internal.makeProfilerApi)(), { sdkName: "rum-shopify" });
9
10
  datadogRum.shopifyPlugin = require_shopifyPlugin.shopifyPlugin;
11
+ datadogRum.shopifyAppPixelPlugin = require_shopifyAppPixelPlugin.shopifyAppPixelPlugin;
10
12
  (0, _datadog_browser_core.defineGlobal)(global, "DD_RUM", datadogRum);
11
13
 
12
14
  //# sourceMappingURL=main.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","names":["globalObject","makeRumPublicApi","makeRecorderApi","makeProfilerApi","shopifyPlugin","defineGlobal"],"sources":["../../src/entries/main.ts"],"sourcesContent":["import { globalObject } from '@datadog/js-core/util'\nimport { defineGlobal } 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 { shopifyPlugin } from '../domain/shopifyPlugin'\n\ntype ShopifyRumPublicApi = RumPublicApi & { shopifyPlugin: typeof shopifyPlugin }\n\ninterface BrowserWindow {\n DD_RUM?: ShopifyRumPublicApi\n}\n\nconst global = globalObject as BrowserWindow\n\nconst datadogRum = makeRumPublicApi(makeRecorderApi(), makeProfilerApi(), {\n sdkName: 'rum-shopify',\n}) as ShopifyRumPublicApi\n\ndatadogRum.shopifyPlugin = shopifyPlugin\n\ndefineGlobal(global, 'DD_RUM', datadogRum)\n"],"mappings":";;;;;;AAaA,MAAM,SAASA,sBAAAA;AAEf,MAAM,cAAA,GAAaC,0BAAAA,iBAAAA,EAAAA,GAAiBC,8BAAAA,gBAAAA,CAAgB,IAAA,GAAGC,8BAAAA,gBAAAA,CAAgB,GAAG,EACxE,SAAS,cACX,CAAC;AAED,WAAW,gBAAgBC,sBAAAA;CAE3BC,GAAAA,sBAAAA,aAAAA,CAAa,QAAQ,UAAU,UAAU"}
1
+ {"version":3,"file":"main.js","names":["globalObject","makeRumPublicApi","makeRecorderApi","makeProfilerApi","shopifyPlugin","shopifyAppPixelPlugin","defineGlobal"],"sources":["../../src/entries/main.ts"],"sourcesContent":["import { globalObject } from '@datadog/js-core/util'\nimport { defineGlobal } 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 { shopifyPlugin } from '../domain/shopifyPlugin'\nimport { shopifyAppPixelPlugin } from '../domain/shopifyAppPixelPlugin'\n\ntype ShopifyRumPublicApi = RumPublicApi & {\n shopifyPlugin: typeof shopifyPlugin\n shopifyAppPixelPlugin: typeof shopifyAppPixelPlugin\n}\n\ninterface BrowserWindow {\n DD_RUM?: ShopifyRumPublicApi\n}\n\nconst global = globalObject as BrowserWindow\n\nconst datadogRum = makeRumPublicApi(makeRecorderApi(), makeProfilerApi(), {\n sdkName: 'rum-shopify',\n}) as ShopifyRumPublicApi\n\ndatadogRum.shopifyPlugin = shopifyPlugin\ndatadogRum.shopifyAppPixelPlugin = shopifyAppPixelPlugin\n\ndefineGlobal(global, 'DD_RUM', datadogRum)\n"],"mappings":";;;;;;;AAiBA,MAAM,SAASA,sBAAAA;AAEf,MAAM,cAAA,GAAaC,0BAAAA,iBAAAA,EAAAA,GAAiBC,8BAAAA,gBAAAA,CAAgB,IAAA,GAAGC,8BAAAA,gBAAAA,CAAgB,GAAG,EACxE,SAAS,cACX,CAAC;AAED,WAAW,gBAAgBC,sBAAAA;AAC3B,WAAW,wBAAwBC,8BAAAA;CAEnCC,GAAAA,sBAAAA,aAAAA,CAAa,QAAQ,UAAU,UAAU"}
@@ -0,0 +1,24 @@
1
+ // src/domain/shopifyAppPixelPlugin.ts
2
+ /**
3
+ * Runs the RUM SDK in the Datadog Shopify app Web Pixel extension, which Shopify runs in a Web
4
+ * Worker. Forces the configuration that works without a page: views are started manually and the
5
+ * features that need a DOM or the checkout main thread are disabled.
6
+ */
7
+ function shopifyAppPixelPlugin() {
8
+ return {
9
+ name: "shopify-app-pixel",
10
+ onInit({ initConfiguration }) {
11
+ initConfiguration.trackViewsManually = true;
12
+ initConfiguration.trackUserInteractions = false;
13
+ initConfiguration.trackResources = false;
14
+ initConfiguration.trackLongTasks = false;
15
+ initConfiguration.trackViewMetricsManually = true;
16
+ initConfiguration.sessionReplaySampleRate = 0;
17
+ initConfiguration.profilingSampleRate = 0;
18
+ initConfiguration.sessionPersistence = "memory";
19
+ }
20
+ };
21
+ }
22
+ export { shopifyAppPixelPlugin };
23
+
24
+ //# sourceMappingURL=shopifyAppPixelPlugin.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shopifyAppPixelPlugin.mjs","names":[],"sources":["../../src/domain/shopifyAppPixelPlugin.ts"],"sourcesContent":["import type { RumPlugin } from '@datadog/browser-rum-core'\n\n/**\n * Runs the RUM SDK in the Datadog Shopify app Web Pixel extension, which Shopify runs in a Web\n * Worker. Forces the configuration that works without a page: views are started manually and the\n * features that need a DOM or the checkout main thread are disabled.\n */\nexport function shopifyAppPixelPlugin(): RumPlugin {\n return {\n name: 'shopify-app-pixel',\n onInit({ initConfiguration }) {\n initConfiguration.trackViewsManually = true // Views are started from Shopify `page_viewed` events\n initConfiguration.trackUserInteractions = false // The worker has no DOM to interact with\n initConfiguration.trackResources = false // The worker only sees its own requests\n initConfiguration.trackLongTasks = false // The worker does not run on the checkout main thread\n initConfiguration.trackViewMetricsManually = true // The worker has no page to measure\n initConfiguration.sessionReplaySampleRate = 0 // Session Replay needs a DOM\n initConfiguration.profilingSampleRate = 0 // Profiling does not see the checkout main thread\n initConfiguration.sessionPersistence = 'memory' // The worker has no cookies\n },\n }\n}\n"],"mappings":";;;;;;AAOA,SAAgB,wBAAmC;CACjD,OAAO;EACL,MAAM;EACN,OAAO,EAAE,qBAAqB;GAC5B,kBAAkB,qBAAqB;GACvC,kBAAkB,wBAAwB;GAC1C,kBAAkB,iBAAiB;GACnC,kBAAkB,iBAAiB;GACnC,kBAAkB,2BAA2B;GAC7C,kBAAkB,0BAA0B;GAC5C,kBAAkB,sBAAsB;GACxC,kBAAkB,qBAAqB;EACzC;CACF;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { patchSandboxedIframeApis } from "../boot/patchSandboxedIframeApis.mjs";
2
- import { waitForPageViewedEvent } from "./shopifyAnalytics.mjs";
3
2
  import { initShopifyBindings, isCheckoutPage } from "./shopifyBindings.mjs";
3
+ import { waitForPageViewedEvent } from "./shopifyAnalytics.mjs";
4
4
  import { mockable } from "@datadog/js-core/util";
5
5
  // src/domain/shopifyPlugin.ts
6
6
  /**
@@ -1,4 +1,5 @@
1
1
  import { shopifyPlugin } from "../domain/shopifyPlugin.mjs";
2
+ import { shopifyAppPixelPlugin } from "../domain/shopifyAppPixelPlugin.mjs";
2
3
  import { globalObject } from "@datadog/js-core/util";
3
4
  import { defineGlobal } from "@datadog/browser-core";
4
5
  import { makeRumPublicApi } from "@datadog/browser-rum-core";
@@ -7,6 +8,7 @@ import { makeProfilerApi, makeRecorderApi } from "@datadog/browser-rum/internal"
7
8
  const global = globalObject;
8
9
  const datadogRum = makeRumPublicApi(makeRecorderApi(), makeProfilerApi(), { sdkName: "rum-shopify" });
9
10
  datadogRum.shopifyPlugin = shopifyPlugin;
11
+ datadogRum.shopifyAppPixelPlugin = shopifyAppPixelPlugin;
10
12
  defineGlobal(global, "DD_RUM", datadogRum);
11
13
 
12
14
  //# sourceMappingURL=main.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"main.mjs","names":[],"sources":["../../src/entries/main.ts"],"sourcesContent":["import { globalObject } from '@datadog/js-core/util'\nimport { defineGlobal } 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 { shopifyPlugin } from '../domain/shopifyPlugin'\n\ntype ShopifyRumPublicApi = RumPublicApi & { shopifyPlugin: typeof shopifyPlugin }\n\ninterface BrowserWindow {\n DD_RUM?: ShopifyRumPublicApi\n}\n\nconst global = globalObject as BrowserWindow\n\nconst datadogRum = makeRumPublicApi(makeRecorderApi(), makeProfilerApi(), {\n sdkName: 'rum-shopify',\n}) as ShopifyRumPublicApi\n\ndatadogRum.shopifyPlugin = shopifyPlugin\n\ndefineGlobal(global, 'DD_RUM', datadogRum)\n"],"mappings":";;;;;;AAaA,MAAM,SAAS;AAEf,MAAM,aAAa,iBAAiB,gBAAgB,GAAG,gBAAgB,GAAG,EACxE,SAAS,cACX,CAAC;AAED,WAAW,gBAAgB;AAE3B,aAAa,QAAQ,UAAU,UAAU"}
1
+ {"version":3,"file":"main.mjs","names":[],"sources":["../../src/entries/main.ts"],"sourcesContent":["import { globalObject } from '@datadog/js-core/util'\nimport { defineGlobal } 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 { shopifyPlugin } from '../domain/shopifyPlugin'\nimport { shopifyAppPixelPlugin } from '../domain/shopifyAppPixelPlugin'\n\ntype ShopifyRumPublicApi = RumPublicApi & {\n shopifyPlugin: typeof shopifyPlugin\n shopifyAppPixelPlugin: typeof shopifyAppPixelPlugin\n}\n\ninterface BrowserWindow {\n DD_RUM?: ShopifyRumPublicApi\n}\n\nconst global = globalObject as BrowserWindow\n\nconst datadogRum = makeRumPublicApi(makeRecorderApi(), makeProfilerApi(), {\n sdkName: 'rum-shopify',\n}) as ShopifyRumPublicApi\n\ndatadogRum.shopifyPlugin = shopifyPlugin\ndatadogRum.shopifyAppPixelPlugin = shopifyAppPixelPlugin\n\ndefineGlobal(global, 'DD_RUM', datadogRum)\n"],"mappings":";;;;;;;AAiBA,MAAM,SAAS;AAEf,MAAM,aAAa,iBAAiB,gBAAgB,GAAG,gBAAgB,GAAG,EACxE,SAAS,cACX,CAAC;AAED,WAAW,gBAAgB;AAC3B,WAAW,wBAAwB;AAEnC,aAAa,QAAQ,UAAU,UAAU"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/browser-rum-shopify",
3
- "version": "7.17.1",
3
+ "version": "7.19.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.17.1",
23
- "@datadog/browser-rum": "7.17.1",
24
- "@datadog/browser-rum-core": "7.17.1",
25
- "@datadog/js-core": "0.0.21"
22
+ "@datadog/browser-core": "7.19.0",
23
+ "@datadog/browser-rum": "7.19.0",
24
+ "@datadog/browser-rum-core": "7.19.0",
25
+ "@datadog/js-core": "0.0.23"
26
26
  },
27
27
  "repository": {
28
28
  "type": "git",
@@ -0,0 +1,22 @@
1
+ import type { RumPlugin } from '@datadog/browser-rum-core'
2
+
3
+ /**
4
+ * Runs the RUM SDK in the Datadog Shopify app Web Pixel extension, which Shopify runs in a Web
5
+ * Worker. Forces the configuration that works without a page: views are started manually and the
6
+ * features that need a DOM or the checkout main thread are disabled.
7
+ */
8
+ export function shopifyAppPixelPlugin(): RumPlugin {
9
+ return {
10
+ name: 'shopify-app-pixel',
11
+ onInit({ initConfiguration }) {
12
+ initConfiguration.trackViewsManually = true // Views are started from Shopify `page_viewed` events
13
+ initConfiguration.trackUserInteractions = false // The worker has no DOM to interact with
14
+ initConfiguration.trackResources = false // The worker only sees its own requests
15
+ initConfiguration.trackLongTasks = false // The worker does not run on the checkout main thread
16
+ initConfiguration.trackViewMetricsManually = true // The worker has no page to measure
17
+ initConfiguration.sessionReplaySampleRate = 0 // Session Replay needs a DOM
18
+ initConfiguration.profilingSampleRate = 0 // Profiling does not see the checkout main thread
19
+ initConfiguration.sessionPersistence = 'memory' // The worker has no cookies
20
+ },
21
+ }
22
+ }
@@ -4,8 +4,12 @@ import type { RumPublicApi } from '@datadog/browser-rum-core'
4
4
  import { makeRumPublicApi } from '@datadog/browser-rum-core'
5
5
  import { makeRecorderApi, makeProfilerApi } from '@datadog/browser-rum/internal'
6
6
  import { shopifyPlugin } from '../domain/shopifyPlugin'
7
+ import { shopifyAppPixelPlugin } from '../domain/shopifyAppPixelPlugin'
7
8
 
8
- type ShopifyRumPublicApi = RumPublicApi & { shopifyPlugin: typeof shopifyPlugin }
9
+ type ShopifyRumPublicApi = RumPublicApi & {
10
+ shopifyPlugin: typeof shopifyPlugin
11
+ shopifyAppPixelPlugin: typeof shopifyAppPixelPlugin
12
+ }
9
13
 
10
14
  interface BrowserWindow {
11
15
  DD_RUM?: ShopifyRumPublicApi
@@ -18,5 +22,6 @@ const datadogRum = makeRumPublicApi(makeRecorderApi(), makeProfilerApi(), {
18
22
  }) as ShopifyRumPublicApi
19
23
 
20
24
  datadogRum.shopifyPlugin = shopifyPlugin
25
+ datadogRum.shopifyAppPixelPlugin = shopifyAppPixelPlugin
21
26
 
22
27
  defineGlobal(global, 'DD_RUM', datadogRum)
@@ -1 +0,0 @@
1
- export const __webpack_esm_ids__=["datadogProfiler"];export const __webpack_esm_modules__={7492(e,t,n){n.d(t,{createRumProfiler:()=>O});var s=n(5762),o=n(2128),a=n(8975),r=n(449),i=n(8333),l=n(9305),c=n(4215),u=n(5648),d=n(1e3);function p(){const e=(0,l.Y9)();return t=>{e.send("profile",t)}}var f=n(6196);function v(e,t,n){const s=(0,f.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),o=function(e,t,n){const{ids:s,names:o}=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),a=e.longTasks.map(e=>e.id).filter(e=>void 0!==e),r=e.actions?.map(e=>e.id).filter(e=>void 0!==e)??[],{ids:i,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:o}),a.length&&(c.long_task={id:a}),r.length&&(c.action={id:r,label:[]}),i.length&&(c.vital={id:i,label:l}),c}(e,t.applicationId,n),a=function(e){return e.concat(["language:javascript","runtime:chrome","family:chrome","host:browser"])}(s);return{...o,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:a.join(","),_dd:{clock_drift:(0,i._O)()}}}var _=n(603),h=n(2511);const w=_.AQ;function y(e){const t=(0,h.qj)({expireDelay:w});return e.subscribe(12,({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===f.K.LONG_TASK?f.do.LONG_TASK:f.do.LONG_ANIMATION_FRAME},n.relative).close((0,i.Gw)(n.relative,s))}),t}const C=_.AQ;function I(e){const t=(0,h.qj)({expireDelay:C});return e.subscribe(15,e=>{t.add({id:e.id,label:"",startClocks:e.startClocks,duration:void 0},e.startClocks.relative)}),e.subscribe(12,({rawRumEvent:e,startClocks:n,duration:s})=>{if("action"===e.type){const o=t.getEntries(n.relative).find(t=>t.value.id===e.action.id),a=s??0;o?(o.value.duration=a,o.close((0,i.Gw)(n.relative,a))):t.add({id:e.action.id,label:"",startClocks:n,duration:s},n.relative).close((0,i.Gw)(n.relative,a))}}),t}const T=_.AQ;function D(e){const t=(0,h.qj)({expireDelay:T});return e.subscribe(16,e=>{t.add({id:e.id,type:f.DL.DURATION,startClocks:e.startClocks,duration:void 0,label:e.name},e.startClocks.relative)}),e.subscribe(12,({rawRumEvent:e,startClocks:n,duration:s})=>{if("vital"!==e.type)return;if(e.vital.type===f.DL.WEBSOCKET)return;const o=e.vital;if(o.type===f.DL.OPERATION_STEP){if("start"===o.step_type)t.add({id:o.id,type:o.type,operationKey:o.operation_key,startClocks:n,label:o.name},n.relative);else if("end"===o.step_type){const e=t.findAllEntries().find(e=>e.value.type===f.DL.OPERATION_STEP&&e.value.label===o.name&&e.value.operationKey===o.operation_key);if(!e)return;e.value.duration=(0,i.vk)(e.value.startClocks.relative,n.relative),e.close(n.relative)}return}const a=t.getEntries(n.relative).find(e=>e.value.id===o.id);if(a)return a.value.duration=s,void a.close((0,i.Gw)(n.relative,s));t.add({id:o.id,type:o.type,operationKey:o.operation_key,startClocks:n,duration:s,label:o.name},n.relative).close((0,i.Gw)(n.relative,s))}),t}var E=n(5358),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),o=new AbortController;let r;const i=(0,E.h)(s,{credentials:"omit",signal:o.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,a.DJ)(r),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,a.DJ)(r),t))}).catch(()=>((0,a.DJ)(r),{decision:"quota_ok",reason:"api-error"})),l=new Promise(e=>{r=(0,a.wg)(()=>{o.abort(),e({decision:"quota_ok",reason:"timeout"})},n)});return Promise.race([i,l])}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 o=t.get(e);void 0!==o&&n.push({resourceId:s,debugId:o})}),n.length?n:void 0}const R={sampleIntervalMs:10,collectIntervalMs:6e4,minProfileDurationMs:5e3};function O(e,t,n,f,m,b,_=R){const h=(0,l.d0)()?(0,s.B)(p)():(0,s.B)(v)(e,t,m);let w;const C=[],T=(0,s.B)(y)(t),E=(0,s.B)(I)(t),S=(0,s.B)(D)(t);let A={state:"stopped",stateReason:"initializing"},O=0;function P(){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,C.push((0,r.q2)(window,"visibilitychange",G).stop,(0,r.q2)(window,"beforeunload",K).stop),N(),function(){if((0,l.d0)())return;const t=++O,o=n.findTrackedSession()?.id;o&&(0,s.B)(q)(e,o).then(e=>{t===O&&("running"!==A.state&&"paused"!==A.state||"quota_ko"===e.decision&&x("quota_ko",e.reason))}).catch(d.Dx)}()}function x(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,a.DJ)(t.timeoutId),t.profiler.removeEventListener("samplebufferfull",B),t.profiler.stop().catch(d.Dx)):L(t)}(e),C.forEach(e=>e()),C.length=0,f.set({status:"stopped",error_reason:void 0,quota_reason:t})}function N(){const e=o.J.Profiler;if(!e)throw f.set({status:"error",error_reason:"not-supported-by-browser"}),Error("RUM Profiler is not supported in this browser.");"running"===A.state&&L(A);const{cleanupTasks:s}=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};j(t),w=t});return n.push(s.unsubscribe),{cleanupTasks:n}}(A);let r;try{r=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")?(u.V.warn("[DD_RUM] Profiler startup failed. Ensure your server includes the `Document-Policy: js-profiling` response header when serving HTML pages.",e),f.set({status:"error",error_reason:"missing-document-policy-header"})):f.set({status:"error",error_reason:"unexpected-exception"}))}f.set({status:"running",error_reason:void 0}),A={state:"running",startClocks:(0,i.M8)(),profiler:r,timeoutId:(0,a.wg)(N,_.collectIntervalMs),views:[],cleanupTasks:s,longTasks:[],sessionId:n.findTrackedSession()?.id},j(w),r.addEventListener("samplebufferfull",B)}function L(t){(0,a.DJ)(t.timeoutId),t.profiler.removeEventListener("samplebufferfull",B);const{startClocks:n,views:s,sessionId:o}=t;t.profiler.stop().then(t=>{const a=(0,i.M8)(),r=(0,i.vk)(n.relative,a.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:a,clocksOrigin:(0,i.Oc)(),longTasks:l,actions:c,vitals:u,views:s,sampleInterval:_.sampleIntervalMs,debugIds:M(t.resources)}),o)}).catch(d.Dx)}function j(e){"running"===A.state&&e&&A.views.push(e)}function B(){N()}function G(){"hidden"===document.visibilityState&&"running"===A.state?function(){if("running"!==A.state)return;const e=A;A={state:"paused"},e.cleanupTasks.forEach(e=>e()),L(e)}():"visible"===document.visibilityState&&"paused"===A.state&&N()}function K(){N()}return t.subscribe(9,()=>{x("session-expired")}),t.subscribe(10,()=>{if("stopped"===A.state&&("session-expired"===A.stateReason||"quota_ko"===A.stateReason)){const t=n.findTrackedSession();if(!t||!(0,c.$5)(t.id,(0,c.it)(e.sessionSampleRate,e.profilingSampleRate)))return;P()}}),{start:P,stop(){x("stopped-by-user")},isStopped:()=>"stopped"===A.state,isRunning:()=>"running"===A.state,isPaused:()=>"paused"===A.state}}}};