1import{K as j,$ as v,ay as S,J as B,z as m,F as g,h as T,b1 as A,b2 as M}from"./0Qinthl5.js";import{s as G,b as I}from"./Db64noul.js";import{A as O}from"./BPFxCquk.js";import{d as x,p as _,i as H,c as P,g as U,b as d,n as b,a as E}from"./BXBAbesc.js";import{i as z}from"./BVQCr-HH.js";import{O as V}from"./BHuYNInE.js";import{i as k,a as w,s as C,b as F}from"./DMbnQq2_.js";import"./BiG_7VjL.js";import"./BeJIIZ6Y.js";import"./DAK6iKKX.js";function X({body:t,query:e}={}){if(!(!t&&!e))try{const s=D(R(t));if(s)return s;const a=Q(J(e));if(a)return a}catch{}}function Q(t){if(typeof t!="object"||!t.query||typeof t.query!="string")return;const e=t.query.trim().match(/^(query|mutation|subscription)\s?(\w*)/),s=e?.[1];return s?{operationName:t.operationName||e?.[2]||"Anonymous",operationType:s,operationFramework:"GraphQL"}:void 0}function D(t){if(!t)return;Array.isArray(t)||(t=[t]);const e=[],s=[];for(let a of t){const n=Q(a);n&&(e.push(n.operationName),s.push(n.operationType))}if(s.length)return{operationName:e.join(","),operationType:s.join(","),operationFramework:"GraphQL"}}function R(t){let e;if(!t||typeof t!="string"&&typeof t!="object"||(typeof t=="string"?e=JSON.parse(t):e=t,!z(e)&&!Array.isArray(e)))return;let s=!1;if(Array.isArray(e)?s=e.some(a=>N(a)):s=N(e),!!s)return e}function J(t){if(!t||typeof t!="string")return;const e=new URLSearchParams(t);return R(Object.fromEntries(e))}function N(t){return!(typeof t!="object"||!t.query||typeof t.query!="string")}function L(t){return Array.isArray(t?.errors)&&t.errors.some(e=>e&&typeof e=="object"&&typeof e.message=="string")}function K(t){if(!t)return!1;try{let e=t;return typeof t=="string"&&(e=JSON.parse(t)),Array.isArray(e)?e.some(L):L(e)}catch{return!1}}class oe extends O{static featureName=j;constructor(e){super(e,j),G(e.runtime.denyList);const s=this;this.obfuscator=new V(e,v.AJAX),e.init.ajax.block_internal?super.customAttributesAreSeparate=!0:super.canHarvestEarly=!1,S("returnAjax",a=>this.events.add(a),this.featureName,this.ee),S("xhr",function(a,n,p,u,i,r){s.storeXhr(a,n,p,u,i,r,this)},this.featureName,this.ee),this.ee.on("long-task",(a,n)=>{if(n instanceof B().o.XHR){const p=this.ee.context(n);p.latestLongtaskEnd=a.end}}),this.waitForFlags([]).then(()=>this.drain())}storeXhr(e,s,a,n,p,u,i){s.time=a;let r;e.cat?r=m([e.status,e.cat]):r=m([e.status,e.host,e.pathname]);const l=I(e),f=this.agentRef.init.feature_flags?.includes("ajax_metrics_deny_list");if(this.agentRef.features?.[g.jserrors]&&(l||!f)&&this.agentRef.sharedAggregator?.add(["xhr",r,e,s]),!l){e.hostname===this.agentRef.info.errorBeacon||this.agentRef.init.proxy?.beacon&&e.hostname===this.agentRef.init.proxy.beacon?(this.reportSupportabilityMetric("Ajax/Events/Excluded/Agent"),f&&this.reportSupportabilityMetric("Ajax/Metrics/Excluded/Agent")):(this.reportSupportabilityMetric("Ajax/Events/Excluded/App"),f&&this.reportSupportabilityMetric("Ajax/Metrics/Excluded/App"));return}T("bstXhrAgg",["xhr",r,e,s],void 0,g.sessionTrace,this.ee);const o={method:e.method,status:e.status,domain:e.host,path:e.pathname,requestSize:s.txSize,responseSize:s.rxSize,type:p,startTime:a,endTime:n,callbackDuration:s.cbTime,[A]:M()};o.gql=X({body:i.requestBody,query:i.parsedOrigin?.search}),o.gql&&(o.gql.operationHasErrors=K(i.responseBody));const y=this.agentRef.init.ajax.capture_payloads;x(y,{statusCode:o.status,hasGQLErrors:o.gql?.operationHasErrors,payloadHostname:e.hostname,payloadHost:e.host,payloadPathname:e.pathname},this.agentRef.beacons)&&(o.requestQuery=_(i.parsedOrigin?.search),o.requestHeaders=i.requestHeaders,o.responseHeaders=i.responseHeaders,H(i.requestHeaders,i.requestBody)&&(o.requestBody=i.requestBody),H(i.responseHeaders,i.responseBody)&&(o.responseBody=i.responseBody)),i.dt&&(o.spanId=i.dt.spanId,o.traceId=i.dt.traceId,o.spanTimestamp=Math.floor(this.agentRef.runtime.timeKeeper.correctAbsoluteTimestamp(i.dt.timestamp))),o.gql&&this.reportSupportabilityMetric("Ajax/Events/GraphQL/Bytes-Added",m(o.gql).length),k(u)?(this.events.add({...o,targetAttributes:w(u,this)}),C(u,this)&&this.reportContainerEvent({...o,targetAttributes:F(u,this)},i)):this.reportContainerEvent(o,i)}
1reportContainerEvent(e,s){!!this.agentRef.features?.[g.softNav]?T("ajax",[e,s],void 0,g.softNav,this.ee):this.events.add(e)}serializer(e){if(!e.length)return;const{addString:s,addStringRaw:a,addStringWithTruncation:n}=P(U,this.obfuscator);let p="bel.7;",u=0;for(let i=0;i<e.length;i++){const r=e[i],l=r.startTime-u;i===0&&(u=r.startTime);const f=[d(l),d(r.endTime-r.startTime),d(0),d(0),a(r.method),d(r.status),s(r.domain),s(r.path),d(r.requestSize),d(r.responseSize),r.type==="fetch"?1:"",a(0),b(r.spanId,a,!0)+b(r.traceId,a,!0)+b(r.spanTimestamp,d,!1)];let h="2,";const o=this.agentRef.info.jsAttributes;let y=E({...o||{},...r.targetAttributes||{},...r.gql||{}},{addKey:a,addVal:s});y.push(...E({[A]:r[A]},{addKey:a,addVal:a}));const q=E({...r.requestBody?{requestBody:r.requestBody}:{},...r.requestHeaders?{requestHeaders:r.requestHeaders}:{},...r.requestQuery?{requestQuery:r.requestQuery}:{},...r.responseBody?{responseBody:r.responseBody}:{},...r.responseHeaders?{responseHeaders:r.responseHeaders}:{}},{addKey:a,addVal:n}),c=[...y,...q];f.unshift(d(c.length)),h+=f.join(","),c&&c.length>0&&(h+=";"+c.join(";")),i+1<e.length&&(h+=";"),p+=h}return p}}export{oe as Aggregate};
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.