@datadog/browser-rum-shopify 7.16.0 → 7.16.1

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__={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(8637);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}}}};
@@ -1 +1 @@
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(6448),c=s(9305),u=s(8333),d=s(5387),p=s(7923),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,p.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,p.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(14,{error:{message:t,source:n.g.AGENT,startClocks:(0,u.M8)()}}),(0,o.A2)("Error reported to customer",{"error.message":t})},S=g||(0,i.sA)([(0,d.ns)(t,"replay")],w,6e4),x=b||(0,i.sA)([(0,d.ns)(t,"replay")],w,0);let E,R,D=a.l,C=a.l;const{unsubscribe:T}=e.subscribe(11,e=>{e!==r.y5.PAGE_TERMINATED&&C()});if(_.push(T),(0,c.d0)())({addRecord:E}=function(e){const t=(0,c.Y9)();return{addRecord(s){const n=e.findView();t.send("record",s,n.id)}}}(m)),R=a.l;else{const n=function(e,t,s,n,o,i){return function(e,o,i,a){let c={status:0,nextSegmentCreationReason:"init"};const{unsubscribe:u}=e.subscribe(2,()=>{p("view_change")}),{unsubscribe:d}=e.subscribe(11,e=>{e!==r.y5.PAGE_TERMINATED&&p(e)});function p(e){1===c.status&&(c.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,r.Kp)(e)&&e!==r.y5.HIDDEN?i.sendOnExit(o):i.send(o)}),(0,l.DJ)(c.expirationTimeoutId)),c="stop"!==e?{status:0,nextSegmentCreationReason:e}:{status:2}}return{addRecord(e){if(2!==c.status){if(0===c.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;c={status:1,segment:f({encoder:a,context:e,creationReason:c.nextSegmentCreationReason}),expirationTimeoutId:(0,l.wg)(()=>{p("segment_duration_limit")},5e3)}}c.segment.addRecord(e,e=>{e>6e4&&p("segment_bytes_limit")})}},addStats(e){1===c.status&&c.segment.addStats(e)},stop(){p("stop"),u(),d()}}}(e,0,o,i)}(e,t,s,m,S,h);E=n.addRecord,R=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 c=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(11,e=>{(0,r.Kp)(e)&&e!==r.y5.HIDDEN&&e!==r.y5.PAGE_TERMINATED&&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);D=c.emitResource,_.push(c.stop)}const v=(0,p.g1)({emitRecord:E,emitResource:D,emitStats:R,configuration:t,lifeCycle:e,viewHistory:m});return C=v.flushMutations,{stop(){v.flushMutations(),v.stop(),_.forEach(e=>e())}}}}};
1
+ export const __webpack_esm_ids__=["datadogRecorder"];export const __webpack_esm_modules__={8647(e,t,s){s.d(t,{startRecording:()=>y});var n=s(9360),o=s(4023),i=s(7003),a=s(1776),r=s(6448),c=s(9305),u=s(8333),d=s(5387),p=s(7923),l=s(8975),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,p.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,p.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(14,{error:{message:t,source:o.g.AGENT,startClocks:(0,u.M8)()}}),(0,i.A2)("Error reported to customer",{"error.message":t})},S=g||(0,a.sA)([(0,d.ns)(t,"replay")],w,6e4),x=b||(0,a.sA)([(0,d.ns)(t,"replay")],w,0);let E,R,D=n.l,C=n.l;const{unsubscribe:T}=e.subscribe(11,e=>{e!==r.y5.PAGE_TERMINATED&&C()});if(_.push(T),(0,c.d0)())({addRecord:E}=function(e){const t=(0,c.Y9)();return{addRecord(s){const n=e.findView();t.send("record",s,n.id)}}}(m)),R=n.l;else{const o=function(e,t,s,n,o,i){return function(e,o,i,a){let c={status:0,nextSegmentCreationReason:"init"};const{unsubscribe:u}=e.subscribe(2,()=>{p("view_change")}),{unsubscribe:d}=e.subscribe(11,e=>{e!==r.y5.PAGE_TERMINATED&&p(e)});function p(e){1===c.status&&(c.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,r.Kp)(e)&&e!==r.y5.HIDDEN?i.sendOnExit(o):i.send(o)}),(0,l.DJ)(c.expirationTimeoutId)),c="stop"!==e?{status:0,nextSegmentCreationReason:e}:{status:2}}return{addRecord(e){if(2!==c.status){if(0===c.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;c={status:1,segment:f({encoder:a,context:e,creationReason:c.nextSegmentCreationReason}),expirationTimeoutId:(0,l.wg)(()=>{p("segment_duration_limit")},5e3)}}c.segment.addRecord(e,e=>{e>6e4&&p("segment_bytes_limit")})}},addStats(e){1===c.status&&c.segment.addStats(e)},stop(){p("stop"),u(),d()}}}(e,0,o,i)}(e,t,s,m,S,h);E=o.addRecord,R=o.addStats,_.push(o.stop);const a=function(e,t){if(!e.metricsEnabled)return{stop:n.l};const{unsubscribe:s}=t.subscribe(e=>{if("failure"===e.type||"queue-full"===e.type||"success"===e.type&&e.payload.isFullSnapshot){const o=(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,i.Gk)("Segment network request metrics",{metrics:o})}var t,s,n});return{stop:s}}(y,S.observable);_.push(a.stop);const c=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(11,e=>{(0,r.Kp)(e)&&e!==r.y5.HIDDEN&&e!==r.y5.PAGE_TERMINATED&&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);D=c.emitResource,_.push(c.stop)}const v=(0,p.g1)({emitRecord:E,emitResource:D,emitStats:R,configuration:t,lifeCycle:e,viewHistory:m});return C=v.flushMutations,{stop(){v.flushMutations(),v.stop(),_.forEach(e=>e())}}}}};