@objectiv/plugin-root-location-context-from-url
Version:
Plugin for Objectiv trackers to automatically generate and attach RootLocationContext from URLs
2 lines • 2.68 kB
JavaScript
var i={name:"@objectiv/plugin-root-location-context-from-url",version:"0.0.26",description:"Plugin for Objectiv trackers to automatically generate and attach RootLocationContext from URLs",license:"Apache-2.0",homepage:"https://objectiv.io",keywords:["objectiv","tracking","web","analytics","events","taxonomy","plugin","url","root"],repository:{type:"git",url:"https://github.com/objectiv/objectiv-analytics.git",directory:"tracker/plugins/path-context-from-url"},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",prettier:"^2.7.1","ts-jest":"^28.0.7",tsup:"^6.2.1",typescript:"^4.7.4"},peerDependencies:{"@objectiv/tracker-core":"^0.0.26"}};import{makeId as l}from"@objectiv/tracker-core";var r=()=>{let t=location.pathname;return["/",""].includes(t)?"home":l(t==null?void 0:t.split("/")[1])};import{makeRootLocationContext as d}from"@objectiv/tracker-core";var c=class{constructor(o){this.pluginName="RootLocationContextFromURLPlugin";var e;this.idFactoryFunction=(o==null?void 0:o.idFactoryFunction)??r,(e=globalThis.objectiv.devTools)==null||e.TrackerConsole.log(`%c\uFF62objectiv:${this.pluginName}\uFF63 Initialized`,"font-weight: bold")}enrich(o){var n,s;if(!this.isUsable()){(n=globalThis.objectiv.devTools)==null||n.TrackerConsole.error(`\uFF62objectiv:${this.pluginName}\uFF63 Cannot enrich. Plugin is not usable (document: ${typeof document}).`);return}let e=this.idFactoryFunction();e?o.location_stack.unshift(d({id:e})):(s=globalThis.objectiv.devTools)==null||s.TrackerConsole.error(`%c\uFF62objectiv:${this.pluginName}\uFF63 Could not generate a RootLocationContext from "${location.pathname}"`,"font-weight: bold")}isUsable(){return typeof document<"u"&&typeof document.location<"u"}};globalThis.objectiv=globalThis.objectiv??{};globalThis.objectiv.versions=globalThis.objectiv.versions??new Map;globalThis.objectiv.versions.set(i.name,i.version);export{c as RootLocationContextFromURLPlugin,r as makeRootLocationId};
//# sourceMappingURL=index.js.map