@junobuild/analytics 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var y=e=>e==null,u=e=>!y(e),b=class extends Error{},o=(e,t)=>{if(y(e))throw new b(t)},i=e=>u(e)?[e]:[];var m=()=>typeof window<"u";var l=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,r)=>(r&=63,r<36?t+=r.toString(36):r<62?t+=(r-26).toString(36).toUpperCase():r>62?t+="-":t+="_",t),"");var f=()=>BigInt(Date.now())*BigInt(1e6);var d=()=>({collected_at:f(),updated_at:[]}),g=()=>{let{userAgent:e}=navigator;return{user_agent:i(e)}};var S=()=>{if(!(typeof crypto>"u"))return l()},p=S(),n,k=e=>{let{path:t}=e.worker??{},r=t===void 0?"./workers/analytics.worker.js":t;n=new Worker(r);let s=()=>console.warn("Unable to connect to the analytics web worker. Have you deployed it?");return n?.addEventListener("error",s,!1),_(e),{cleanup(){n?.removeEventListener("error",s,!1)}}},v=()=>{let e=async()=>await E(),t=new Proxy(history.pushState,{apply:async(r,s,c)=>{r.apply(s,c),await e()}});return history.pushState=t,addEventListener("popstate",e,{passive:!0}),{cleanup(){t=null,removeEventListener("popstate",e,!1)}}},a="Analytics worker not initialized. Did you call `initOrbiter`?",h="No session ID initialized.",w=async()=>{if(!m())return;o(p,h);let{title:e,location:{href:t},referrer:r}=document,{innerWidth:s,innerHeight:c}=window,{timeZone:I}=Intl.DateTimeFormat().resolvedOptions(),T={title:e,href:t,referrer:i(u(r)&&r!==""?r:void 0),device:{inner_width:s,inner_height:c},time_zone:I,...g(),...d()};await(await import("./idb.services-T4DLYFZI.js")).setPageView({sessionId:p,key:l(),view:T})},E=async()=>{o(n,a),await w(),n?.postMessage({msg:"junoTrackPageView"})},P=async e=>{if(!m())return;o(p,h),o(n,a),await(await import("./idb.services-T4DLYFZI.js")).setTrackEvent({sessionId:p,key:l(),track:{...e,...g(),...d()}}),n?.postMessage({msg:"junoTrackEvent"})},_=e=>{o(n,a),n?.postMessage({msg:"junoInitEnvironment",data:e})},x=()=>{o(n,a),n?.postMessage({msg:"junoStartTrackTimer"})},N=()=>{o(n,a),n?.postMessage({msg:"junoStopTracker"})};var H=async e=>{await w();let{cleanup:t}=k(e),{cleanup:r}=v();return x(),()=>{N(),t(),r()}};export{H as initOrbiter,P as trackEvent,E as trackPageView};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../utils/src/utils/debounce.utils.ts", "../../../utils/src/utils/null.utils.ts", "../../../utils/src/utils/did.utils.ts", "../../../utils/src/utils/env.utils.ts", "../../../../node_modules/nanoid/index.browser.js", "../../src/utils/date.utils.ts", "../../src/utils/analytics.utils.ts", "../../src/services/analytics.services.ts", "../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable-next-line @typescript-eslint/ban-types */\nexport const debounce = (func: Function, timeout?: number) => {\n let timer: NodeJS.Timer | undefined;\n\n return (...args: unknown[]) => {\n const next = () => func(...args);\n\n if (timer) {\n clearTimeout(timer);\n }\n\n timer = setTimeout(next, timeout !== undefined && timeout > 0 ? timeout : 300);\n };\n};\n", "/** Is null or undefined */\nexport const isNullish = <T>(argument: T | undefined | null): argument is undefined | null =>\n argument === null || argument === undefined;\n\n/** Not null and not undefined */\nexport const nonNullish = <T>(argument: T | undefined | null): argument is NonNullable<T> =>\n !isNullish(argument);\n\nexport class NullishError extends Error {}\n\nexport const assertNonNullish: <T>(\n value: T,\n message?: string\n) => asserts value is NonNullable<T> = <T>(value: T, message?: string): void => {\n if (isNullish(value)) {\n throw new NullishError(message);\n }\n};\n", "import {nonNullish} from './null.utils';\n\nexport const toNullable = <T>(value?: T): [] | [T] => {\n return nonNullish(value) ? [value] : [];\n};\n\nexport const fromNullable = <T>(value: [] | [T]): T | undefined => {\n return value?.[0];\n};\n\nexport const toArray = async <T>(data: T): Promise<Uint8Array> => {\n const blob: Blob = new Blob([JSON.stringify(data)], {\n type: 'application/json; charset=utf-8'\n });\n return new Uint8Array(await blob.arrayBuffer());\n};\n\nexport const fromArray = async <T>(data: Uint8Array | number[]): Promise<T> => {\n const blob: Blob = new Blob([data instanceof Uint8Array ? data : new Uint8Array(data)], {\n type: 'application/json; charset=utf-8'\n });\n return JSON.parse(await blob.text());\n};\n", "export const isBrowser = () => typeof window !== `undefined`;\n", "export { urlAlphabet } from './url-alphabet/index.js'\nexport let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1\n let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step\n while (j--) {\n id += alphabet[bytes[j] & mask] || ''\n if (id.length === size) return id\n }\n }\n }\n}\nexport let customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size, random)\nexport let nanoid = (size = 21) =>\n crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {\n byte &= 63\n if (byte < 36) {\n id += byte.toString(36)\n } else if (byte < 62) {\n id += (byte - 26).toString(36).toUpperCase()\n } else if (byte > 62) {\n id += '-'\n } else {\n id += '_'\n }\n return id\n }, '')\n", "export const nowInBigIntNanoSeconds = (): bigint => BigInt(Date.now()) * BigInt(1e6);\n", "import {toNullable} from '@junobuild/utils';\nimport {nowInBigIntNanoSeconds} from './date.utils';\n\nexport const timestamp = (): {collected_at: bigint; updated_at: [] | [bigint]} => ({\n collected_at: nowInBigIntNanoSeconds(),\n updated_at: []\n});\n\nexport const userAgent = (): {user_agent: [] | [string]} => {\n const {userAgent} = navigator;\n return {user_agent: toNullable(userAgent)};\n};\n", "import {assertNonNullish, isBrowser, nonNullish, toNullable} from '@junobuild/utils';\nimport {nanoid} from 'nanoid';\nimport type {Environment, EnvironmentWorker} from '../types/env';\nimport type {IdbPageView} from '../types/idb';\nimport type {PostMessageInitEnvData} from '../types/post-message';\nimport type {TrackEvent} from '../types/track';\nimport {timestamp, userAgent} from '../utils/analytics.utils';\n\nconst
|
|
5
|
-
"mappings": "ACCO,IAAMA,EAAgBC,GAC3BA,GAAa,KAGFC,EAAiBD,GAC5B,CAACD,EAAUC,CAAQ,EAERE,EAAN,cAA2B,KAAM,CAAC,EAE5BC,EAG0B,CAAIC,EAAUC,IAA2B,CAC9E,GAAIN,EAAUK,CAAK,EACjB,MAAM,IAAIF,EAAaG,CAAO,CAElC,ECfaC,EAAiBF,GACrBH,EAAWG,CAAK,EAAI,CAACA,CAAK,EAAI,CAAC,ECHjC,IAAMG,EAAY,IAAM,OAAO,OAAW,ICmB1C,IAAIC,EAAS,CAACC,EAAO,KAC1B,OAAO,gBAAgB,IAAI,WAAWA,CAAI,CAAC,EAAE,OAAO,CAACC,EAAIC,KACvDA,GAAQ,GACJA,EAAO,GACTD,GAAMC,EAAK,SAAS,EAAE,EACbA,EAAO,GAChBD,IAAOC,EAAO,IAAI,SAAS,EAAE,EAAE,YAAY,EAClCA,EAAO,GAChBD,GAAM,IAENA,GAAM,IAEDA,GACN,EAAE,EChCA,IAAME,EAAyB,IAAc,OAAO,KAAK,IAAI,CAAC,EAAI,OAAO,GAAG,ECG5E,IAAMC,EAAY,KAA0D,CACjF,aAAcC,EAAuB,EACrC,WAAY,CAAC,CACf,GAEaC,EAAY,IAAmC,CAC1D,GAAM,CAAC,UAAAA,CAAS,EAAI,UACpB,MAAO,CAAC,WAAYC,EAAWD,CAAS,CAAC,CAC3C,ECHA,IAAME,
|
|
6
|
-
"names": ["isNullish", "argument", "nonNullish", "NullishError", "assertNonNullish", "value", "message", "toNullable", "isBrowser", "nanoid", "size", "id", "byte", "nowInBigIntNanoSeconds", "timestamp", "nowInBigIntNanoSeconds", "userAgent", "T", "
|
|
4
|
+
"sourcesContent": ["/* eslint-disable-next-line @typescript-eslint/ban-types */\nexport const debounce = (func: Function, timeout?: number) => {\n let timer: NodeJS.Timer | undefined;\n\n return (...args: unknown[]) => {\n const next = () => func(...args);\n\n if (timer) {\n clearTimeout(timer);\n }\n\n timer = setTimeout(next, timeout !== undefined && timeout > 0 ? timeout : 300);\n };\n};\n", "/** Is null or undefined */\nexport const isNullish = <T>(argument: T | undefined | null): argument is undefined | null =>\n argument === null || argument === undefined;\n\n/** Not null and not undefined */\nexport const nonNullish = <T>(argument: T | undefined | null): argument is NonNullable<T> =>\n !isNullish(argument);\n\nexport class NullishError extends Error {}\n\nexport const assertNonNullish: <T>(\n value: T,\n message?: string\n) => asserts value is NonNullable<T> = <T>(value: T, message?: string): void => {\n if (isNullish(value)) {\n throw new NullishError(message);\n }\n};\n", "import {nonNullish} from './null.utils';\n\nexport const toNullable = <T>(value?: T): [] | [T] => {\n return nonNullish(value) ? [value] : [];\n};\n\nexport const fromNullable = <T>(value: [] | [T]): T | undefined => {\n return value?.[0];\n};\n\nexport const toArray = async <T>(data: T): Promise<Uint8Array> => {\n const blob: Blob = new Blob([JSON.stringify(data)], {\n type: 'application/json; charset=utf-8'\n });\n return new Uint8Array(await blob.arrayBuffer());\n};\n\nexport const fromArray = async <T>(data: Uint8Array | number[]): Promise<T> => {\n const blob: Blob = new Blob([data instanceof Uint8Array ? data : new Uint8Array(data)], {\n type: 'application/json; charset=utf-8'\n });\n return JSON.parse(await blob.text());\n};\n", "export const isBrowser = () => typeof window !== `undefined`;\n", "export { urlAlphabet } from './url-alphabet/index.js'\nexport let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1\n let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step\n while (j--) {\n id += alphabet[bytes[j] & mask] || ''\n if (id.length === size) return id\n }\n }\n }\n}\nexport let customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size, random)\nexport let nanoid = (size = 21) =>\n crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {\n byte &= 63\n if (byte < 36) {\n id += byte.toString(36)\n } else if (byte < 62) {\n id += (byte - 26).toString(36).toUpperCase()\n } else if (byte > 62) {\n id += '-'\n } else {\n id += '_'\n }\n return id\n }, '')\n", "export const nowInBigIntNanoSeconds = (): bigint => BigInt(Date.now()) * BigInt(1e6);\n", "import {toNullable} from '@junobuild/utils';\nimport {nowInBigIntNanoSeconds} from './date.utils';\n\nexport const timestamp = (): {collected_at: bigint; updated_at: [] | [bigint]} => ({\n collected_at: nowInBigIntNanoSeconds(),\n updated_at: []\n});\n\nexport const userAgent = (): {user_agent: [] | [string]} => {\n const {userAgent} = navigator;\n return {user_agent: toNullable(userAgent)};\n};\n", "import {assertNonNullish, isBrowser, nonNullish, toNullable} from '@junobuild/utils';\nimport {nanoid} from 'nanoid';\nimport type {Environment, EnvironmentWorker} from '../types/env';\nimport type {IdbPageView} from '../types/idb';\nimport type {PostMessageInitEnvData} from '../types/post-message';\nimport type {TrackEvent} from '../types/track';\nimport {timestamp, userAgent} from '../utils/analytics.utils';\n\nconst initSessionId = (): string | undefined => {\n // I faced this issue when I used the library in Docusaurus which does not implement the crypto API when server-side rendering.\n // https://github.com/ai/nanoid/issues?q=crypto+not+defined\n if (typeof crypto === 'undefined') {\n return undefined;\n }\n\n return nanoid();\n}\n\nconst sessionId = initSessionId();\n\nlet worker: Worker | undefined;\n\nexport const initWorker = (env: Environment): {cleanup: () => void} => {\n const {path}: EnvironmentWorker = env.worker ?? {};\n const workerUrl = path === undefined ? './workers/analytics.worker.js' : path;\n\n worker = new Worker(workerUrl);\n\n const consoleWarn = () =>\n console.warn('Unable to connect to the analytics web worker. Have you deployed it?');\n\n worker?.addEventListener('error', consoleWarn, false);\n\n initWorkerEnvironment(env);\n\n return {\n cleanup() {\n worker?.removeEventListener('error', consoleWarn, false);\n }\n };\n};\n\nexport const initTrackPageViews = (): {cleanup: () => void} => {\n const trackPages = async () => await trackPageView();\n\n let pushStateProxy: typeof history.pushState | null = new Proxy(history.pushState, {\n apply: async (\n target,\n thisArg,\n argArray: [data: unknown, unused: string, url?: string | URL | null | undefined]\n ) => {\n target.apply(thisArg, argArray);\n await trackPages();\n }\n });\n\n history.pushState = pushStateProxy;\n\n addEventListener('popstate', trackPages, {passive: true});\n\n return {\n cleanup() {\n pushStateProxy = null;\n removeEventListener('popstate', trackPages, false);\n }\n };\n};\n\nconst WORKER_UNDEFINED_MSG =\n 'Analytics worker not initialized. Did you call `initOrbiter`?' as const;\nconst SESSION_ID_UNDEFINED_MSG =\n 'No session ID initialized.' as const;\n\nexport const setPageView = async () => {\n if (!isBrowser()) {\n return;\n }\n\n assertNonNullish(sessionId, SESSION_ID_UNDEFINED_MSG);\n\n const {\n title,\n location: {href},\n referrer\n } = document;\n const {innerWidth, innerHeight} = window;\n const {timeZone} = Intl.DateTimeFormat().resolvedOptions();\n\n const data: IdbPageView = {\n title,\n href,\n referrer: toNullable(nonNullish(referrer) && referrer !== '' ? referrer : undefined),\n device: {\n inner_width: innerWidth,\n inner_height: innerHeight\n },\n time_zone: timeZone,\n ...userAgent(),\n ...timestamp()\n };\n\n const idb = await import('./idb.services');\n await idb.setPageView({\n sessionId,\n key: nanoid(),\n view: data\n });\n};\n\nexport const trackPageView = async () => {\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n await setPageView();\n\n worker?.postMessage({msg: 'junoTrackPageView'});\n};\n\nexport const trackEvent = async (data: TrackEvent) => {\n if (!isBrowser()) {\n return;\n }\n\n assertNonNullish(sessionId, SESSION_ID_UNDEFINED_MSG);\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n const idb = await import('./idb.services');\n await idb.setTrackEvent({\n sessionId,\n key: nanoid(),\n track: {...data, ...userAgent(), ...timestamp()}\n });\n\n worker?.postMessage({msg: 'junoTrackEvent'});\n};\n\nexport const initWorkerEnvironment = (env: PostMessageInitEnvData) => {\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n worker?.postMessage({msg: 'junoInitEnvironment', data: env});\n};\n\nexport const startTracking = () => {\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n worker?.postMessage({msg: 'junoStartTrackTimer'});\n};\n\nexport const stopTracking = () => {\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n worker?.postMessage({msg: 'junoStopTracker'});\n};\n", "import {\n initTrackPageViews,\n initWorker,\n setPageView,\n startTracking,\n stopTracking\n} from './services/analytics.services';\nimport type {Environment} from './types/env';\n\nexport {trackEvent, trackPageView} from './services/analytics.services';\nexport * from './types/env';\n\nexport const initOrbiter = async (env: Environment): Promise<() => void> => {\n // Save first page as soon as possible\n await setPageView();\n\n const {cleanup: workerCleanup} = initWorker(env);\n\n const {cleanup: pushHistoryCleanup} = initTrackPageViews();\n\n // Starting tracking will instantly sync the first page and the data from previous sessions that have not been synced yet\n startTracking();\n\n return () => {\n stopTracking();\n workerCleanup();\n pushHistoryCleanup();\n };\n};\n"],
|
|
5
|
+
"mappings": "ACCO,IAAMA,EAAgBC,GAC3BA,GAAa,KAGFC,EAAiBD,GAC5B,CAACD,EAAUC,CAAQ,EAERE,EAAN,cAA2B,KAAM,CAAC,EAE5BC,EAG0B,CAAIC,EAAUC,IAA2B,CAC9E,GAAIN,EAAUK,CAAK,EACjB,MAAM,IAAIF,EAAaG,CAAO,CAElC,ECfaC,EAAiBF,GACrBH,EAAWG,CAAK,EAAI,CAACA,CAAK,EAAI,CAAC,ECHjC,IAAMG,EAAY,IAAM,OAAO,OAAW,ICmB1C,IAAIC,EAAS,CAACC,EAAO,KAC1B,OAAO,gBAAgB,IAAI,WAAWA,CAAI,CAAC,EAAE,OAAO,CAACC,EAAIC,KACvDA,GAAQ,GACJA,EAAO,GACTD,GAAMC,EAAK,SAAS,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C,CAClD,EAEagC,EAAe,IAAM,CAChCd,EAAiBlB,EAAQc,CAAoB,EAE7Cd,GAAQ,YAAY,CAAC,IAAK,iBAAiB,CAAC,CAC9C,EC3IO,IAAMiC,EAAc,MAAOC,GAA0C,CAE1E,MAAMC,EAAY,EAElB,GAAM,CAAC,QAASC,CAAa,EAAIC,EAAWH,CAAG,EAEzC,CAAC,QAASI,CAAkB,EAAIC,EAAmB,EAGzD,OAAAC,EAAc,EAEP,IAAM,CACXC,EAAa,EACbL,EAAc,EACdE,EAAmB,CACrB,CACF",
|
|
6
|
+
"names": ["isNullish", "argument", "nonNullish", "NullishError", "assertNonNullish", "value", "message", "toNullable", "isBrowser", "nanoid", "size", "id", "byte", "nowInBigIntNanoSeconds", "timestamp", "nowInBigIntNanoSeconds", "userAgent", "T", "initSessionId", "nanoid", "sessionId", "worker", "initWorker", "env", "path", "workerUrl", "consoleWarn", "initWorkerEnvironment", "initTrackPageViews", "trackPages", "trackPageView", "pushStateProxy", "target", "thisArg", "argArray", "WORKER_UNDEFINED_MSG", "SESSION_ID_UNDEFINED_MSG", "setPageView", "y", "f", "title", "href", "referrer", "innerWidth", "innerHeight", "timeZone", "data", "T", "s", "userAgent", "timestamp", "trackEvent", "startTracking", "stopTracking", "initOrbiter", "env", "setPageView", "workerCleanup", "initWorker", "pushHistoryCleanup", "initTrackPageViews", "startTracking", "stopTracking"]
|
|
7
7
|
}
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as topLevelCreateRequire } from 'module';
|
|
2
2
|
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
-
var
|
|
3
|
+
var F=Object.defineProperty;var K=(e,t)=>()=>(e&&(t=e(e=0)),t);var G=(e,t)=>{for(var n in t)F(e,n,{get:t[n],enumerable:!0})};function c(e){return new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)})}function y(e,t){let n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(t);let r=c(n);return(i,u)=>r.then(p=>u(p.transaction(t,i).objectStore(t)))}function E(){return I||(I=y("keyval-store","keyval")),I}function b(e,t,n=E()){return n("readwrite",r=>(r.put(t,e),c(r.transaction)))}function P(e,t=E()){return t("readwrite",n=>(e.forEach(r=>n.delete(r)),c(n.transaction)))}function q(e,t){return e.openCursor().onsuccess=function(){this.result&&(t(this.result),this.result.continue())},c(e.transaction)}function x(e=E()){return e("readonly",t=>{if(t.getAll&&t.getAllKeys)return Promise.all([c(t.getAllKeys()),c(t.getAll())]).then(([r,i])=>r.map((u,p)=>[u,i[p]]));let n=[];return e("readonly",r=>q(r,i=>n.push([i.key,i.value])).then(()=>n))})}var I,j=K(()=>{});var A={};G(A,{delPageViews:()=>Y,delTrackEvents:()=>te,getPageViews:()=>X,getTrackEvents:()=>ee,setPageView:()=>Q,setTrackEvent:()=>$});var S,T,Q,X,Y,$,ee,te,N=K(()=>{"use strict";j();S=y("juno-views","views"),T=y("juno-events","events"),Q=({key:e,sessionId:t,view:n})=>b([e,t],n,S),X=()=>x(S),Y=e=>P(e,S),$=({key:e,sessionId:t,track:n})=>b([e,t],n,T),ee=()=>x(T),te=e=>P(e,T)});import{createRequire as H}from"module";var le=H(import.meta.url);var D=e=>e==null,w=e=>!D(e),z=class extends Error{},s=(e,t)=>{if(D(e))throw new z(t)},m=e=>w(e)?[e]:[];var v=()=>typeof window<"u";import{randomFillSync as _}from"crypto";var M="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var J=128,a,l,Z=e=>{!a||a.length<e?(a=Buffer.allocUnsafe(e*J),_(a),l=0):l+e>a.length&&(_(a),l=0),l+=e};var f=(e=21)=>{Z(e-=0);let t="";for(let n=l-e;n<l;n++)t+=M[a[n]&63];return t};var B=()=>BigInt(Date.now())*BigInt(1e6);var k=()=>({collected_at:B(),updated_at:[]}),h=()=>{let{userAgent:e}=navigator;return{user_agent:m(e)}};var ne=()=>{if(!(typeof crypto>"u"))return f()},g=ne(),o,O=e=>{let{path:t}=e.worker??{},n=t===void 0?"./workers/analytics.worker.js":t;o=new Worker(n);let r=()=>console.warn("Unable to connect to the analytics web worker. Have you deployed it?");return o?.addEventListener("error",r,!1),oe(e),{cleanup(){o?.removeEventListener("error",r,!1)}}},U=()=>{let e=async()=>await L(),t=new Proxy(history.pushState,{apply:async(n,r,i)=>{n.apply(r,i),await e()}});return history.pushState=t,addEventListener("popstate",e,{passive:!0}),{cleanup(){t=null,removeEventListener("popstate",e,!1)}}},d="Analytics worker not initialized. Did you call `initOrbiter`?",W="No session ID initialized.",V=async()=>{if(!v())return;s(g,W);let{title:e,location:{href:t},referrer:n}=document,{innerWidth:r,innerHeight:i}=window,{timeZone:u}=Intl.DateTimeFormat().resolvedOptions(),p={title:e,href:t,referrer:m(w(n)&&n!==""?n:void 0),device:{inner_width:r,inner_height:i},time_zone:u,...h(),...k()};await(await Promise.resolve().then(()=>(N(),A))).setPageView({sessionId:g,key:f(),view:p})},L=async()=>{s(o,d),await V(),o?.postMessage({msg:"junoTrackPageView"})},re=async e=>{if(!v())return;s(g,W),s(o,d),await(await Promise.resolve().then(()=>(N(),A))).setTrackEvent({sessionId:g,key:f(),track:{...e,...h(),...k()}}),o?.postMessage({msg:"junoTrackEvent"})},oe=e=>{s(o,d),o?.postMessage({msg:"junoInitEnvironment",data:e})},R=()=>{s(o,d),o?.postMessage({msg:"junoStartTrackTimer"})},C=()=>{s(o,d),o?.postMessage({msg:"junoStopTracker"})};var Se=async e=>{await V();let{cleanup:t}=O(e),{cleanup:n}=U();return R(),()=>{C(),t(),n()}};export{Se as initOrbiter,re as trackEvent,L as trackPageView};
|
|
4
4
|
//# sourceMappingURL=index.mjs.map
|
package/dist/node/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../node_modules/idb-keyval/dist/index.js", "../../src/services/idb.services.ts", "../../../utils/src/utils/debounce.utils.ts", "../../../utils/src/utils/null.utils.ts", "../../../utils/src/utils/did.utils.ts", "../../../utils/src/utils/env.utils.ts", "../../../../node_modules/nanoid/index.js", "../../../../node_modules/nanoid/url-alphabet/index.js", "../../src/utils/date.utils.ts", "../../src/utils/analytics.utils.ts", "../../src/services/analytics.services.ts", "../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["function promisifyRequest(request) {\n return new Promise((resolve, reject) => {\n // @ts-ignore - file size hacks\n request.oncomplete = request.onsuccess = () => resolve(request.result);\n // @ts-ignore - file size hacks\n request.onabort = request.onerror = () => reject(request.error);\n });\n}\nfunction createStore(dbName, storeName) {\n const request = indexedDB.open(dbName);\n request.onupgradeneeded = () => request.result.createObjectStore(storeName);\n const dbp = promisifyRequest(request);\n return (txMode, callback) => dbp.then((db) => callback(db.transaction(storeName, txMode).objectStore(storeName)));\n}\nlet defaultGetStoreFunc;\nfunction defaultGetStore() {\n if (!defaultGetStoreFunc) {\n defaultGetStoreFunc = createStore('keyval-store', 'keyval');\n }\n return defaultGetStoreFunc;\n}\n/**\n * Get a value by its key.\n *\n * @param key\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction get(key, customStore = defaultGetStore()) {\n return customStore('readonly', (store) => promisifyRequest(store.get(key)));\n}\n/**\n * Set a value with a key.\n *\n * @param key\n * @param value\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction set(key, value, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n store.put(value, key);\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Set multiple values at once. This is faster than calling set() multiple times.\n * It's also atomic \u2013 if one of the pairs can't be added, none will be added.\n *\n * @param entries Array of entries, where each entry is an array of `[key, value]`.\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction setMany(entries, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n entries.forEach((entry) => store.put(entry[1], entry[0]));\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Get multiple values by their keys\n *\n * @param keys\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction getMany(keys, customStore = defaultGetStore()) {\n return customStore('readonly', (store) => Promise.all(keys.map((key) => promisifyRequest(store.get(key)))));\n}\n/**\n * Update a value. This lets you see the old value and update it as an atomic operation.\n *\n * @param key\n * @param updater A callback that takes the old value and returns a new value.\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction update(key, updater, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => \n // Need to create the promise manually.\n // If I try to chain promises, the transaction closes in browsers\n // that use a promise polyfill (IE10/11).\n new Promise((resolve, reject) => {\n store.get(key).onsuccess = function () {\n try {\n store.put(updater(this.result), key);\n resolve(promisifyRequest(store.transaction));\n }\n catch (err) {\n reject(err);\n }\n };\n }));\n}\n/**\n * Delete a particular key from the store.\n *\n * @param key\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction del(key, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n store.delete(key);\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Delete multiple keys at once.\n *\n * @param keys List of keys to delete.\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction delMany(keys, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n keys.forEach((key) => store.delete(key));\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Clear all values in the store.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction clear(customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n store.clear();\n return promisifyRequest(store.transaction);\n });\n}\nfunction eachCursor(store, callback) {\n store.openCursor().onsuccess = function () {\n if (!this.result)\n return;\n callback(this.result);\n this.result.continue();\n };\n return promisifyRequest(store.transaction);\n}\n/**\n * Get all keys in the store.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction keys(customStore = defaultGetStore()) {\n return customStore('readonly', (store) => {\n // Fast path for modern browsers\n if (store.getAllKeys) {\n return promisifyRequest(store.getAllKeys());\n }\n const items = [];\n return eachCursor(store, (cursor) => items.push(cursor.key)).then(() => items);\n });\n}\n/**\n * Get all values in the store.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction values(customStore = defaultGetStore()) {\n return customStore('readonly', (store) => {\n // Fast path for modern browsers\n if (store.getAll) {\n return promisifyRequest(store.getAll());\n }\n const items = [];\n return eachCursor(store, (cursor) => items.push(cursor.value)).then(() => items);\n });\n}\n/**\n * Get all entries in the store. Each entry is an array of `[key, value]`.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction entries(customStore = defaultGetStore()) {\n return customStore('readonly', (store) => {\n // Fast path for modern browsers\n // (although, hopefully we'll get a simpler path some day)\n if (store.getAll && store.getAllKeys) {\n return Promise.all([\n promisifyRequest(store.getAllKeys()),\n promisifyRequest(store.getAll()),\n ]).then(([keys, values]) => keys.map((key, i) => [key, values[i]]));\n }\n const items = [];\n return customStore('readonly', (store) => eachCursor(store, (cursor) => items.push([cursor.key, cursor.value])).then(() => items));\n });\n}\n\nexport { clear, createStore, del, delMany, entries, get, getMany, keys, promisifyRequest, set, setMany, update, values };\n", "import {createStore, delMany, entries, set} from 'idb-keyval';\nimport type {IdbKeyKey, IdbKeySessionId, IdbPageView, IdbTrackEvent} from '../types/idb';\n\nconst viewsStore = createStore('juno-views', 'views');\nconst eventsStore = createStore('juno-events', 'events');\n\nexport const setPageView = ({\n key,\n sessionId,\n view\n}: {\n view: IdbPageView;\n key: IdbKeyKey;\n sessionId: IdbKeySessionId;\n}): Promise<void> => set([key, sessionId], view, viewsStore);\n\nexport const getPageViews = (): Promise<[IDBValidKey, IdbPageView][]> => entries(viewsStore);\n\nexport const delPageViews = (keys: IDBValidKey[]): Promise<void> => delMany(keys, viewsStore);\n\nexport const setTrackEvent = ({\n key,\n sessionId,\n track\n}: {\n key: IdbKeyKey;\n sessionId: IdbKeySessionId;\n track: IdbTrackEvent;\n}): Promise<void> => set([key, sessionId], track, eventsStore);\n\nexport const getTrackEvents = (): Promise<[IDBValidKey, IdbTrackEvent][]> => entries(eventsStore);\n\nexport const delTrackEvents = (keys: IDBValidKey[]): Promise<void> => delMany(keys, eventsStore);\n", "/* eslint-disable-next-line @typescript-eslint/ban-types */\nexport const debounce = (func: Function, timeout?: number) => {\n let timer: NodeJS.Timer | undefined;\n\n return (...args: unknown[]) => {\n const next = () => func(...args);\n\n if (timer) {\n clearTimeout(timer);\n }\n\n timer = setTimeout(next, timeout !== undefined && timeout > 0 ? timeout : 300);\n };\n};\n", "/** Is null or undefined */\nexport const isNullish = <T>(argument: T | undefined | null): argument is undefined | null =>\n argument === null || argument === undefined;\n\n/** Not null and not undefined */\nexport const nonNullish = <T>(argument: T | undefined | null): argument is NonNullable<T> =>\n !isNullish(argument);\n\nexport class NullishError extends Error {}\n\nexport const assertNonNullish: <T>(\n value: T,\n message?: string\n) => asserts value is NonNullable<T> = <T>(value: T, message?: string): void => {\n if (isNullish(value)) {\n throw new NullishError(message);\n }\n};\n", "import {nonNullish} from './null.utils';\n\nexport const toNullable = <T>(value?: T): [] | [T] => {\n return nonNullish(value) ? [value] : [];\n};\n\nexport const fromNullable = <T>(value: [] | [T]): T | undefined => {\n return value?.[0];\n};\n\nexport const toArray = async <T>(data: T): Promise<Uint8Array> => {\n const blob: Blob = new Blob([JSON.stringify(data)], {\n type: 'application/json; charset=utf-8'\n });\n return new Uint8Array(await blob.arrayBuffer());\n};\n\nexport const fromArray = async <T>(data: Uint8Array | number[]): Promise<T> => {\n const blob: Blob = new Blob([data instanceof Uint8Array ? data : new Uint8Array(data)], {\n type: 'application/json; charset=utf-8'\n });\n return JSON.parse(await blob.text());\n};\n", "export const isBrowser = () => typeof window !== `undefined`;\n", "import { randomFillSync } from 'crypto'\nimport { urlAlphabet } from './url-alphabet/index.js'\nexport { urlAlphabet }\nconst POOL_SIZE_MULTIPLIER = 128\nlet pool, poolOffset\nlet fillPool = bytes => {\n if (!pool || pool.length < bytes) {\n pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER)\n randomFillSync(pool)\n poolOffset = 0\n } else if (poolOffset + bytes > pool.length) {\n randomFillSync(pool)\n poolOffset = 0\n }\n poolOffset += bytes\n}\nexport let random = bytes => {\n fillPool((bytes -= 0))\n return pool.subarray(poolOffset - bytes, poolOffset)\n}\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1\n let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let i = step\n while (i--) {\n id += alphabet[bytes[i] & mask] || ''\n if (id.length === size) return id\n }\n }\n }\n}\nexport let customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size, random)\nexport let nanoid = (size = 21) => {\n fillPool((size -= 0))\n let id = ''\n for (let i = poolOffset - size; i < poolOffset; i++) {\n id += urlAlphabet[pool[i] & 63]\n }\n return id\n}\n", "export const urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\n", "export const nowInBigIntNanoSeconds = (): bigint => BigInt(Date.now()) * BigInt(1e6);\n", "import {toNullable} from '@junobuild/utils';\nimport {nowInBigIntNanoSeconds} from './date.utils';\n\nexport const timestamp = (): {collected_at: bigint; updated_at: [] | [bigint]} => ({\n collected_at: nowInBigIntNanoSeconds(),\n updated_at: []\n});\n\nexport const userAgent = (): {user_agent: [] | [string]} => {\n const {userAgent} = navigator;\n return {user_agent: toNullable(userAgent)};\n};\n", "import {assertNonNullish, isBrowser, nonNullish, toNullable} from '@junobuild/utils';\nimport {nanoid} from 'nanoid';\nimport type {Environment, EnvironmentWorker} from '../types/env';\nimport type {IdbPageView} from '../types/idb';\nimport type {PostMessageInitEnvData} from '../types/post-message';\nimport type {TrackEvent} from '../types/track';\nimport {timestamp, userAgent} from '../utils/analytics.utils';\n\nconst sessionId = nanoid();\n\nlet worker: Worker | undefined;\n\nexport const initWorker = (env: Environment): {cleanup: () => void} => {\n const {path}: EnvironmentWorker = env.worker ?? {};\n const workerUrl = path === undefined ? './workers/analytics.worker.js' : path;\n\n worker = new Worker(workerUrl);\n\n const consoleWarn = () =>\n console.warn('Unable to connect to the analytics web worker. Have you deployed it?');\n\n worker?.addEventListener('error', consoleWarn, false);\n\n initWorkerEnvironment(env);\n\n return {\n cleanup() {\n worker?.removeEventListener('error', consoleWarn, false);\n }\n };\n};\n\nexport const initTrackPageViews = (): {cleanup: () => void} => {\n const trackPages = async () => await trackPageView();\n\n let pushStateProxy: typeof history.pushState | null = new Proxy(history.pushState, {\n apply: async (\n target,\n thisArg,\n argArray: [data: unknown, unused: string, url?: string | URL | null | undefined]\n ) => {\n target.apply(thisArg, argArray);\n await trackPages();\n }\n });\n\n history.pushState = pushStateProxy;\n\n addEventListener('popstate', trackPages, {passive: true});\n\n return {\n cleanup() {\n pushStateProxy = null;\n removeEventListener('popstate', trackPages, false);\n }\n };\n};\n\nconst WORKER_UNDEFINED_MSG =\n 'Analytics worker not initialized. Did you call `initWorker`?' as const;\n\nexport const setPageView = async () => {\n if (!isBrowser()) {\n return;\n }\n\n const {\n title,\n location: {href},\n referrer\n } = document;\n const {innerWidth, innerHeight} = window;\n const {timeZone} = Intl.DateTimeFormat().resolvedOptions();\n\n const data: IdbPageView = {\n title,\n href,\n referrer: toNullable(nonNullish(referrer) && referrer !== '' ? referrer : undefined),\n device: {\n inner_width: innerWidth,\n inner_height: innerHeight\n },\n time_zone: timeZone,\n ...userAgent(),\n ...timestamp()\n };\n\n const idb = await import('./idb.services');\n await idb.setPageView({\n sessionId,\n key: nanoid(),\n view: data\n });\n};\n\nexport const trackPageView = async () => {\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n await setPageView();\n\n worker?.postMessage({msg: 'junoTrackPageView'});\n};\n\nexport const trackEvent = async (data: TrackEvent) => {\n if (!isBrowser()) {\n return;\n }\n\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n const idb = await import('./idb.services');\n await idb.setTrackEvent({\n sessionId,\n key: nanoid(),\n track: {...data, ...userAgent(), ...timestamp()}\n });\n\n worker?.postMessage({msg: 'junoTrackEvent'});\n};\n\nexport const initWorkerEnvironment = (env: PostMessageInitEnvData) => {\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n worker?.postMessage({msg: 'junoInitEnvironment', data: env});\n};\n\nexport const startTracking = () => {\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n worker?.postMessage({msg: 'junoStartTrackTimer'});\n};\n\nexport const stopTracking = () => {\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n worker?.postMessage({msg: 'junoStopTracker'});\n};\n", "import {\n initTrackPageViews,\n initWorker,\n setPageView,\n startTracking,\n stopTracking\n} from './services/analytics.services';\nimport type {Environment} from './types/env';\n\nexport {trackEvent, trackPageView} from './services/analytics.services';\nexport * from './types/env';\n\nexport const initOrbiter = async (env: Environment): Promise<() => void> => {\n // Save first page as soon as possible\n await setPageView();\n\n const {cleanup: workerCleanup} = initWorker(env);\n\n const {cleanup: pushHistoryCleanup} = initTrackPageViews();\n\n // Starting tracking will instantly sync the first page and the data from previous sessions that have not been synced yet\n startTracking();\n\n return () => {\n stopTracking();\n workerCleanup();\n pushHistoryCleanup();\n };\n};\n"],
|
|
5
|
-
"mappings": ";;6HAAA,SAASA,EAAiBC,EAAS,CAC/B,OAAO,IAAI,QAAQ,CAACC,EAASC,IAAW,CAEpCF,EAAQ,WAAaA,EAAQ,UAAY,IAAMC,EAAQD,EAAQ,MAAM,EAErEA,EAAQ,QAAUA,EAAQ,QAAU,IAAME,EAAOF,EAAQ,KAAK,CAClE,CAAC,CACL,CACA,SAASG,EAAYC,EAAQC,EAAW,CACpC,IAAML,EAAU,UAAU,KAAKI,CAAM,EACrCJ,EAAQ,gBAAkB,IAAMA,EAAQ,OAAO,kBAAkBK,CAAS,EAC1E,IAAMC,EAAM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C,CACrI,CAAC,CACL,CArLA,IAcIZ,EAdJc,EAAAC,EAAA,QCAA,IAAAC,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,EAAA,mBAAAC,GAAA,iBAAAC,EAAA,mBAAAC,
|
|
6
|
-
"names": ["promisifyRequest", "request", "resolve", "reject", "createStore", "dbName", "storeName", "dbp", "txMode", "callback", "db", "defaultGetStore", "defaultGetStoreFunc", "set", "key", "value", "customStore", "store", "delMany", "keys", "eachCursor", "entries", "values", "i", "items", "cursor", "init_dist", "__esmMin", "idb_services_exports", "__export", "delPageViews", "delTrackEvents", "getPageViews", "getTrackEvents", "setPageView", "setTrackEvent", "viewsStore", "eventsStore", "init_idb_services", "__esmMin", "init_dist", "createStore", "key", "sessionId", "view", "set", "entries", "keys", "delMany", "track", "isNullish", "argument", "nonNullish", "NullishError", "assertNonNullish", "value", "message", "toNullable", "isBrowser", "randomFillSync", "urlAlphabet", "POOL_SIZE_MULTIPLIER", "pool", "poolOffset", "fillPool", "bytes", "randomFillSync", "nanoid", "size", "fillPool", "id", "i", "poolOffset", "urlAlphabet", "pool", "nowInBigIntNanoSeconds", "timestamp", "nowInBigIntNanoSeconds", "userAgent", "T", "
|
|
4
|
+
"sourcesContent": ["function promisifyRequest(request) {\n return new Promise((resolve, reject) => {\n // @ts-ignore - file size hacks\n request.oncomplete = request.onsuccess = () => resolve(request.result);\n // @ts-ignore - file size hacks\n request.onabort = request.onerror = () => reject(request.error);\n });\n}\nfunction createStore(dbName, storeName) {\n const request = indexedDB.open(dbName);\n request.onupgradeneeded = () => request.result.createObjectStore(storeName);\n const dbp = promisifyRequest(request);\n return (txMode, callback) => dbp.then((db) => callback(db.transaction(storeName, txMode).objectStore(storeName)));\n}\nlet defaultGetStoreFunc;\nfunction defaultGetStore() {\n if (!defaultGetStoreFunc) {\n defaultGetStoreFunc = createStore('keyval-store', 'keyval');\n }\n return defaultGetStoreFunc;\n}\n/**\n * Get a value by its key.\n *\n * @param key\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction get(key, customStore = defaultGetStore()) {\n return customStore('readonly', (store) => promisifyRequest(store.get(key)));\n}\n/**\n * Set a value with a key.\n *\n * @param key\n * @param value\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction set(key, value, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n store.put(value, key);\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Set multiple values at once. This is faster than calling set() multiple times.\n * It's also atomic \u2013 if one of the pairs can't be added, none will be added.\n *\n * @param entries Array of entries, where each entry is an array of `[key, value]`.\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction setMany(entries, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n entries.forEach((entry) => store.put(entry[1], entry[0]));\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Get multiple values by their keys\n *\n * @param keys\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction getMany(keys, customStore = defaultGetStore()) {\n return customStore('readonly', (store) => Promise.all(keys.map((key) => promisifyRequest(store.get(key)))));\n}\n/**\n * Update a value. This lets you see the old value and update it as an atomic operation.\n *\n * @param key\n * @param updater A callback that takes the old value and returns a new value.\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction update(key, updater, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => \n // Need to create the promise manually.\n // If I try to chain promises, the transaction closes in browsers\n // that use a promise polyfill (IE10/11).\n new Promise((resolve, reject) => {\n store.get(key).onsuccess = function () {\n try {\n store.put(updater(this.result), key);\n resolve(promisifyRequest(store.transaction));\n }\n catch (err) {\n reject(err);\n }\n };\n }));\n}\n/**\n * Delete a particular key from the store.\n *\n * @param key\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction del(key, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n store.delete(key);\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Delete multiple keys at once.\n *\n * @param keys List of keys to delete.\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction delMany(keys, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n keys.forEach((key) => store.delete(key));\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Clear all values in the store.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction clear(customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n store.clear();\n return promisifyRequest(store.transaction);\n });\n}\nfunction eachCursor(store, callback) {\n store.openCursor().onsuccess = function () {\n if (!this.result)\n return;\n callback(this.result);\n this.result.continue();\n };\n return promisifyRequest(store.transaction);\n}\n/**\n * Get all keys in the store.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction keys(customStore = defaultGetStore()) {\n return customStore('readonly', (store) => {\n // Fast path for modern browsers\n if (store.getAllKeys) {\n return promisifyRequest(store.getAllKeys());\n }\n const items = [];\n return eachCursor(store, (cursor) => items.push(cursor.key)).then(() => items);\n });\n}\n/**\n * Get all values in the store.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction values(customStore = defaultGetStore()) {\n return customStore('readonly', (store) => {\n // Fast path for modern browsers\n if (store.getAll) {\n return promisifyRequest(store.getAll());\n }\n const items = [];\n return eachCursor(store, (cursor) => items.push(cursor.value)).then(() => items);\n });\n}\n/**\n * Get all entries in the store. Each entry is an array of `[key, value]`.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction entries(customStore = defaultGetStore()) {\n return customStore('readonly', (store) => {\n // Fast path for modern browsers\n // (although, hopefully we'll get a simpler path some day)\n if (store.getAll && store.getAllKeys) {\n return Promise.all([\n promisifyRequest(store.getAllKeys()),\n promisifyRequest(store.getAll()),\n ]).then(([keys, values]) => keys.map((key, i) => [key, values[i]]));\n }\n const items = [];\n return customStore('readonly', (store) => eachCursor(store, (cursor) => items.push([cursor.key, cursor.value])).then(() => items));\n });\n}\n\nexport { clear, createStore, del, delMany, entries, get, getMany, keys, promisifyRequest, set, setMany, update, values };\n", "import {createStore, delMany, entries, set} from 'idb-keyval';\nimport type {IdbKeyKey, IdbKeySessionId, IdbPageView, IdbTrackEvent} from '../types/idb';\n\nconst viewsStore = createStore('juno-views', 'views');\nconst eventsStore = createStore('juno-events', 'events');\n\nexport const setPageView = ({\n key,\n sessionId,\n view\n}: {\n view: IdbPageView;\n key: IdbKeyKey;\n sessionId: IdbKeySessionId;\n}): Promise<void> => set([key, sessionId], view, viewsStore);\n\nexport const getPageViews = (): Promise<[IDBValidKey, IdbPageView][]> => entries(viewsStore);\n\nexport const delPageViews = (keys: IDBValidKey[]): Promise<void> => delMany(keys, viewsStore);\n\nexport const setTrackEvent = ({\n key,\n sessionId,\n track\n}: {\n key: IdbKeyKey;\n sessionId: IdbKeySessionId;\n track: IdbTrackEvent;\n}): Promise<void> => set([key, sessionId], track, eventsStore);\n\nexport const getTrackEvents = (): Promise<[IDBValidKey, IdbTrackEvent][]> => entries(eventsStore);\n\nexport const delTrackEvents = (keys: IDBValidKey[]): Promise<void> => delMany(keys, eventsStore);\n", "/* eslint-disable-next-line @typescript-eslint/ban-types */\nexport const debounce = (func: Function, timeout?: number) => {\n let timer: NodeJS.Timer | undefined;\n\n return (...args: unknown[]) => {\n const next = () => func(...args);\n\n if (timer) {\n clearTimeout(timer);\n }\n\n timer = setTimeout(next, timeout !== undefined && timeout > 0 ? timeout : 300);\n };\n};\n", "/** Is null or undefined */\nexport const isNullish = <T>(argument: T | undefined | null): argument is undefined | null =>\n argument === null || argument === undefined;\n\n/** Not null and not undefined */\nexport const nonNullish = <T>(argument: T | undefined | null): argument is NonNullable<T> =>\n !isNullish(argument);\n\nexport class NullishError extends Error {}\n\nexport const assertNonNullish: <T>(\n value: T,\n message?: string\n) => asserts value is NonNullable<T> = <T>(value: T, message?: string): void => {\n if (isNullish(value)) {\n throw new NullishError(message);\n }\n};\n", "import {nonNullish} from './null.utils';\n\nexport const toNullable = <T>(value?: T): [] | [T] => {\n return nonNullish(value) ? [value] : [];\n};\n\nexport const fromNullable = <T>(value: [] | [T]): T | undefined => {\n return value?.[0];\n};\n\nexport const toArray = async <T>(data: T): Promise<Uint8Array> => {\n const blob: Blob = new Blob([JSON.stringify(data)], {\n type: 'application/json; charset=utf-8'\n });\n return new Uint8Array(await blob.arrayBuffer());\n};\n\nexport const fromArray = async <T>(data: Uint8Array | number[]): Promise<T> => {\n const blob: Blob = new Blob([data instanceof Uint8Array ? data : new Uint8Array(data)], {\n type: 'application/json; charset=utf-8'\n });\n return JSON.parse(await blob.text());\n};\n", "export const isBrowser = () => typeof window !== `undefined`;\n", "import { randomFillSync } from 'crypto'\nimport { urlAlphabet } from './url-alphabet/index.js'\nexport { urlAlphabet }\nconst POOL_SIZE_MULTIPLIER = 128\nlet pool, poolOffset\nlet fillPool = bytes => {\n if (!pool || pool.length < bytes) {\n pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER)\n randomFillSync(pool)\n poolOffset = 0\n } else if (poolOffset + bytes > pool.length) {\n randomFillSync(pool)\n poolOffset = 0\n }\n poolOffset += bytes\n}\nexport let random = bytes => {\n fillPool((bytes -= 0))\n return pool.subarray(poolOffset - bytes, poolOffset)\n}\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1\n let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let i = step\n while (i--) {\n id += alphabet[bytes[i] & mask] || ''\n if (id.length === size) return id\n }\n }\n }\n}\nexport let customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size, random)\nexport let nanoid = (size = 21) => {\n fillPool((size -= 0))\n let id = ''\n for (let i = poolOffset - size; i < poolOffset; i++) {\n id += urlAlphabet[pool[i] & 63]\n }\n return id\n}\n", "export const urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\n", "export const nowInBigIntNanoSeconds = (): bigint => BigInt(Date.now()) * BigInt(1e6);\n", "import {toNullable} from '@junobuild/utils';\nimport {nowInBigIntNanoSeconds} from './date.utils';\n\nexport const timestamp = (): {collected_at: bigint; updated_at: [] | [bigint]} => ({\n collected_at: nowInBigIntNanoSeconds(),\n updated_at: []\n});\n\nexport const userAgent = (): {user_agent: [] | [string]} => {\n const {userAgent} = navigator;\n return {user_agent: toNullable(userAgent)};\n};\n", "import {assertNonNullish, isBrowser, nonNullish, toNullable} from '@junobuild/utils';\nimport {nanoid} from 'nanoid';\nimport type {Environment, EnvironmentWorker} from '../types/env';\nimport type {IdbPageView} from '../types/idb';\nimport type {PostMessageInitEnvData} from '../types/post-message';\nimport type {TrackEvent} from '../types/track';\nimport {timestamp, userAgent} from '../utils/analytics.utils';\n\nconst initSessionId = (): string | undefined => {\n // I faced this issue when I used the library in Docusaurus which does not implement the crypto API when server-side rendering.\n // https://github.com/ai/nanoid/issues?q=crypto+not+defined\n if (typeof crypto === 'undefined') {\n return undefined;\n }\n\n return nanoid();\n}\n\nconst sessionId = initSessionId();\n\nlet worker: Worker | undefined;\n\nexport const initWorker = (env: Environment): {cleanup: () => void} => {\n const {path}: EnvironmentWorker = env.worker ?? {};\n const workerUrl = path === undefined ? './workers/analytics.worker.js' : path;\n\n worker = new Worker(workerUrl);\n\n const consoleWarn = () =>\n console.warn('Unable to connect to the analytics web worker. Have you deployed it?');\n\n worker?.addEventListener('error', consoleWarn, false);\n\n initWorkerEnvironment(env);\n\n return {\n cleanup() {\n worker?.removeEventListener('error', consoleWarn, false);\n }\n };\n};\n\nexport const initTrackPageViews = (): {cleanup: () => void} => {\n const trackPages = async () => await trackPageView();\n\n let pushStateProxy: typeof history.pushState | null = new Proxy(history.pushState, {\n apply: async (\n target,\n thisArg,\n argArray: [data: unknown, unused: string, url?: string | URL | null | undefined]\n ) => {\n target.apply(thisArg, argArray);\n await trackPages();\n }\n });\n\n history.pushState = pushStateProxy;\n\n addEventListener('popstate', trackPages, {passive: true});\n\n return {\n cleanup() {\n pushStateProxy = null;\n removeEventListener('popstate', trackPages, false);\n }\n };\n};\n\nconst WORKER_UNDEFINED_MSG =\n 'Analytics worker not initialized. Did you call `initOrbiter`?' as const;\nconst SESSION_ID_UNDEFINED_MSG =\n 'No session ID initialized.' as const;\n\nexport const setPageView = async () => {\n if (!isBrowser()) {\n return;\n }\n\n assertNonNullish(sessionId, SESSION_ID_UNDEFINED_MSG);\n\n const {\n title,\n location: {href},\n referrer\n } = document;\n const {innerWidth, innerHeight} = window;\n const {timeZone} = Intl.DateTimeFormat().resolvedOptions();\n\n const data: IdbPageView = {\n title,\n href,\n referrer: toNullable(nonNullish(referrer) && referrer !== '' ? referrer : undefined),\n device: {\n inner_width: innerWidth,\n inner_height: innerHeight\n },\n time_zone: timeZone,\n ...userAgent(),\n ...timestamp()\n };\n\n const idb = await import('./idb.services');\n await idb.setPageView({\n sessionId,\n key: nanoid(),\n view: data\n });\n};\n\nexport const trackPageView = async () => {\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n await setPageView();\n\n worker?.postMessage({msg: 'junoTrackPageView'});\n};\n\nexport const trackEvent = async (data: TrackEvent) => {\n if (!isBrowser()) {\n return;\n }\n\n assertNonNullish(sessionId, SESSION_ID_UNDEFINED_MSG);\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n const idb = await import('./idb.services');\n await idb.setTrackEvent({\n sessionId,\n key: nanoid(),\n track: {...data, ...userAgent(), ...timestamp()}\n });\n\n worker?.postMessage({msg: 'junoTrackEvent'});\n};\n\nexport const initWorkerEnvironment = (env: PostMessageInitEnvData) => {\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n worker?.postMessage({msg: 'junoInitEnvironment', data: env});\n};\n\nexport const startTracking = () => {\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n worker?.postMessage({msg: 'junoStartTrackTimer'});\n};\n\nexport const stopTracking = () => {\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n worker?.postMessage({msg: 'junoStopTracker'});\n};\n", "import {\n initTrackPageViews,\n initWorker,\n setPageView,\n startTracking,\n stopTracking\n} from './services/analytics.services';\nimport type {Environment} from './types/env';\n\nexport {trackEvent, trackPageView} from './services/analytics.services';\nexport * from './types/env';\n\nexport const initOrbiter = async (env: Environment): Promise<() => void> => {\n // Save first page as soon as possible\n await setPageView();\n\n const {cleanup: workerCleanup} = initWorker(env);\n\n const {cleanup: pushHistoryCleanup} = initTrackPageViews();\n\n // Starting tracking will instantly sync the first page and the data from previous sessions that have not been synced yet\n startTracking();\n\n return () => {\n stopTracking();\n workerCleanup();\n pushHistoryCleanup();\n };\n};\n"],
|
|
5
|
+
"mappings": ";;6HAAA,SAASA,EAAiBC,EAAS,CAC/B,OAAO,IAAI,QAAQ,CAACC,EAASC,IAAW,CAEpCF,EAAQ,WAAaA,EAAQ,UAAY,IAAMC,EAAQD,EAAQ,MAAM,EAErEA,EAAQ,QAAUA,EAAQ,QAAU,IAAME,EAAOF,EAAQ,KAAK,CAClE,CAAC,CACL,CACA,SAASG,EAAYC,EAAQC,EAAW,CACpC,IAAML,EAAU,UAAU,KAAKI,CAAM,EACrCJ,EAAQ,gBAAkB,IAAMA,EAAQ,OAAO,kBAAkBK,CAAS,EAC1E,IAAMC,EAAMP,EAAiBC,CAAO,EACpC,MAAO,CAACO,EAAQC,IAAaF,EAAI,KAAMG,GAAOD,EAASC,EAAG,YAAYJ,EAAWE,CAAM,EAAE,YAAYF,CAAS,CAAC,CAAC,CACpH,CAEA,SAASK,GAAkB,CACvB,OAAKC,IACDA,EAAsBR,EAAY,eAAgB,QAAQ,GAEvDQ,CACX,CAiBA,SAASC,EAAIC,EAAKC,EAAOC,EAAcL,EAAgB,EAAG,CACtD,OAAOK,EAAY,YAAcC,IAC7BA,EAAM,IAAIF,EAAOD,CAAG,EACbd,EAAiBiB,EAAM,WAAW,EAC5C,CACL,CAiEA,SAASC,EAAQC,EAAMH,EAAcL,EAAgB,EAAG,CAC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EAAIC,EAAmB,EAGzD,OAAAC,EAAc,EAEP,IAAM,CACXC,EAAa,EACbL,EAAc,EACdE,EAAmB,CACrB,CACF",
|
|
6
|
+
"names": ["promisifyRequest", "request", "resolve", "reject", "createStore", "dbName", "storeName", "dbp", "txMode", "callback", "db", "defaultGetStore", "defaultGetStoreFunc", "set", "key", "value", "customStore", "store", "delMany", "keys", "eachCursor", "entries", "values", "i", "items", "cursor", "init_dist", "__esmMin", "idb_services_exports", "__export", "delPageViews", "delTrackEvents", "getPageViews", "getTrackEvents", "setPageView", "setTrackEvent", "viewsStore", "eventsStore", "init_idb_services", "__esmMin", "init_dist", "createStore", "key", "sessionId", "view", "set", "entries", "keys", "delMany", "track", "isNullish", "argument", "nonNullish", "NullishError", "assertNonNullish", "value", "message", "toNullable", "isBrowser", "randomFillSync", "urlAlphabet", "POOL_SIZE_MULTIPLIER", "pool", "poolOffset", "fillPool", "bytes", "randomFillSync", "nanoid", "size", "fillPool", "id", "i", "poolOffset", "urlAlphabet", "pool", "nowInBigIntNanoSeconds", "timestamp", "nowInBigIntNanoSeconds", "userAgent", "T", "initSessionId", "nanoid", "sessionId", "worker", "initWorker", "env", "path", "workerUrl", "consoleWarn", "initWorkerEnvironment", "initTrackPageViews", "trackPages", "trackPageView", "pushStateProxy", "target", "thisArg", "argArray", "WORKER_UNDEFINED_MSG", "SESSION_ID_UNDEFINED_MSG", "setPageView", "y", "f", "title", "href", "referrer", "innerWidth", "innerHeight", "timeZone", "data", "T", "s", "userAgent", "timestamp", "trackEvent", "startTracking", "stopTracking", "initOrbiter", "env", "setPageView", "workerCleanup", "initWorker", "pushHistoryCleanup", "initTrackPageViews", "startTracking", "stopTracking"]
|
|
7
7
|
}
|