PageSourceSearch

https://dotb.io/assets/datadogProfiler.js

js dotb.io collected 2026-09-24 14:03:17 UTC 9,243 bytes, 1 lines download raw bytes

1import{j as H,o as ae,c as le,a as ce,b as de,g as ue,D as pe,d as fe,e as me,f as R,L as _,R as j,h as ve,i as I,S as V,V as w,k as z,l as _e,m as T,s as Y,n as be,p as F,q as b,r as B,t as x,u as ye,v as Ee,w as C,x as L,y as he,z as Te,A as Ie}from"./app.js";import"./account-selector.js";import"./index.js";import"./preload-helper.js";import"./accounting-panel.js";import"./accounting-orders-table.js";import"./delay-slider.js";import"./affiliate-calculator.js";import"./shopify-to-vinted-csv.js";function ke(s,t,e,n){const l=d=>{t.notify(14,{error:d}),de("Error reported to customer",{"error.message":d.message})},c=le([ce(s,"profile")],l),r=e(n);return{async send({event:d,...m}){const u=new FormData,p=H(d);if(!p)throw new Error("Failed to serialize event");u.append("event",new Blob([p],{type:"application/json"}),"event.json");let k=p.length;for(const[g,o]of ae(m)){const y=H(o);if(!y)throw new Error("Failed to serialize attachment");const E=await ge(r,y);k+=E.outputBytesCount,u.append(g,new Blob([E.output]),g)}c.send({data:u,bytesCount:k})}}}function ge(s,t){return new Promise(e=>{s.write(t),s.finish(n=>{e(n)})})}function De(){const s=ue();return t=>{s.send("profile",t)}}function Ae(s,t,e){const n=ke(s,t,e,pe.PROFILING);return({profile:l,trace:c})=>{const r={event:l,"wall-time.json":c};n.send(r)}}const Se=/\/(?![vV]\d{1,2}\/)([^/\d?]*\d+[^/?]*)/g;function Oe(s){return s?s.replace(Se,"/?"):"/"}const G=(s,t)=>s||Oe(t);function Ne(s,t,e){const n=fe(t),l=Pe(s,t.applicationId,e),c=Re(n);return{...l,attachments:["wall-time.json"],start:new Date(s.startClocks.timeStamp).toISOString(),end:new Date(s.endClocks.timeStamp).toISOString(),family:"chrome",runtime:"chrome",format:"json",version:4,tags_profiler:c.join(","),_dd:{clock_drift:me()}}}function Pe(s,t,e){const{ids:n,names:l}=we(s.views),c=s.longTasks.map(p=>p.id).filter(p=>p!==void 0),r=s.actions?.map(p=>p.id).filter(p=>p!==void 0)??[],{ids:d,labels:m}=Le(s.vitals),u={application:{id:t}};return e&&(u.session={id:e}),n.length&&(u.view={id:n,name:l}),c.length&&(u.long_task={id:c}),r.length&&(u.action={id:r,label:[]}),d.length&&(u.vital={id:d,label:m}),u}function we(s){const t={ids:[],names:[]};for(const e of s)t.ids.push(e.viewId),e.viewName&&t.names.push(e.viewName);return t.names=Array.from(new Set(t.names)),t}function Le(s){const t={ids:[],labels:[]};if(!s)return t;for(const e of s)t.ids.push(e.id),t.labels.push(e.label);return t.labels=Array.from(new Set(t.labels)),t}function Re(s){return s.concat(["language:javascript","runtime:chrome","family:chrome","host:browser"])}const Ve=V;function Me(s){const t=R({expireDelay:Ve});return s.subscribe(_.RAW_RUM_EVENT_COLLECTED,({rawRumEvent:e,startClocks:n,duration:l})=>{e.type==="long_task"&&t.add({id:e.long_task.id,startClocks:n,duration:l,entryType:e.long_task.entry_type===ve.LONG_TASK?j.LONG_TASK:j.LONG_ANIMATION_FRAME},n.relative).close(I(n.relative,l))}),t}const Ue=V;function qe(s){const t=R({expireDelay:Ue});return s.subscribe(_.ACTION_STARTED,e=>{t.add({id:e.id,label:"",startClocks:e.startClocks,duration:void 0},e.startClocks.relative)}),s.subscribe(_.RAW_RUM_EVENT_COLLECTED,({rawRumEvent:e,startClocks:n,duration:l})=>{if(e.type==="action"){const c=t.getEntries(n.relative).find(d=>d.value.id===e.action.id),r=l??0;c?(c.value.duration=r,c.close(I(n.relative,r))):t.add({id:e.action.id,label:"",startClocks:n,duration:l},n.relative).close(I(n.relative,r))}}),t}const He=V;function je(s){const t=R({expireDelay:He});return s.subscribe(_.DURATION_VITAL_STARTED,e=>{t.add({id:e.id,type:w.DURATION,startClocks:e.startClocks,duration:void 0,label:e.name},e.startClocks.relative)}),s.subscribe(_.RAW_RUM_EVENT_COLLECTED,({rawRumEvent:e,startClocks:n,duration:l})=>{if(e.type!=="vital")return;if(e.vital.type===w.OPERATION_STEP){if(e.vital.step_type==="start")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(e.vital.step_type==="end"){const r=t.findAllEntries().find(d=>d.value.type===w.OPERATION_STEP&&d.value.label===e.vital.name&&d.value.operationKey===e.vital.operation_key);if(!r)return;r.value.duration=z(r.value.startClocks.relative,n.relative),r.close(n.relative)}return}const c=t.getEntries(n.relative).find(r=>r.value.id===e.vital.id);if(c){c.value.duration=l,c.close(I(n.relative,l));return}t.add({id:e.vital.id,type:e.vital.type,operationKey:e.vital.operation_key,startClocks:n,duration:l,label:e.vital.name},n.relative).close(I(n.relative,l))}),t}function Fe(s,t){const e=s?.data?.attributes;if(!e||typeof e.admitted!="boolean"||typeof e.reason!="string")return t;const n=e.reason==="backend_client_not_initialized"?"backend_unavailable":e.reason;return{decision:e.admitted?"quota_ok":"quota_ko",reason:n}}function Be(s,t){return be({proxy:s.proxy,site:s.site,path:"/api/v2/profiling/quota",parameters:`session_id=${t}`,subdomain:"quota"})}function xe(s,t,e=5e3){const n=Be(s,t),l=new AbortController;let c;const r=_e(n,{credentials:"omit",signal:l.signal,headers:new Headers({"DD-CLIENT-TOKEN":s.clientToken})}).then(m=>{const u=m.status===429?{decision:"quota_ko",reason:"quota_exceeded"}:{decision:"quota_ok",reason:"api-error"};return m.json().then(p=>(T(c),Fe(p,u)),()=>(T(c),u))}).catch(()=>(T(c),{decision:"quota_ok",reason:"api-error"})),d=new Promise(m=>{c=Y(()=>{l.abort(),m({decision:"quota_ok",reason:"timeout"})},e)});return Promise.race([r,d])}const Ce={sampleIntervalMs:10,collectIntervalMs:6e4,minProfileDurationMs:5e3};function Ze(s,t,e,n,l,c,r=Ce){const d=F()?b(De)():b(Ae)(s,t,l);let m;const u=[],p=b(Me)(t),k=b(qe)(t),g=b(je)(t);let o={state:"stopped",stateReason:"initializing"},y=0;t.subscribe(_.SESSION_EXPIRED,()=>{O("session-expired")}),t.subscribe(_.SESSION_RENEWED,()=>{if(o.state==="stopped"&&(o.stateReason==="session-expired"||o.stateReason==="quota_ko")){const i=e.findTrackedSession();if(!i||!he(i.id,Te(s.sessionSampleRate,s.profilingSampleRate)))return;E()}});
1function E(){if(o.state==="running")return;const i=c.findView();m=i?{startClocks:i.startClocks,viewId:i.id,viewName:G(i.name,document.location.pathname)}:void 0,u.push(B(window,x.VISIBILITY_CHANGE,Z).stop,B(window,x.BEFORE_UNLOAD,ee).stop),h(),K()}function K(){if(F())return;const i=++y,a=e.findTrackedSession()?.id;a&&b(xe)(s,a).then(f=>{i===y&&(o.state!=="running"&&o.state!=="paused"||f.decision==="quota_ko"&&O("quota_ko",f.reason))}).catch(L)}function W(){O("stopped-by-user")}function O(i,a){X(i),u.forEach(f=>f()),u.length=0,n.set({status:"stopped",error_reason:void 0,quota_reason:a})}function Q(i){if(i.state==="running")return{cleanupTasks:i.cleanupTasks};const a=[],f=t.subscribe(_.VIEW_CREATED,v=>{const D={viewId:v.id,viewName:G(v.name,document.location.pathname),startClocks:v.startClocks};M(D),m=D});return a.push(f.unsubscribe),{cleanupTasks:a}}function h(){const i=ye.Profiler;if(!i)throw n.set({status:"error",error_reason:"not-supported-by-browser"}),new Error("RUM Profiler is not supported in this browser.");o.state==="running"&&N(o);const{cleanupTasks:a}=Q(o);let f;try{f=new i({sampleInterval:r.sampleIntervalMs,maxBufferSize:Math.round(r.collectIntervalMs*1.5/r.sampleIntervalMs)})}catch(v){v instanceof Error&&v.message.includes("disabled by Document Policy")?(Ee.warn("[DD_RUM] Profiler startup failed. Ensure your server includes the `Document-Policy: js-profiling` response header when serving HTML pages.",v),n.set({status:"error",error_reason:"missing-document-policy-header"})):n.set({status:"error",error_reason:"unexpected-exception"});return}n.set({status:"running",error_reason:void 0}),o={state:"running",startClocks:C(),profiler:f,timeoutId:Y(h,r.collectIntervalMs),views:[],cleanupTasks:a,longTasks:[],sessionId:e.findTrackedSession()?.id},M(m),f.addEventListener("samplebufferfull",P)}function N(i){T(i.timeoutId),i.profiler.removeEventListener("samplebufferfull",P);const{startClocks:a,views:f,sessionId:v}=i;i.profiler.stop().then(D=>{const U=C(),A=z(a.relative,U.relative),q=p.findAll(a.relative,A),ie=k.findAll(a.relative,A),oe=g.findAll(a.relative,A).map(S=>({id:S.id,label:S.label,startClocks:S.startClocks,duration:S.duration})),re=A<r.minProfileDurationMs;q.length===0&&re||J(Object.assign({},D,{startClocks:a,endClocks:U,clocksOrigin:Ie(),longTasks:q,actions:ie,vitals:oe,views:f,sampleInterval:r.sampleIntervalMs}),v)}).catch(L)}function X(i){if(o.state!=="running"){(o.state==="paused"||o.state==="stopped"&&i==="stopped-by-user")&&(o={state:"stopped",stateReason:i});return}const a=o;o={state:"stopped",stateReason:i},a.cleanupTasks.forEach(f=>f()),i==="quota_ko"?(T(a.timeoutId),a.profiler.removeEventListener("samplebufferfull",P),a.profiler.stop().catch(L)):N(a)}function $(){if(o.state!=="running")return;const i=o;o={state:"paused"},i.cleanupTasks.forEach(a=>a()),N(i)}function M(i){o.state!=="running"||!i||o.views.push(i)}function J(i,a){d({profile:Ne(i,s,a),trace:i})}function P(){h()}function Z(){document.visibilityState==="hidden"&&o.state==="running"?$():document.visibilityState==="visible"&&o.state==="paused"&&h()}function ee(){h()}function te(){return o.state==="stopped"}function se(){return o.state==="running"}function ne(){return o.state==="paused"}return{start:E,stop:W,isStopped:te,isRunning:se,isPaused:ne}}export{Ze as createRumProfiler};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.