UNPKG

@objectiv/tracker-browser

Version:

Objectiv Web application analytics tracker for the open analytics taxonomy

2 lines 23.8 kB
var _={name:"@objectiv/tracker-browser",version:"0.0.26",description:"Objectiv Web application analytics tracker for the open analytics taxonomy",license:"Apache-2.0",homepage:"https://objectiv.io",keywords:["objectiv","tracking","web","analytics","events","taxonomy"],repository:{type:"git",url:"https://github.com/objectiv/objectiv-analytics.git",directory:"tracker/trackers/browser"},bugs:"https://github.com/objectiv/objectiv-analytics/issues",contributors:[{name:"Surai Di Rosa",email:"surai.dirosa@gmail.com",url:"https://github.com/sdirosa"}],main:"./dist/index.js",module:"./dist/esm/index.js",types:"./dist/index.d.ts",files:["dist"],exports:{".":{require:"./dist/index.js",import:"./dist/esm/index.js",types:"./dist/index.d.ts"}},scripts:{build:"tsup src/index.ts --format cjs,esm --legacy-output --minify --dts --sourcemap --clean","deploy:verdaccio":"npm publish",prettify:"prettier --write .",tsc:"tsc --noEmit",test:"jest --silent","test:ci":"jest --silent --ci","test:coverage":"jest --silent --coverage",depcheck:"npx depcheck"},devDependencies:{"@objectiv/developer-tools":"^0.0.26","@objectiv/testing-tools":"^0.0.26",jest:"^28.1.3","jest-fetch-mock":"^3.0.3","jest-useragent-mock":"^0.1.1",prettier:"^2.7.1","ts-jest":"^28.0.7",tsup:"^6.2.1",typescript:"^4.7.4"},dependencies:{"@objectiv/plugin-application-context":"^0.0.26","@objectiv/plugin-http-context":"^0.0.26","@objectiv/plugin-path-context-from-url":"^0.0.26","@objectiv/plugin-root-location-context-from-url":"^0.0.26","@objectiv/queue-local-storage":"^0.0.26","@objectiv/schema":"^0.0.26","@objectiv/tracker-core":"^0.0.26","@objectiv/transport-debug":"^0.0.26","@objectiv/transport-fetch":"^0.0.26","@objectiv/transport-xhr":"^0.0.26"}};export*from"@objectiv/tracker-core";import{ApplicationContextPlugin as Ar}from"@objectiv/plugin-application-context";import{HttpContextPlugin as Vr}from"@objectiv/plugin-http-context";import{PathContextFromURLPlugin as Ir}from"@objectiv/plugin-path-context-from-url";import{RootLocationContextFromURLPlugin as Br}from"@objectiv/plugin-root-location-context-from-url";var F=r=>{let{trackApplicationContext:t=!0,trackHttpContext:e=!0,trackPathContextFromURL:i=!0,trackRootLocationContextFromURL:o=!0}=r,n=[];return t&&n.push(new Ar),e&&n.push(new Vr),i&&n.push(new Ir),o&&n.push(new Br),n};import{LocalStorageQueueStore as Or}from"@objectiv/queue-local-storage";import{TrackerQueue as Sr}from"@objectiv/tracker-core";var M=r=>new Sr({store:new Or({trackerId:r.trackerId??r.applicationId})});import{TrackerTransportRetry as Qr,TrackerTransportSwitch as Hr}from"@objectiv/tracker-core";import{FetchTransport as Rr}from"@objectiv/transport-fetch";import{XHRTransport as Nr}from"@objectiv/transport-xhr";var $=()=>new Qr({transport:new Hr({transports:[new Rr,new Nr]})});var U=r=>r===!0||r===!1||r==="onTimeout";import{LocationContextName as _r}from"@objectiv/tracker-core";var v=r=>typeof r!="object"||r===null||!r._type||!r.id?!1:Object.keys(_r).includes(r._type);var l=r=>!(typeof r!="object"||r===null||!r.hasOwnProperty("id")||r.id&&typeof r.id!="string");var m=(g=>(g.elementId="data-objectiv-element-id",g.parentElementId="data-objectiv-parent-element-id",g.context="data-objectiv-context",g.trackClicks="data-objectiv-track-clicks",g.trackBlurs="data-objectiv-track-blurs",g.trackVisibility="data-objectiv-track-visibility",g.tagChildren="data-objectiv-tag-children",g.tracked="data-objectiv-tracked",g.validate="data-objectiv-validate",g))(m||{});var y=r=>r instanceof HTMLElement||r instanceof SVGElement;var u=r=>y(r)&&r.hasAttribute("data-objectiv-context");var q=r=>u(r)&&r.hasAttribute("data-objectiv-parent-element-id");import{LocationContextName as G}from"@objectiv/tracker-core";var D=r=>[G.PressableContext.toString(),G.LinkContext.toString()].includes(r._type);import{LocationContextName as W}from"@objectiv/tracker-core";var K=r=>[W.OverlayContext.toString(),W.ExpandableContext.toString()].includes(r._type);var X=r=>y(r)&&r.hasAttribute("data-objectiv-tag-children");var z=r=>!(typeof r!="object"||r===null||r["data-objectiv-element-id"]===void 0||r["data-objectiv-context"]===void 0);var B=r=>typeof r!="boolean"&&typeof r!="object"||r===null?!1:!(typeof r=="object"&&typeof r.trackValue!="boolean");var Y=r=>!(typeof r!="object"||r===null||r.intervalMs===void 0&&r.timeoutMs===void 0&&r.flushQueue===void 0||r.intervalMs!==void 0&&typeof r.intervalMs!="number"||r.timeoutMs!==void 0&&typeof r.timeoutMs!="number"||r.flushQueue!==void 0&&!U(r.flushQueue));var O=r=>typeof r!="boolean"&&typeof r!="object"||r===null||typeof r=="object"&&r.waitUntilTracked!==!0&&typeof r.waitUntilTracked!="object"?!1:typeof r=="object"&&typeof r.waitUntilTracked=="object"?Y(r.waitUntilTracked):!0;var h=r=>typeof r!="boolean"&&typeof r!="object"?!1:typeof r=="boolean"?!0:!(!r.mode||!["auto","manual"].includes(r.mode)||r.mode==="auto"&&r.hasOwnProperty("isVisible")||r.mode==="manual"&&!r.hasOwnProperty("isVisible")||r.mode==="manual"&&typeof r.isVisible!="boolean");var C=r=>!(typeof r!="object"||r===null||!r.hasOwnProperty("locationUniqueness")||typeof r.locationUniqueness!="boolean");var Z=r=>!(typeof r!="object"||r===null||r.trackClicks!==void 0&&!O(r.trackClicks)||r.trackBlurs!==void 0&&!B(r.trackBlurs)||r.trackVisibility!==void 0&&!h(r.trackVisibility)||r.validate!==void 0&&!C(r.validate));var rr=r=>!(typeof r!="object"||r===null||!r.hasOwnProperty("instance")||r.instance&&!v(r.instance)||r.options&&!Z(r.options));var w=r=>!(typeof r!="object"||r===null||r.queryAll===void 0||r.tagAs===void 0||r.queryAll!==void 0&&typeof r.queryAll!="string"||r.tagAs!==void 0&&!z(r.tagAs));var k=r=>r===null?null:JSON.parse(r);var x=r=>{let t=k(r);if(!v(t))throw new Error(`LocationContext is not valid: ${JSON.stringify(r)}`);return t};var tr=r=>{if(r===null)throw new Error("Received `null` while attempting to parse Children Tagging Attribute");if(typeof r!="string")throw new Error("Children Tagging Attribute must be a string");let t=k(r);if(!Array.isArray(t))throw new Error("Parsed Children Tagging Attribute is not an array");return t.forEach(e=>{if(!w(e))throw new Error(`Invalid children tagging parameters: ${JSON.stringify(t)}`)}),t};var er=r=>{let t=k(r);if(!B(t))throw new Error(`Invalid trackClicks attribute: ${JSON.stringify(r)}`);return t===!0?{trackValue:!1}:t===!1?void 0:t};var or=r=>{let t=k(r);if(!O(t))throw new Error(`Invalid trackClicks attribute: ${JSON.stringify(r)}`);if(typeof t=="boolean")return t?{}:void 0;let e={},{waitUntilTracked:i}=t;if(typeof i=="boolean")e.waitForQueue={},e.flushQueue=!0;else{let{flushQueue:o,...n}=i;e.flushQueue=o!==void 0?o:!0,e.waitForQueue=n}return e};var L=r=>{let t=k(r);if(!h(t))throw new Error(`trackVisibility attribute is not valid: ${JSON.stringify(r)}`);if(t===!0)return{mode:"auto"};if(t!==!1)return t};var ir=r=>{if(!r)return{locationUniqueness:!0};let t=k(r);if(!C(t))throw new Error(`validate attribute is not valid: ${JSON.stringify(r)}`);return t};var d=r=>JSON.stringify(r);var ar=r=>{if(!v(r))throw new Error(`Object is not a valid LocationContext: ${JSON.stringify(r)}`);return d(r)};var nr=r=>(r.forEach(t=>{if(!w(t))throw new Error(`Invalid children tagging parameters: ${JSON.stringify(r)}`)}),JSON.stringify(r));var cr=r=>d(r);var sr=r=>d(r);var mr=r=>{if(!h(r))throw new Error(`trackVisibility is not valid, received: ${JSON.stringify(r)}`);return d(r)};var lr=r=>{if(!C(r))throw new Error(`validate attribute is not valid, received: ${JSON.stringify(r)}`);return d(r)};var A=(r,t=[])=>{var i;if(!r)return t;u(r)&&t.push(r);let e=r.parentElement;if(q(r)){let o=r.getAttribute("data-objectiv-parent-element-id"),n=document.querySelector(`[${"data-objectiv-element-id"}='${o}']`);if(!u(n))return(i=globalThis.objectiv.devTools)==null||i.TrackerConsole.error(`findParentTaggedElements: missing or invalid Parent Element '${o}'`),t;e=n}return A(e,t)};import{TrackerPlugins as Jr}from"@objectiv/tracker-core";var a=(r,t,e)=>{var i;e?e(r):(i=globalThis.objectiv.devTools)==null||i.TrackerConsole.error(r,t)};var fr=r=>{let t=[];try{let{element:e,tracker:i}=r;i&&t.push(...i.location_stack),y(e)&&A(e).reverse().forEach(n=>{t.push(x(n.getAttribute("data-objectiv-context")))}),i&&new Jr(i.plugins).enrich({location_stack:t,global_contexts:[]})}catch(e){a(e,r)}return t};var pr=()=>{if(!(typeof location>"u"))return location.href};var V=(r,t)=>{if(!(typeof t>"u"))return r(t)};import{makeFailureEvent as jr}from"@objectiv/tracker-core";var P=()=>globalThis.objectiv.TrackerRepository;var E=r=>{let t=P().get(r);if(!t)throw new Error("No Tracker found. Please create one via `makeTracker`.");return t};var c=r=>{try{let{event:t,element:e,tracker:i=E(r.trackerId)}=r,o=t.location_stack;(o==null?void 0:o.length)===0&&e&&(o=fr({element:e})),i.trackEvent({...t,location_stack:o})}catch(t){a(t,r,r.onError)}};var ho=r=>{try{let{message:t,element:e=document,locationStack:i,globalContexts:o,tracker:n}=r;return c({event:jr({message:t,location_stack:i,global_contexts:o}),element:e,tracker:n})}catch(t){a(t,r,r.onError)}};import{makeApplicationLoadedEvent as Fr}from"@objectiv/tracker-core";var ur=(r={})=>{try{let{element:t=document,locationStack:e,globalContexts:i,tracker:o}=r;return c({event:Fr({location_stack:e,global_contexts:i}),element:t,tracker:o})}catch(t){a(t,r,r.onError)}};import{makePressEvent as Mr}from"@objectiv/tracker-core";var gr=({element:r,locationStack:t,globalContexts:e,tracker:i,onError:o})=>c({event:Mr({location_stack:t,global_contexts:e}),element:r,tracker:i,onError:o});import{makeSuccessEvent as $r}from"@objectiv/tracker-core";var Ho=r=>{try{let{message:t,element:e=document,locationStack:i,globalContexts:o,tracker:n}=r;return c({event:$r({message:t,location_stack:i,global_contexts:o}),element:e,tracker:n})}catch(t){a(t,r,r.onError)}};import{makeInputChangeEvent as Ur}from"@objectiv/tracker-core";var kr=({element:r,locationStack:t,globalContexts:e,tracker:i,onError:o})=>c({event:Ur({location_stack:t,global_contexts:e}),element:r,tracker:i,onError:o});import{makeInteractiveEvent as qr}from"@objectiv/tracker-core";var Mo=({element:r,locationStack:t,globalContexts:e,tracker:i,onError:o})=>c({event:qr({location_stack:t,global_contexts:e}),element:r,tracker:i,onError:o});import{makeHiddenEvent as Gr}from"@objectiv/tracker-core";var S=({element:r,locationStack:t,globalContexts:e,tracker:i,onError:o})=>c({event:Gr({location_stack:t,global_contexts:e}),element:r,tracker:i,onError:o});import{makeVisibleEvent as Dr}from"@objectiv/tracker-core";var dr=({element:r,locationStack:t,globalContexts:e,tracker:i,onError:o})=>c({event:Dr({location_stack:t,global_contexts:e}),element:r,tracker:i,onError:o});import{makeMediaEvent as Wr}from"@objectiv/tracker-core";var Yo=({element:r,locationStack:t,globalContexts:e,tracker:i,onError:o})=>c({event:Wr({location_stack:t,global_contexts:e}),element:r,tracker:i,onError:o});import{makeMediaLoadEvent as Kr}from"@objectiv/tracker-core";var ei=({element:r,locationStack:t,globalContexts:e,tracker:i,onError:o})=>c({event:Kr({location_stack:t,global_contexts:e}),element:r,tracker:i,onError:o});import{makeMediaPauseEvent as Xr}from"@objectiv/tracker-core";var ni=({element:r,locationStack:t,globalContexts:e,tracker:i,onError:o})=>c({event:Xr({location_stack:t,global_contexts:e}),element:r,tracker:i,onError:o});import{makeMediaStartEvent as zr}from"@objectiv/tracker-core";var li=({element:r,locationStack:t,globalContexts:e,tracker:i,onError:o})=>c({event:zr({location_stack:t,global_contexts:e}),element:r,tracker:i,onError:o});import{makeMediaStopEvent as Yr}from"@objectiv/tracker-core";var gi=({element:r,locationStack:t,globalContexts:e,tracker:i,onError:o})=>c({event:Yr({location_stack:t,global_contexts:e}),element:r,tracker:i,onError:o});import{makeNonInteractiveEvent as Zr}from"@objectiv/tracker-core";var xi=({element:r,locationStack:t,globalContexts:e,tracker:i,onError:o})=>c({event:Zr({location_stack:t,global_contexts:e}),element:r,tracker:i,onError:o});import{makeHiddenEvent as rt,makeVisibleEvent as tt}from"@objectiv/tracker-core";var yi=({element:r,locationStack:t,globalContexts:e,tracker:i,isVisible:o,onError:n})=>c({event:o?tt({location_stack:t,global_contexts:e}):rt({location_stack:t,global_contexts:e}),element:r,tracker:i,onError:n});var Tr=(r,t)=>{try{return r.forEach(e=>{if(!w(e))throw new Error(`Invalid children tagging parameters: ${JSON.stringify(r)}`)}),{["data-objectiv-tag-children"]:nr(r)}}catch(e){return a(e,r,t)}};var Ii=(r,t)=>Tr([r],t);import{makeContentContext as at}from"@objectiv/tracker-core";import{generateGUID as et,getObjectKeys as ot,LocationContextName as it}from"@objectiv/tracker-core";var f=r=>{try{if(!rr(r))throw new Error(`Invalid tagLocation parameters: ${JSON.stringify(r)}`);let{instance:t,options:e}=r,i=D(t),o=t._type===it.InputContext,n=K(t),p=(e==null?void 0:e.trackClicks)??(i?!0:void 0),s=(e==null?void 0:e.trackBlurs)??(o?!0:void 0),b=e!=null&&e.parent?e.parent["data-objectiv-element-id"]:void 0,g=(e==null?void 0:e.trackVisibility)!==!1?e==null?void 0:e.trackVisibility:void 0;((e==null?void 0:e.trackVisibility)===void 0&&n||(e==null?void 0:e.trackVisibility)===!0)&&(g={mode:"auto"});let I={["data-objectiv-element-id"]:et(),["data-objectiv-parent-element-id"]:b,["data-objectiv-context"]:ar(t),["data-objectiv-track-clicks"]:V(sr,p),["data-objectiv-track-blurs"]:V(cr,s),["data-objectiv-track-visibility"]:V(mr,g),["data-objectiv-validate"]:V(lr,e==null?void 0:e.validate)};return ot(I).forEach(j=>{I[j]===void 0&&delete I[j]}),I}catch(t){return a(t,r,r==null?void 0:r.onError)}};var Ki=r=>{try{if(!l(r))throw new Error(`Invalid location tagger parameters: ${JSON.stringify(r)}`);let{id:t,options:e}=r;return f({instance:at({id:t}),options:e,onError:r.onError})}catch(t){return a(t,r)}};import{makeExpandableContext as nt}from"@objectiv/tracker-core";var ta=r=>{try{if(!l(r))throw new Error(`Invalid location tagger parameters: ${JSON.stringify(r)}`);let{id:t,options:e}=r;return f({instance:nt({id:t}),options:e,onError:r.onError})}catch(t){return a(t,r)}};import{makeInputContext as ct}from"@objectiv/tracker-core";var ca=r=>{try{if(!l(r))throw new Error(`Invalid location tagger parameters: ${JSON.stringify(r)}`);let{id:t,options:e}=r;return f({instance:ct({id:t}),options:e,onError:r.onError})}catch(t){return a(t,r)}};import{makeLinkContext as st}from"@objectiv/tracker-core";var ua=r=>{try{if(!l(r))throw new Error(`Invalid location tagger parameters: ${JSON.stringify(r)}`);let{id:t,href:e,options:i}=r;return f({instance:st({id:t,href:e}),options:i,onError:r.onError})}catch(t){return a(t,r)}};import{makeMediaPlayerContext as mt}from"@objectiv/tracker-core";var Ea=r=>{try{if(!l(r))throw new Error(`Invalid location tagger parameters: ${JSON.stringify(r)}`);let{id:t,options:e}=r;return f({instance:mt({id:t}),options:e,onError:r.onError})}catch(t){return a(t,r)}};import{makeNavigationContext as lt}from"@objectiv/tracker-core";var wa=r=>{try{if(!l(r))throw new Error(`Invalid location tagger parameters: ${JSON.stringify(r)}`);let{id:t,options:e}=r;return f({instance:lt({id:t}),options:e,onError:r.onError})}catch(t){return a(t,r)}};import{makeOverlayContext as ft}from"@objectiv/tracker-core";var Ba=r=>{try{if(!l(r))throw new Error(`Invalid location tagger parameters: ${JSON.stringify(r)}`);let{id:t,options:e}=r;return f({instance:ft({id:t}),options:e,onError:r.onError})}catch(t){return a(t,r)}};import{makePressableContext as pt}from"@objectiv/tracker-core";var Na=r=>{try{if(!l(r))throw new Error(`Invalid location tagger parameters: ${JSON.stringify(r)}`);let{id:t,options:e}=r;return f({instance:pt({id:t}),options:e,onError:r.onError})}catch(t){return a(t,r)}};import{makeRootLocationContext as ut}from"@objectiv/tracker-core";var $a=r=>{try{if(!l(r))throw new Error(`Invalid location tagger parameters: ${JSON.stringify(r)}`);let{id:t,options:e}=r;return f({instance:ut({id:t}),options:e,onError:r.onError})}catch(t){return a(t,r)}};var T={observerInstance:null,applicationLoaded:!1,previousURL:pr()};import{makeInputValueContext as gt}from"@objectiv/tracker-core";var xr=(r,t,e,i)=>o=>{if(o.target===r||u(o.currentTarget)&&o.currentTarget.hasAttribute("data-objectiv-track-blurs")){let n=[];(e==null?void 0:e.trackValue)&&i&&(o.target instanceof HTMLInputElement||o.target instanceof HTMLSelectElement)&&n.push(gt({id:i,value:o.target.value})),kr({element:r,tracker:t,globalContexts:n})}};var Q=(r,t,e)=>async function i(o){if((o.target===r||u(o.currentTarget)&&o.currentTarget.hasAttribute("data-objectiv-track-clicks"))&&(gr({element:r,tracker:t}),e)){let{waitForQueue:n,flushQueue:p}=e,s=new o.constructor(o.type,o);o.preventDefault(),o.stopImmediatePropagation();let b=!0;n&&(b=await t.waitForQueue(n)),(p===!0||p==="onTimeout"&&!b)&&t.flushQueue(),r.removeEventListener(o.type,i,!0),r.dispatchEvent(s),r.addEventListener(o.type,Q(r,t,e),!0)}};var Er=r=>{let t=[];try{if(!X(r))return t;tr(r.getAttribute("data-objectiv-tag-children")).forEach(i=>{let{queryAll:o,tagAs:n}=i;r.querySelectorAll(o).forEach(p=>{for(let[s,b]of Object.entries(n))b&&p.setAttribute(s,b);t.push(p)})})}catch(e){a(e)}return t};var H=(r,t)=>{try{if(!r.hasAttribute("data-objectiv-track-visibility"))return;let e=L(r.getAttribute("data-objectiv-track-visibility"));e&&(e.mode==="auto"||e.mode==="manual"&&e.isVisible)&&dr({element:r,tracker:t})}catch(e){a(e)}};var J=(r,t)=>{try{if(u(r)){if(r.hasAttribute("data-objectiv-tracked"))return;r.setAttribute("data-objectiv-tracked","true");let e=ir(r.getAttribute("data-objectiv-validate")),i=r.getAttribute("data-objectiv-context"),o=x(i);if(globalThis.objectiv.devTools&&e.locationUniqueness){let n=null,p=A(r).splice(1).reverse().pop()??null;if(p){let s=p.getAttribute("data-objectiv-context");s&&(n=x(s))}globalThis.objectiv.devTools.LocationTree.add(o,n)}if(H(r,t),r.hasAttribute("data-objectiv-track-clicks")){let n=or(r.getAttribute("data-objectiv-track-clicks"));if(!n)return;n.waitForQueue?r.addEventListener("click",Q(r,t,n),!0):r.addEventListener("click",Q(r,t),{passive:!0})}if(r.hasAttribute("data-objectiv-track-blurs")){let n=er(r.getAttribute("data-objectiv-track-blurs"));if(!n)return;r.addEventListener("blur",xr(r,t,n,o.id),{passive:!0})}}}catch(e){a(e)}};var R=(r,t)=>{try{let e=r.querySelectorAll(`[${"data-objectiv-context"}]`);[r,...Array.from(e)].forEach(o=>J(o,t));let i=r.querySelectorAll(`[${"data-objectiv-tag-children"}]`);[r,...Array.from(i)].forEach(o=>{Er(o).forEach(n=>{J(n,t)})})}catch(e){a(e)}};var br=(r,t)=>{try{if(u(r)){if(r.hasAttribute("data-objectiv-track-visibility")){let e=L(r.getAttribute("data-objectiv-track-visibility"));e&&e.mode==="auto"&&S({element:r,tracker:t})}globalThis.objectiv.devTools&&globalThis.objectiv.devTools.LocationTree.remove(x(r.getAttribute("data-objectiv-context")))}}catch(e){a(e)}};var vr=(r,t)=>{try{let e=r.querySelectorAll(`[${"data-objectiv-element-id"}]`);[r,...Array.from(e)].forEach(i=>br(i,t))}catch(e){a(e)}};var yr=(r,t)=>{try{if(!r.hasAttribute("data-objectiv-track-visibility"))return;let e=L(r.getAttribute("data-objectiv-track-visibility"));e&&e.mode==="manual"&&!e.isVisible&&S({element:r,tracker:t})}catch(e){a(e)}};var hr=()=>r=>{try{let t=E();r.forEach(({addedNodes:e,removedNodes:i,target:o,attributeName:n,oldValue:p})=>{if(globalThis.objectiv.devTools&&n==="data-objectiv-element-id"&&p){let s=document.querySelector(`[${"data-objectiv-element-id"}='${p}']`);s&&globalThis.objectiv.devTools.LocationTree.remove(x(s.getAttribute("data-objectiv-context")))}e.forEach(s=>{s instanceof Element&&R(s,t)}),i.forEach(s=>{s instanceof Element&&vr(s,t)}),n==="data-objectiv-track-visibility"&&u(o)&&(H(o,t),yr(o,t))})}catch(t){a(t)}};import{Tracker as kt,TrackerPlatform as dt}from"@objectiv/tracker-core";var N=class extends kt{constructor(e,...i){let o=e;if(o.platform=dt.BROWSER,!o.transport&&!e.endpoint)throw new Error("Either `transport` or `endpoint` must be provided");if(o.transport&&e.endpoint)throw new Error("Please provider either `transport` or `endpoint`, not both at same time");e.endpoint&&(o={...o,transport:$(),queue:o.queue??M(o)}),o.plugins=[...F(e),...o.plugins??[]];super(o,...i);this.trackerConfig=e}};var Cr=(r,t)=>{let e={...r},i={...t};return delete e.active,delete i.active,delete e.anonymous,delete i.anonymous,JSON.stringify(e)===JSON.stringify(i)};var wr=r=>{try{if(T.observerInstance)return;let t=hr();T.observerInstance=new MutationObserver(t),R(document.documentElement,E()),T.observerInstance.observe(document,{childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0,attributeFilter:["data-objectiv-track-visibility","data-objectiv-element-id"]}),((r==null?void 0:r.trackApplicationLoadedEvent)??!0)&&!T.applicationLoaded&&(T.applicationLoaded=!0,ur({tracker:E()}))}catch(t){a(t)}};var Lr=r=>{let t=new N(r);return wr(r),t};var wc=r=>{var o;let t=P(),e=r.trackerId??r.applicationId,i=t.trackersMap.get(e);return i?(Cr(i.trackerConfig,r)||(o=globalThis.objectiv.devTools)==null||o.TrackerConsole.error(`Tracker \`${e}\` exists but its configuration doesn't match the given one. This means getOrMakeTracker has been called twice with different configs.`),i):Lr(r)};var Vc=async r=>{let t,e,i,o={};typeof r=="string"?(t=r,e=o,i=!0):(t=r.trackerId,e=r.waitForQueue??o,i=r.flushQueue??!0);let p=E(),s=!0;e&&(s=await p.waitForQueue(e)),(i===!0||i==="onTimeout"&&!s)&&p.flushQueue(),P().setDefault(t)};var Sc=()=>{try{if(!T.observerInstance)return;T.observerInstance.disconnect(),T.observerInstance=null}catch(r){a(r)}};globalThis.objectiv=globalThis.objectiv??{};globalThis.objectiv.versions=globalThis.objectiv.versions??new Map;globalThis.objectiv.versions.set(_.name,_.version);export{T as AutoTrackingState,N as BrowserTracker,m as TaggingAttribute,A as findParentTaggedElements,fr as getElementLocationStack,pr as getLocationHref,wc as getOrMakeTracker,E as getTracker,P as getTrackerRepository,U as isFlushQueueOptions,v as isLocationContext,l as isLocationTaggerParameters,q as isParentTaggedElement,D as isPressableContext,K as isShowableContext,X as isTagChildrenElement,z as isTagLocationAttributes,Z as isTagLocationOptions,rr as isTagLocationParameters,y as isTaggableElement,u as isTaggedElement,B as isTrackBlursAttribute,O as isTrackClicksAttribute,h as isTrackVisibilityAttribute,w as isValidChildrenTaggingQuery,C as isValidateAttribute,Y as isWaitUntilTrackedOptions,xr as makeBlurEventHandler,F as makeBrowserTrackerDefaultPluginsList,M as makeBrowserTrackerDefaultQueue,$ as makeBrowserTrackerDefaultTransport,Q as makeClickEventHandler,hr as makeMutationCallback,Lr as makeTracker,k as parseJson,x as parseLocationContext,tr as parseTagChildren,er as parseTrackBlurs,or as parseTrackClicks,L as parseTrackVisibility,ir as parseValidate,Er as processTagChildrenElement,V as runIfValueIsNotUndefined,Vc as setDefaultTracker,wr as startAutoTracking,Sc as stopAutoTracking,d as stringifyJson,ar as stringifyLocationContext,nr as stringifyTagChildren,cr as stringifyTrackBlurs,sr as stringifyTrackClicks,mr as stringifyTrackVisibility,lr as stringifyValidate,Ii as tagChild,Tr as tagChildren,Ki as tagContent,ta as tagExpandable,ca as tagInput,ua as tagLink,f as tagLocation,Ea as tagMediaPlayer,wa as tagNavigation,Ba as tagOverlay,Na as tagPressable,$a as tagRootLocation,ur as trackApplicationLoadedEvent,c as trackEvent,ho as trackFailureEvent,S as trackHiddenEvent,kr as trackInputChangeEvent,Mo as trackInteractiveEvent,Yo as trackMediaEvent,ei as trackMediaLoadEvent,ni as trackMediaPauseEvent,li as trackMediaStartEvent,gi as trackMediaStopEvent,J as trackNewElement,R as trackNewElements,xi as trackNonInteractiveEvent,gr as trackPressEvent,br as trackRemovedElement,vr as trackRemovedElements,Ho as trackSuccessEvent,yi as trackVisibility,yr as trackVisibilityHiddenEvent,H as trackVisibilityVisibleEvent,dr as trackVisibleEvent,a as trackerErrorHandler}; //# sourceMappingURL=index.js.map