1import{t as g,am as C,an as _,_ as A,ao as P,ap as v,aq as k,i as b,G as p,ar as N,w as S,b as L,f as w,X as D,n as O,U}from"./browser-agent-m10cITbU.js";import{A as B}from"./aggregate-base-3Twa-eY_.js";import{a as G}from"./traverse-eGeoT8Mx.js";import{T as M}from"./timer--QM2LZfv.js";import{i as I}from"./iframe-PalxAwQ_.js";import{i as T}from"./type-check-BVQCr-HH.js";import"./main-CX5PqK3X.js";import"./event-buffer-D7sh4Nzo.js";const K=(r,e=[])=>{const s={path:void 0,nearestFields:{},hasButton:!1,hasLink:!1};if(!r)return s;if(r===window)return s.path="window",s;if(r===document)return s.path="document",s;let c="";const u=H(r);try{for(;r?.tagName;){const t=r.tagName.toLowerCase();s.hasLink||=t==="a",s.hasButton||=t==="button"||t==="input"&&r.type.toLowerCase()==="button",e.forEach(i=>{s.nearestFields[V(i)]||=r[i]?.baseVal||r[i]}),c=W(r,c),r=r.parentNode}}catch{}return s.path=c?u?"".concat(c,":nth-of-type(").concat(u,")"):c:void 0,s};function W(r,e){const{id:s,localName:c}=r;return[c,s?"#".concat(s):"",e?">".concat(e):""].join("")}function H(r){try{let e=1;const{tagName:s}=r;for(;r.previousElementSibling;)r.previousElementSibling.tagName===s&&e++,r=r.previousElementSibling;return e}catch{}}function V(r){return r==="tagName"&&(r="tag"),r==="className"&&(r="class"),"nearest".concat(r.charAt(0).toUpperCase()+r.slice(1))}class x{constructor(e,s){this.event=e,this.count=1,this.originMs=Math.floor(e.timeStamp),this.relativeMs=[0],this.selectorPath=s.path,this.rageClick=void 0,this.nearestTargetFields=s.nearestFields,this.currentUrl=g(""+location),this.deadClick=!1,this.errorClick=!1}aggregate(e){this.count++,this.relativeMs.push(Math.floor(e.timeStamp-this.originMs)),this.isRageClick()&&(this.rageClick=!0)}isRageClick(){const e=this.relativeMs.length;return this.event.type==="click"&&e>=C&&this.relativeMs[e-1]-this.relativeMs[e-C]<_}}class j{#e=void 0;#t="";#r=void 0;#i=void 0;#s=void 0;constructor(){A().o.MO&&(this.#i=new MutationObserver(this.isLiveClick.bind(this)))}get aggregationEvent(){const e=this.#e;return this.#t="",this.#e=void 0,e}process(e,s){if(!e)return;const c=P.includes(e.type)?window:e.target,u=K(c,s),t=F(e,u.path);if(t&&t===this.#t)this.#e.aggregate(e);else{const i=this.#e;return this.#a(),this.#n(),this.#t=t,this.#e=new x(e,u),e.type==="click"&&(u.hasButton||u.hasLink)&&(this.#u(this.#e),this.#c()),i}}markAsErrorClick(){this.#e&&this.#s&&(this.#e.errorClick=!0,this.#n())}#c(){this.#s=new M({onEnd:()=>{this.#n()}},v)}#n(){this.#s?.clear(),this.#s=void 0}#u(e){this.#o()||!this.#i||(this.#i.observe(document,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this.#r=new M({onEnd:()=>{e.deadClick=!0,this.#a()}},v))}#a(){this.#i?.disconnect(),this.#r?.clear(),this.#r=void 0}#o(){return this.#r!==void 0}isLiveClick(){this.#o()&&this.#a()}}function F(r,e){let s=r.type;return r.type!=="scrollend"&&(s+="-"+e),s}class ee extends B{static featureName=k;#e;constructor(e){super(e,k),this.referrerUrl=b&&document.referrer?g(document.referrer):void 0,this.waitForFlags(["ins"]).then(([s])=>{if(!s){this.blocked=!0,this.deregisterDrain();return}this.#r(),p("api-recordCustomEvent",(t,i,l,a)=>{if(N.includes(i))return S(46);this.addEvent({eventType:i,timestamp:this.#t(t),...l},a)},this.featureName,this.ee),e.init.page_action.enabled&&p("api-addPageAction",(t,i,l,a)=>{this.addEvent({...l,eventType:"PageAction",timestamp:this.#t(t),timeSinceLoad:t/1e3,actionName:i,referrerUrl:this.referrerUrl,...b&&{browserWidth:window.document.documentElement?.clientWidth,browserHeight:window.document.documentElement?.clientHeight}},a)},this.featureName,this.ee);let c=()=>{};b&&e.init.user_actions.enabled&&(this.#e=new j,this.harvestOpts.beforeUnload=()=>c?.(this.#e.aggregationEvent),c=t=>{try{if(t?.event){let m=function(n){return n==="tagName"&&(n="tag"),n==="className"&&(n="class"),"target".concat(n.charAt(0).toUpperCase()+n.slice(1))},o=function(n){return!!(t.selectorPath!=="window"&&t.selectorPath!=="document"&&i instanceof HTMLElement&&i?.[n])};const{target:i,timeStamp:l,type:a}=t.event,f={eventType:"UserAction",timestamp:this.#t(l),action:a,actionCount:t.count,actionDuration:t.relativeMs[t.relativeMs.length-1],actionMs:t.relativeMs,rageClick:t.rageClick,target:t.selectorPath,currentUrl:t.currentUrl,...I(window)&&{iframe:!0},...this.agentRef.init.user_actions.elementAttributes.reduce((n,h)=>(o(h)&&(n[m(h)]=String(i[h]).trim().slice(0,128)),n),{}),...t.nearestTargetFields,...t.deadClick&&{deadClick:!0},...t.errorClick&&{errorClick:!0}};this.addEvent(f),this.#i(f)}}catch{}},p("ua",t=>{c(this.#e.process(t,this.agentRef.init.user_actions.elementAttributes))},this.featureName,this.ee),p("navChange",()=>{this.#e.isLiveClick()},this.featureName,this.ee),p("uaXhr",()=>{this.#e.isLiveClick()},this.featureName,this.ee),p("uaErr",()=>this.#e.markAsErrorClick(),this.featureName,this.ee));const u=[...e.init.performance.capture_marks?["mark"]:[],...e.init.performance.capture_measures?["measure"]:[]];if(u.length)try{u.forEach(t=>{PerformanceObserver.supportedEntryTypes.includes(t)&&new PerformanceObserver(l=>
1{l.getEntries().forEach(a=>{try{let m=function(o){if(o==null)return{};return T(o)?n(o):{entryDetail:o};function n(h,R="entryDetail"){let y={};return h==null||Object.keys(h).forEach(d=>{let E=R+"."+d;T(h[d])?Object.assign(y,n(h[d],E)):h[d]!==null&&h[d]!==void 0&&(y[E]=h[d])}),y}};this.reportSupportabilityMetric("Generic/Performance/"+t+"/Seen");const f=e.init.performance.capture_detail?m(a.detail):{};this.addEvent({...f,eventType:"BrowserPerformance",timestamp:this.#t(a.startTime),entryName:a.name,entryDuration:a.duration,entryType:t})}catch{}})}).observe({buffered:!0,type:t})})}catch{}b&&e.init.performance.resources.enabled&&p("browserPerformance.resource",t=>{try{const{name:i,duration:l,...a}=t.toJSON();let f=!1;try{const o=new URL(i).hostname,n=o.includes("newrelic.com")||o.includes("nr-data.net")||o.includes("nr-local.net");if(this.agentRef.init.performance.resources.ignore_newrelic&&n||this.agentRef.init.performance.resources.asset_types.length&&!this.agentRef.init.performance.resources.asset_types.includes(a.initiatorType))return;f=o===L?.location.hostname||e.init.performance.resources.first_party_domains.includes(o),f&&this.reportSupportabilityMetric("Generic/Performance/FirstPartyResource/Seen"),n&&this.reportSupportabilityMetric("Generic/Performance/NrResource/Seen")}catch{}this.reportSupportabilityMetric("Generic/Performance/Resource/Seen");const m={...a,eventType:"BrowserPerformance",timestamp:this.#t(a.startTime),entryName:g(i),entryDuration:l,firstParty:f};this.addEvent(m)}catch(i){this.ee.emit("internal-error",[i,"GenericEvents-Resource"])}},this.featureName,this.ee),p("api-measure",(t,i,l)=>{const{start:a,duration:f,customAttributes:m}=t,o={...m,eventType:"BrowserPerformance",timestamp:this.#t(a),entryName:i,entryDuration:f,entryType:"measure"};this.addEvent(o,l)},this.featureName,this.ee),e.init.feature_flags.includes("websockets")&&p("ws-complete",t=>{const i={...t,eventType:"WebSocket",timestamp:this.#t(t.timestamp),openedAt:this.#t(t.openedAt),closedAt:this.#t(t.closedAt)};this.reportSupportabilityMetric("WebSocket/Completed/Seen"),this.reportSupportabilityMetric("WebSocket/Completed/Bytes",w(i).length),this.addEvent(i)},this.featureName,this.ee),this.drain()})}addEvent(e={},s){if(!e||!Object.keys(e).length)return;if(!e.eventType){S(44);return}for(let t in e){let i=e[t];e[t]=i&&typeof i=="object"?w(i):i}const c={timestamp:this.#t(O()),pageUrl:g(""+U),currentUrl:g(""+location),...D(s,this)},u={...this.agentRef.info.jsAttributes||{},...c,...e};this.events.add(u)}serializer(e){return G({ins:e},this.obfuscator.obfuscateString.bind(this.obfuscator),"string")}queryStringsBuilder(){return{ua:this.agentRef.info.userAttributes,at:this.agentRef.info.atts}}#t(e){return Math.floor(this.agentRef.runtime.timeKeeper.correctRelativeTimestamp(e))}#r(){const e="Config/Performance/";this.agentRef.init.performance.capture_marks&&this.reportSupportabilityMetric(e+"CaptureMarks/Enabled"),this.agentRef.init.performance.capture_measures&&this.reportSupportabilityMetric(e+"CaptureMeasures/Enabled"),this.agentRef.init.performance.resources.enabled&&this.reportSupportabilityMetric(e+"Resources/Enabled"),this.agentRef.init.performance.resources.asset_types?.length!==0&&this.reportSupportabilityMetric(e+"Resources/AssetTypes/Changed"),this.agentRef.init.performance.resources.first_party_domains?.length!==0&&this.reportSupportabilityMetric(e+"Resources/FirstPartyDomains/Changed"),this.agentRef.init.performance.resources.ignore_newrelic===!1&&this.reportSupportabilityMetric(e+"Resources/IgnoreNewrelic/Changed")}#i(e){e.rageClick&&this.reportSupportabilityMetric("UserAction/RageClick/Seen"),e.deadClick&&this.reportSupportabilityMetric("UserAction/DeadClick/Seen"),e.errorClick&&this.reportSupportabilityMetric("UserAction/ErrorClick/Seen")}}export{ee 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.