@datadog/browser-rum-shopify 7.18.0 → 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 @@
1
+ export const __webpack_esm_ids__=["datadogProfiler"];export const __webpack_esm_modules__={740(e,t,n){n.d(t,{createRumProfiler:()=>L});var r=n(5762),i=n(2128),s=n(8975),o=n(449),a=n(8333),l=n(9305),c=n(4215),d=n(5648),u=n(1e3),p=n(5358),f=n(5387);function v(e,t,n=5e3){const r=function(e,t){return(0,f.Hg)({proxy:e.proxy,site:e.site,path:"/api/v2/profiling/quota",parameters:"session_id="+t,subdomain:"quota"})}(e,t),i=new AbortController;let o;const a=(0,p.h)(r,{credentials:"omit",signal:i.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,s.DJ)(o),function(e,t){const n=e?.data?.attributes;if(!n||"boolean"!=typeof n.admitted||"string"!=typeof n.reason)return t;const r="backend_client_not_initialized"===n.reason?"backend_unavailable":n.reason;return{decision:n.admitted?"quota_ok":"quota_ko",reason:r}}(e,t)),()=>((0,s.DJ)(o),t))}).catch(()=>((0,s.DJ)(o),{decision:"quota_ok",reason:"api-error"})),l=new Promise(e=>{o=(0,s.wg)(()=>{i.abort(),e({decision:"quota_ok",reason:"timeout"})},n)});return Promise.race([a,l])}var m=n(603),b=n(2511),k=n(4822);const _=m.AQ;function g(e){const t=(0,b.qj)({expireDelay:_});return e.subscribe(12,({rawRumEvent:e,startClocks:n,duration:r})=>{"long_task"===e.type&&t.add({id:e.long_task.id,startClocks:n,duration:r,entryType:e.long_task.entry_type===k.K.LONG_TASK?k.do.LONG_TASK:k.do.LONG_ANIMATION_FRAME},n.relative).close((0,a.Gw)(n.relative,r))}),t}const y=m.AQ;function w(e){const t=(0,b.qj)({expireDelay:y});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:r})=>{if("action"===e.type){const i=t.getEntries(n.relative).find(t=>t.value.id===e.action.id),s=r??0;i?(i.value.duration=s,i.close((0,a.Gw)(n.relative,s))):t.add({id:e.action.id,label:"",startClocks:n,duration:r},n.relative).close((0,a.Gw)(n.relative,s))}}),t}const h=m.AQ;function C(e){const t=(0,b.qj)({expireDelay:h});return e.subscribe(16,e=>{t.add({id:e.id,type:k.DL.DURATION,startClocks:e.startClocks,duration:void 0,label:e.name},e.startClocks.relative)}),e.subscribe(12,({rawRumEvent:e,startClocks:n,duration:r})=>{if("vital"!==e.type)return;if(e.vital.type===k.DL.WEBSOCKET)return;const i=e.vital;if(i.type===k.DL.OPERATION_STEP){if("start"===i.step_type)t.add({id:i.id,type:i.type,operationKey:i.operation_key,startClocks:n,label:i.name},n.relative);else if("end"===i.step_type){const e=t.findAllEntries().find(e=>e.value.type===k.DL.OPERATION_STEP&&e.value.label===i.name&&e.value.operationKey===i.operation_key);if(!e)return;e.value.duration=(0,a.vk)(e.value.startClocks.relative,n.relative),e.close(n.relative)}return}const s=t.getEntries(n.relative).find(e=>e.value.id===i.id);if(s)return s.value.duration=r,void s.close((0,a.Gw)(n.relative,r));t.add({id:i.id,type:i.type,operationKey:i.operation_key,startClocks:n,duration:r,label:i.name},n.relative).close((0,a.Gw)(n.relative,r))}),t}function I(e,t){const n=(0,b.qj)({expireDelay:m.AQ}),s=t.findView();function o(e){n.add({viewId:e.id,viewName:D(e.name,(0,r.B)(i.J.location).pathname),startClocks:e.startClocks},e.startClocks.relative)}return s&&o(s),e.subscribe(2,o),e.subscribe(6,({endClocks:e})=>{n.closeActive(e.relative)}),n}const D=(e,t)=>e||function(e){return e?e.replace(E,"/?"):"/"}(t),E=/\/(?![vV]\d{1,2}\/)([^/\d?]*\d+[^/?]*)/g;var S=n(8032);function A(e){const t=new Map((0,S.Jv)(e)?.map(e=>[e.url,e.id])),n=[];return e.forEach((e,r)=>{const i=t.get(e);void 0!==i&&n.push({resourceId:r,debugId:i})}),n.length?n:void 0}var q=n(98);function T(e,t,n){const r=(0,q.m5)(t),i=function({views:e,longTasks:t,actions:n,vitals:r},i,s){const o=t.map(({id:e})=>e).filter(e=>void 0!==e),a=n?.map(({id:e})=>e)??[];return{application:{id:i},session:s?{id:s}:void 0,view:M(e),long_task:o.length?{id:o}:void 0,action:a.length?{id:a,label:[]}:void 0,vital:R(r)}}(e,t.applicationId,n),s=function(e){return e.concat(["language:javascript","runtime:chrome","family:chrome","host:browser"])}(r);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:s.join(","),_dd:{clock_drift:(0,a._O)()}}}function M(e){if(e.length)return{id:e.map(({viewId:e})=>e),name:Array.from(new Set(e.map(({viewName:e})=>e).filter(e=>!!e)))}}function R(e){if(e?.length)return{id:e.map(({id:e})=>e),label:Array.from(new Set(e.map(({label:e})=>e)))}}function x(){const e=(0,l.Y9)();return t=>{e.send("profile",t)}}function P(e,t,n){const r=(0,k.wP)(e,t,n,6);return({profile:e,trace:t})=>{const n={event:e,"wall-time.json":t};r.send(n)}}const O={sampleIntervalMs:10,collectIntervalMs:6e4,minProfileDurationMs:5e3};function L(e,t,n,p,f,m,b=O){const k=(0,l.d0)()?(0,r.B)(x)():(0,r.B)(P)(e,t,f),_=function(e,t,n,i,s){const o=(0,r.B)(g)(t),l=(0,r.B)(w)(t),c=(0,r.B)(C)(t),d=(0,r.B)(I)(t,n);return{assemble(t,n,r,u){const p=(0,a.vk)(n.relative,r.relative),f=d.findAll(n.relative,p).reverse(),v=o.findAll(n.relative,p),m=l.findAll(n.relative,p),b=c.findAll(n.relative,p).map(e=>({id:e.id,label:e.label,startClocks:e.startClocks,duration:e.duration})),k=p<i.minProfileDurationMs;if(0===v.length&&k)return;const _={...t,startClocks:n,endClocks:r,clocksOrigin:(0,a.Oc)(),longTasks:v,actions:m,vitals:b,views:f,sampleInterval:i.sampleIntervalMs,debugIds:A(t.resources)};s({profile:T(_,e,u),trace:_})}}}(e,t,m,b,k),y=[];let h={state:"stopped",stateReason:"initializing"},D=0;function E(){"running"!==h.state&&(y.push((0,o.q2)(window,"visibilitychange",L).stop,(0,o.q2)(window,"beforeunload",N).stop),q(),function(){if((0,l.d0)())return;const t=++D,i=n.findTrackedSession()?.id;i&&(0,r.B)(v)(e,i).then(e=>{t===D&&("running"!==h.state&&"paused"!==h.state||"quota_ko"===e.decision&&S("quota_ko",e.reason))}).catch(u.Dx)}())}function S(e,t){!function(e){if("running"!==h.state)return void(("paused"===h.state||"stopped"===h.state&&"stopped-by-user"===e)&&(h={state:"stopped",stateReason:e}));const t=h;h={state:"stopped",stateReason:e},"quota_ko"===e?((0,s.DJ)(t.timeoutId),t.profiler.removeEventListener("samplebufferfull",R),t.profiler.stop().catch(u.Dx)):M(t)}(e),y.forEach(e=>e()),y.length=0,p.set({status:"stopped",error_reason:void 0,quota_reason:t})}function q(){const e=i.J.Profiler;if(!e)throw p.set({status:"error",error_reason:"not-supported-by-browser"}),Error("RUM Profiler is not supported in this browser.");let t;"running"===h.state&&M(h);try{t=new e({sampleInterval:b.sampleIntervalMs,maxBufferSize:Math.round(1.5*b.collectIntervalMs/b.sampleIntervalMs)})}catch(e){return void(e instanceof Error&&e.message.includes("disabled by Document Policy")?(d.V.warn("[DD_RUM] Profiler startup failed. Ensure your server includes the `Document-Policy: js-profiling` response header when serving HTML pages.",e),p.set({status:"error",error_reason:"missing-document-policy-header"})):p.set({status:"error",error_reason:"unexpected-exception"}))}p.set({status:"running",error_reason:void 0}),h={state:"running",startClocks:(0,a.M8)(),profiler:t,timeoutId:(0,s.wg)(q,b.collectIntervalMs),sessionId:n.findTrackedSession()?.id},t.addEventListener("samplebufferfull",R)}function M(e){(0,s.DJ)(e.timeoutId),e.profiler.removeEventListener("samplebufferfull",R);const{startClocks:t,sessionId:n}=e,r=(0,a.M8)();e.profiler.stop().then(e=>{_.assemble(e,t,r,n)}).catch(u.Dx)}function R(){q()}function L(){"hidden"===document.visibilityState&&"running"===h.state?function(){if("running"!==h.state)return;const e=h;h={state:"paused"},M(e)}():"visible"===document.visibilityState&&"paused"===h.state&&q()}function N(){q()}return t.subscribe(9,()=>{S("session-expired")}),t.subscribe(10,()=>{if("stopped"===h.state&&("session-expired"===h.stateReason||"quota_ko"===h.stateReason)){const t=n.findTrackedSession();if(!t||!(0,c.$5)(t.id,(0,c.it)(e.sessionSampleRate,e.profilingSampleRate)))return;E()}}),{start:E,stop(){S("stopped-by-user")},isStopped:()=>"stopped"===h.state,isRunning:()=>"running"===h.state,isPaused:()=>"paused"===h.state}}}};