1import{a8 as w,a9 as R,aa as _,ab as M,c as E,d as g,ac as P,w as b,e as A,s as C,n as N,x as D}from"./newrelic-CYyXWaUu.js";import{c as d,A as k}from"./aggregate-base-B1T_b5C8.js";import{a as K}from"./traverse-eGeoT8Mx.js";import{i as L}from"./iframe-PalxAwQ_.js";import{i as T}from"./type-check-BVQCr-HH.js";import"./event-buffer-CJip6WaH.js";const O=(a,e=[])=>{if(!a)return{path:void 0,nearestFields:{}};const o=r=>{try{let c=1;const{tagName:f}=r;for(;r.previousElementSibling;)r.previousElementSibling.tagName===f&&c++,r=r.previousElementSibling;return c}catch{}};let n="",h=o(a);const t={};try{for(;a?.tagName;){const{id:r,localName:c}=a;e.forEach(i=>{t[u(i)]||=a[i]?.baseVal||a[i]}),n=[c,r?"#".concat(r):"",n?">".concat(n):""].join(""),a=a.parentNode}}catch{}return{path:n?h?"".concat(n,":nth-of-type(").concat(h,")"):n:void 0,nearestFields:t};function u(r){return r==="tagName"&&(r="tag"),r==="className"&&(r="class"),"nearest".concat(r.charAt(0).toUpperCase()+r.slice(1))}};class H{constructor(e,o,n){this.event=e,this.count=1,this.originMs=Math.floor(e.timeStamp),this.relativeMs=[0],this.selectorPath=o,this.rageClick=void 0,this.nearestTargetFields=n,this.currentUrl=d(""+location)}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>=w&&this.relativeMs[e-1]-this.relativeMs[e-w]<R}}class B{#e=void 0;#t="";get aggregationEvent(){const e=this.#e;return this.#t="",this.#e=void 0,e}process(e,o){if(!e)return;const{selectorPath:n,nearestTargetFields:h}=U(e,o),t=G(e,n);if(t&&t===this.#t)this.#e.aggregate(e);else{const s=this.#e;return this.#t=t,this.#e=new H(e,n,h),s}}}function U(a,e){let o,n={};if(_.includes(a.type)||a.target===window)o="window";else if(a.target===document)o="document";else{const{path:h,nearestFields:t}=O(a.target,e);o=h,n=t}return{selectorPath:o,nearestTargetFields:n}}function G(a,e){let o=a.type;return a.type!=="scrollend"&&(o+="-"+e),o}class q extends k{static featureName=M;constructor(e){super(e,M),this.referrerUrl=E&&document.referrer?d(document.referrer):void 0,this.waitForFlags(["ins"]).then(([o])=>{if(!o){this.blocked=!0,this.deregisterDrain();return}this.trackSupportabilityMetrics(),g("api-recordCustomEvent",(t,s,u)=>{if(P.includes(s))return b(46);this.addEvent({eventType:s,timestamp:this.toEpoch(t),...u})},this.featureName,this.ee),e.init.page_action.enabled&&g("api-addPageAction",(t,s,u,r)=>{if(!this.agentRef.runtime.entityManager.get(r))return b(56,this.featureName);this.addEvent({...u,eventType:"PageAction",timestamp:this.toEpoch(t),timeSinceLoad:t/1e3,actionName:s,referrerUrl:this.referrerUrl,...E&&{browserWidth:window.document.documentElement?.clientWidth,browserHeight:window.document.documentElement?.clientHeight}},r)},this.featureName,this.ee);let n=()=>{};E&&e.init.user_actions.enabled&&(this.userActionAggregator=new B,this.harvestOpts.beforeUnload=()=>n?.(this.userActionAggregator.aggregationEvent),n=t=>{try{if(t?.event){let c=function(i){return i==="tagName"&&(i="tag"),i==="className"&&(i="class"),"target".concat(i.charAt(0).toUpperCase()+i.slice(1))},f=function(i){return!!(t.selectorPath!=="window"&&t.selectorPath!=="document"&&s instanceof HTMLElement&&s?.[i])};const{target:s,timeStamp:u,type:r}=t.event;this.addEvent({eventType:"UserAction",timestamp:this.toEpoch(u),action:r,actionCount:t.count,actionDuration:t.relativeMs[t.relativeMs.length-1],actionMs:t.relativeMs,rageClick:t.rageClick,target:t.selectorPath,currentUrl:t.currentUrl,...L(window)&&{iframe:!0},...this.agentRef.init.user_actions.elementAttributes.reduce((i,l)=>(f(l)&&(i[c(l)]=String(s[l]).trim().slice(0,128)),i),{}),...t.nearestTargetFields})}}catch{}},g("ua",t=>{n(this.userActionAggregator.process(t,this.agentRef.init.user_actions.elementAttributes))},this.featureName,this.ee));const h=[...e.init.performance.capture_marks?["mark"]:[],...e.init.performance.capture_measures?["measure"]:[]];if(h.length)try{h.forEach(t=>{PerformanceObserver.supportedEntryTypes.includes(t)&&new PerformanceObserver(u=>
1{u.getEntries().forEach(r=>{try{let f=function(i){if(i==null)return{};return T(i)?l(i):{entryDetail:i};function l(p,S="entryDetail"){let y={};return p==null||Object.keys(p).forEach(m=>{let v=S+"."+m;T(p[m])?Object.assign(y,l(p[m],v)):p[m]!==null&&p[m]!==void 0&&(y[v]=p[m])}),y}};this.reportSupportabilityMetric("Generic/Performance/"+t+"/Seen");const c=e.init.performance.capture_detail?f(r.detail):{};this.addEvent({...c,eventType:"BrowserPerformance",timestamp:this.toEpoch(r.startTime),entryName:r.name,entryDuration:r.duration,entryType:t})}catch{}})}).observe({buffered:!0,type:t})})}catch{}E&&e.init.performance.resources.enabled&&g("browserPerformance.resource",t=>{try{const{name:s,duration:u,...r}=t.toJSON();let c=!1;try{const i=new URL(s).hostname,l=i.includes("newrelic.com")||i.includes("nr-data.net")||i.includes("nr-local.net");if(this.agentRef.init.performance.resources.ignore_newrelic&&l||this.agentRef.init.performance.resources.asset_types.length&&!this.agentRef.init.performance.resources.asset_types.includes(r.initiatorType))return;c=i===A?.location.hostname||e.init.performance.resources.first_party_domains.includes(i),c&&this.reportSupportabilityMetric("Generic/Performance/FirstPartyResource/Seen"),l&&this.reportSupportabilityMetric("Generic/Performance/NrResource/Seen")}catch{}this.reportSupportabilityMetric("Generic/Performance/Resource/Seen");const f={...r,eventType:"BrowserPerformance",timestamp:Math.floor(e.runtime.timeKeeper.correctRelativeTimestamp(r.startTime)),entryName:d(s),entryDuration:u,firstParty:c};this.addEvent(f)}catch(s){this.ee.emit("internal-error",[s,"GenericEvents-Resource"])}},this.featureName,this.ee),g("api-measure",(t,s)=>{const{start:u,duration:r,customAttributes:c}=t,f={...c,eventType:"BrowserPerformance",timestamp:Math.floor(e.runtime.timeKeeper.correctRelativeTimestamp(u)),entryName:s,entryDuration:r,entryType:"measure"};this.addEvent(f)},this.featureName,this.ee),e.runtime.harvester.triggerHarvestFor(this),this.drain()})}addEvent(e={},o){if(!e||!Object.keys(e).length)return;if(!e.eventType){b(44);return}for(let t in e){let s=e[t];e[t]=s&&typeof s=="object"?C(s):s}const n={timestamp:Math.floor(this.agentRef.runtime.timeKeeper.correctRelativeTimestamp(N())),pageUrl:d(""+D),currentUrl:d(""+location)},h={...this.agentRef.info.jsAttributes||{},...n,...e};this.events.add(h,o)}serializer(e){return K({ins:e},this.obfuscator.obfuscateString.bind(this.obfuscator),"string")}queryStringsBuilder(){return{ua:this.agentRef.info.userAttributes,at:this.agentRef.info.atts}}toEpoch(e){return Math.floor(this.agentRef.runtime.timeKeeper.correctRelativeTimestamp(e))}trackSupportabilityMetrics(){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")}}export{q 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.