@lidofinance/analytics-matomo 0.57.0 → 0.58.0
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/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -104,7 +104,7 @@ const $8ec118068c18cb0c$var$injectMatomoScript = (matomoHost)=>{
|
|
|
104
104
|
* For other options see https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity#tools_for_generating_sri_hashes
|
|
105
105
|
*/ integrity: [
|
|
106
106
|
"sha384-cT0Nk8wS/smX3tvm0JOiaJhNeO5DbtYoG0ReQ6VlEE5EPNjmbcuZa1NwGwg14Hqa",
|
|
107
|
-
"sha384-
|
|
107
|
+
"sha384-iu/OZ4/Rk57hZYRyQrM5W4VNMMHSRB5Wg/s2g4zAVSSXZu3UfuhTz7E/sAlLhQkz"
|
|
108
108
|
].join(" ")
|
|
109
109
|
}));
|
|
110
110
|
};
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AEGO,MAAM,4CAA2B;AACjC,MAAM,4CAA0B;AAChC,MAAM,2CAAmB;AAEzB,MAAM,4CAAsB;IACjC;IACA;CACD;AAEM,MAAM,4CAAkB;IAC7B,OAAO,OAAO,WAAW,eAAe,OAAO,SAAS;AAC1D;AAEA,MAAM,uDAAiC,CAAC;IACtC,MAAM,eAAe;IAErB,IAAI,OAAO,WAAW,aACpB,OAAO;IAGT,MAAM,gBAAgB,IAAI,OAAO,CAAC,KAAK,EAAE,IAAI,QAAQ,CAAC;IACtD,OAAO,AAAC,SAAS,OAAO,MAAM,gBAAgB,CAAC,EAAE,IAAe;AAClE;AAEO,MAAM,4CAAa,CAAC,WAAmB,GAAG;IAC/C,IAAI,CAAC,6CACH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Ac;gBAAC,CAAC,EAAE,EAAE,CAAA,GAAA,wCAAQ,IAAI,CAAC;aAAC;SAAC;QACpC;YAAC;YAA4B;SAAK;KACnC;IAED,0BAA0B;IAC1B,MAAM,SAAS,IAAI;IACnB,KAAK,MAAM,CAAC,KAAK,MAAM,IAAI,UACzB,IAAI,CAAC,OAAO,IAAI,MACd,OAAO,IAAI,KAAK;IAIpB,QAAQ,MAAM,QACT,MAAM,KAAK,OAAO,WAClB,IAAI,CAAC,CAAC,KAAK,MAAM;QAChB,OAAQ;YACN,KAAK;gBACH,OAAO;YACT,KAAK;YACL,KAAK;gBACH,OAAO;oBAAC;iBAAI;YACd;gBACE,OAAO;oBAAC;oBAAK;iBAAM;QACvB;IACF,GACC,OAAO,CAAC,OAAyC,SAAS;IAG/D,yCAAmB;AACrB;;;;;;;;;;AG/GO,MAAM,4CAAqB,CAAyB,OAA+B,KACxF,QACI,CAAC,GAAG;QACF,CAAA,GAAA,yCAAS,EAAE,iBAAiB;QAC5B,OAAO,QAAQ;IACjB,IACA;;;;AJFN,mBAAmB;AACnB,CAAA,GAAA,yCAAS","sources":["packages/analytics/matomo/src/index.ts","packages/analytics/matomo/src/init.ts","packages/analytics/matomo/src/utils.ts","packages/analytics/matomo/src/type.ts","packages/analytics/matomo/src/decoratorts.ts"],"sourcesContent":["import { initMatomo } from './init'\n\nexport * from './type'\nexport * from './decoratorts'\nexport * from './utils'\nexport * from './init'\n\n// Run after import\ninitMatomo()\n","import { getDomain } from './utils'\n\ndeclare global {\n interface Window {\n _paq?: undefined | [string, ...unknown[]][]\n __env__: { matomoHost: string } & Record<string | number | symbol, unknown>\n }\n}\n\nconst injectMatomoScript = (matomoHost: string) => {\n /**\n * # How to update matomo\n *\n * To safely update Matomo without analytics downtime:\n *\n * 1. Download the new Matomo version zip from https://github.com/matomo-org/matomo/releases\n * 2. Extract matomo.js from the zip archive\n * 3. Generate integrity checksum:\n * - Run: `cat matomo.js | openssl dgst -sha384 -binary | openssl base64 -A`\n * - Add 'sha384-' prefix to the generated hash\n * 4. Add the new integrity hash to the array below (keep the old one)\n * 5. Release this package and update all dependent repositories\n *\n * Notes:\n * - The script will automatically use the matching integrity hash\n * - Old integrity values can be safely removed later if desired\n * - No console errors will occur during the transition\n * - This approach ensures zero analytics downtime during updates\n */\n document.documentElement.appendChild(\n Object.assign(document.createElement('script'), {\n async: true,\n src: new URL('/matomo.js', matomoHost).href,\n crossOrigin: 'anonymous',\n /**\n * To generate checksum:\n * 1. Download matomo.js via `curl -O https://matomo.lido.fi/matomo.js`\n * 2. Calculate checkusm via `cat matomo.js | openssl dgst -sha384 -binary | openssl base64 -A`\n * 3. Add sha384 prefix\n * For other options see https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity#tools_for_generating_sri_hashes\n */\n integrity: [\n 'sha384-cT0Nk8wS/smX3tvm0JOiaJhNeO5DbtYoG0ReQ6VlEE5EPNjmbcuZa1NwGwg14Hqa', // Matomo v 5.2.0 && Matomo v 5.2.2 without cookies (cookie-less analytics) deprecate later\n 'sha384-
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AEGO,MAAM,4CAA2B;AACjC,MAAM,4CAA0B;AAChC,MAAM,2CAAmB;AAEzB,MAAM,4CAAsB;IACjC;IACA;CACD;AAEM,MAAM,4CAAkB;IAC7B,OAAO,OAAO,WAAW,eAAe,OAAO,SAAS;AAC1D;AAEA,MAAM,uDAAiC,CAAC;IACtC,MAAM,eAAe;IAErB,IAAI,OAAO,WAAW,aACpB,OAAO;IAGT,MAAM,gBAAgB,IAAI,OAAO,CAAC,KAAK,EAAE,IAAI,QAAQ,CAAC;IACtD,OAAO,AAAC,SAAS,OAAO,MAAM,gBAAgB,CAAC,EAAE,IAAe;AAClE;AAEO,MAAM,4CAAa,CAAC,WAAmB,GAAG;IAC/C,IAAI,CAAC,6CACH,CAAA,GAAA,yCAAS;IAGX,IAAI,OAAO,WAAW,aACpB;IAGF,MAAM,uBAAuB,qDA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ACpC;YAAC;YAA4B;SAAK;KACnC;IAED,0BAA0B;IAC1B,MAAM,SAAS,IAAI;IACnB,KAAK,MAAM,CAAC,KAAK,MAAM,IAAI,UACzB,IAAI,CAAC,OAAO,IAAI,MACd,OAAO,IAAI,KAAK;IAIpB,QAAQ,MAAM,QACT,MAAM,KAAK,OAAO,WAClB,IAAI,CAAC,CAAC,KAAK,MAAM;QAChB,OAAQ;YACN,KAAK;gBACH,OAAO;YACT,KAAK;YACL,KAAK;gBACH,OAAO;oBAAC;iBAAI;YACd;gBACE,OAAO;oBAAC;oBAAK;iBAAM;QACvB;IACF,GACC,OAAO,CAAC,OAAyC,SAAS;IAG/D,yCAAmB;AACrB;;;;;;;;;;AG/GO,MAAM,4CAAqB,CAAyB,OAA+B,KACxF,QACI,CAAC,GAAG;QACF,CAAA,GAAA,yCAAS,EAAE,iBAAiB;QAC5B,OAAO,QAAQ;IACjB,IACA;;;;AJFN,mBAAmB;AACnB,CAAA,GAAA,yCAAS","sources":["packages/analytics/matomo/src/index.ts","packages/analytics/matomo/src/init.ts","packages/analytics/matomo/src/utils.ts","packages/analytics/matomo/src/type.ts","packages/analytics/matomo/src/decoratorts.ts"],"sourcesContent":["import { initMatomo } from './init'\n\nexport * from './type'\nexport * from './decoratorts'\nexport * from './utils'\nexport * from './init'\n\n// Run after import\ninitMatomo()\n","import { getDomain } from './utils'\n\ndeclare global {\n interface Window {\n _paq?: undefined | [string, ...unknown[]][]\n __env__: { matomoHost: string } & Record<string | number | symbol, unknown>\n }\n}\n\nconst injectMatomoScript = (matomoHost: string) => {\n /**\n * # How to update matomo\n *\n * To safely update Matomo without analytics downtime:\n *\n * 1. Download the new Matomo version zip from https://github.com/matomo-org/matomo/releases\n * 2. Extract matomo.js from the zip archive\n * 3. Generate integrity checksum:\n * - Run: `cat matomo.js | openssl dgst -sha384 -binary | openssl base64 -A`\n * - Add 'sha384-' prefix to the generated hash\n * 4. Add the new integrity hash to the array below (keep the old one)\n * 5. Release this package and update all dependent repositories\n *\n * Notes:\n * - The script will automatically use the matching integrity hash\n * - Old integrity values can be safely removed later if desired\n * - No console errors will occur during the transition\n * - This approach ensures zero analytics downtime during updates\n */\n document.documentElement.appendChild(\n Object.assign(document.createElement('script'), {\n async: true,\n src: new URL('/matomo.js', matomoHost).href,\n crossOrigin: 'anonymous',\n /**\n * To generate checksum:\n * 1. Download matomo.js via `curl -O https://matomo.lido.fi/matomo.js`\n * 2. Calculate checkusm via `cat matomo.js | openssl dgst -sha384 -binary | openssl base64 -A`\n * 3. Add sha384 prefix\n * For other options see https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity#tools_for_generating_sri_hashes\n */\n integrity: [\n 'sha384-cT0Nk8wS/smX3tvm0JOiaJhNeO5DbtYoG0ReQ6VlEE5EPNjmbcuZa1NwGwg14Hqa', // Matomo v 5.2.0 && Matomo v 5.2.2 without cookies (cookie-less analytics) deprecate later\n 'sha384-iu/OZ4/Rk57hZYRyQrM5W4VNMMHSRB5Wg/s2g4zAVSSXZu3UfuhTz7E/sAlLhQkz', // Matomo v 5.2.2 && Matomo v 5.8.0\n ].join(' '),\n }),\n )\n}\n\nexport type MatomoConfig = Array<[string, ...unknown[]]>\n\nexport const initMatomo = (matomoHost?: string, customConfig: MatomoConfig = []): void => {\n if (typeof window === 'undefined') {\n // SSR not supported!\n return\n }\n\n const _matomoHost = matomoHost || window?.__env__?.matomoHost || undefined\n\n if (!_matomoHost) {\n // Where Do I send analytics?\n return\n }\n\n if (window._paq) {\n // window._paq has been initialized\n return\n }\n\n window._paq ??= []\n\n const rawConfig = [\n // These are hardcoded values and cannot be changed\n ['setTrackerUrl', new URL('/matomo.php', _matomoHost).href],\n ['requireCookieConsent', true],\n // Add subdomain prefix to page titles to separate analytics by subdomain\n ['setDocumentTitle', window.location.hostname + '/' + (document.title || '')],\n\n // These are custom settings\n ...customConfig,\n\n // These are default settings, will be overwritten if custom set\n ['trackPageView', true],\n ['enableLinkTracking', true],\n ['setSiteId', '1'],\n ['setDomains', [`*.${getDomain()}`]],\n ['enableCrossDomainLinking', true],\n ]\n\n // Map keeps order of keys\n const config = new Map()\n for (const [key, value] of rawConfig) {\n if (!config.has(key)) {\n config.set(key, value)\n }\n }\n\n window?._paq?.push(\n ...Array.from(config.entries())\n .map(([key, value]) => {\n switch (value) {\n case false:\n return false\n case true:\n case undefined:\n return [key]\n default:\n return [key, value]\n }\n })\n .filter((item): item is [string, ...unknown[]] => item !== false),\n )\n\n injectMatomoScript(_matomoHost)\n}\n","import { initMatomo } from './init'\nimport { MatomoEventType } from './type'\n\nexport const COOKIE_ALLOWED_VALUE_YES = 'yes'\nexport const COOKIE_ALLOWED_MAIN_KEY = 'cookie-allowed'\nexport const META_INFO_COOKIE = 'meta-info'\n\nexport const COOKIE_ALLOWED_KEYS = [\n 'LIDO_WIDGET__COOKIES_ALLOWED', // will be deprecated soon\n COOKIE_ALLOWED_MAIN_KEY,\n]\n\nexport const matomoAvailable = (): boolean => {\n return typeof window !== 'undefined' && window._paq !== undefined\n}\n\nconst getCrossDomainCookieClientSide = (key: string): string | null => {\n const defaultValue = null\n\n if (typeof window === 'undefined') {\n return defaultValue\n }\n\n const cookieMatcher = new RegExp(`(^| )${key}=([^;]+)`)\n return (document.cookie.match(cookieMatcher)?.[2] as string) ?? defaultValue\n}\n\nexport const callMatomo = (apiMethod: string, ...args: unknown[]): void => {\n if (!matomoAvailable()) {\n initMatomo()\n }\n\n if (typeof window === 'undefined') {\n return\n }\n\n const customDimensionValue = getCrossDomainCookieClientSide(META_INFO_COOKIE) || 'none'\n window?._paq?.push(['setCustomDimension', 1, customDimensionValue])\n\n window?._paq?.push([apiMethod, ...args])\n}\n\nexport const trackEvent = (...event: MatomoEventType): void => {\n callMatomo('trackEvent', ...event)\n}\n\nexport const trackVisibleContentImpressions = (checkOnScroll = true, timeIntervalInMs = 750): void => {\n callMatomo('trackVisibleContentImpressions', checkOnScroll, timeIntervalInMs)\n}\n\nexport const getDomain = () => {\n return location.hostname.split('.').slice(-2).join('.')\n}\n","export type MatomoEventType = [category: string, action: string, name: string]\n","import { MatomoEventType } from './type'\nimport { callMatomo } from './utils'\n\nexport const wrapWithEventTrack = <A extends unknown[], R>(event: MatomoEventType | void, fn: (...args: A) => R) =>\n event\n ? (...args: A): R => {\n callMatomo('trackEvent', ...event)\n return fn?.(...args)\n }\n : fn\n"],"names":[],"version":3,"file":"index.cjs.map"}
|
package/dist/index.mjs
CHANGED
|
@@ -88,7 +88,7 @@ const $76adf94c93f4a7f4$var$injectMatomoScript = (matomoHost)=>{
|
|
|
88
88
|
* For other options see https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity#tools_for_generating_sri_hashes
|
|
89
89
|
*/ integrity: [
|
|
90
90
|
"sha384-cT0Nk8wS/smX3tvm0JOiaJhNeO5DbtYoG0ReQ6VlEE5EPNjmbcuZa1NwGwg14Hqa",
|
|
91
|
-
"sha384-
|
|
91
|
+
"sha384-iu/OZ4/Rk57hZYRyQrM5W4VNMMHSRB5Wg/s2g4zAVSSXZu3UfuhTz7E/sAlLhQkz"
|
|
92
92
|
].join(" ")
|
|
93
93
|
}));
|
|
94
94
|
};
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;AEGO,MAAM,4CAA2B;AACjC,MAAM,4CAA0B;AAChC,MAAM,2CAAmB;AAEzB,MAAM,4CAAsB;IACjC;IACA;CACD;AAEM,MAAM,4CAAkB;IAC7B,OAAO,OAAO,WAAW,eAAe,OAAO,SAAS;AAC1D;AAEA,MAAM,uDAAiC,CAAC;IACtC,MAAM,eAAe;IAErB,IAAI,OAAO,WAAW,aACpB,OAAO;IAGT,MAAM,gBAAgB,IAAI,OAAO,CAAC,KAAK,EAAE,IAAI,QAAQ,CAAC;IACtD,OAAO,AAAC,SAAS,OAAO,MAAM,gBAAgB,CAAC,EAAE,IAAe;AAClE;AAEO,MAAM,4CAAa,CAAC,WAAmB,GAAG;IAC/C,IAAI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ClB;YAAC;YAAc;gBAAC,CAAC,EAAE,EAAE,CAAA,GAAA,wCAAQ,IAAI,CAAC;aAAC;SAAC;QACpC;YAAC;YAA4B;SAAK;KACnC;IAED,0BAA0B;IAC1B,MAAM,SAAS,IAAI;IACnB,KAAK,MAAM,CAAC,KAAK,MAAM,IAAI,UACzB,IAAI,CAAC,OAAO,IAAI,MACd,OAAO,IAAI,KAAK;IAIpB,QAAQ,MAAM,QACT,MAAM,KAAK,OAAO,WAClB,IAAI,CAAC,CAAC,KAAK,MAAM;QAChB,OAAQ;YACN,KAAK;gBACH,OAAO;YACT,KAAK;YACL,KAAK;gBACH,OAAO;oBAAC;iBAAI;YACd;gBACE,OAAO;oBAAC;oBAAK;iBAAM;QACvB;IACF,GACC,OAAO,CAAC,OAAyC,SAAS;IAG/D,yCAAmB;AACrB;;;;;;;;;;AG/GO,MAAM,4CAAqB,CAAyB,OAA+B,KACxF,QACI,CAAC,GAAG;QACF,CAAA,GAAA,yCAAS,EAAE,iBAAiB;QAC5B,OAAO,QAAQ;IACjB,IACA;;;;AJFN,mBAAmB;AACnB,CAAA,GAAA,yCAAS","sources":["packages/analytics/matomo/src/index.ts","packages/analytics/matomo/src/init.ts","packages/analytics/matomo/src/utils.ts","packages/analytics/matomo/src/type.ts","packages/analytics/matomo/src/decoratorts.ts"],"sourcesContent":["import { initMatomo } from './init'\n\nexport * from './type'\nexport * from './decoratorts'\nexport * from './utils'\nexport * from './init'\n\n// Run after import\ninitMatomo()\n","import { getDomain } from './utils'\n\ndeclare global {\n interface Window {\n _paq?: undefined | [string, ...unknown[]][]\n __env__: { matomoHost: string } & Record<string | number | symbol, unknown>\n }\n}\n\nconst injectMatomoScript = (matomoHost: string) => {\n /**\n * # How to update matomo\n *\n * To safely update Matomo without analytics downtime:\n *\n * 1. Download the new Matomo version zip from https://github.com/matomo-org/matomo/releases\n * 2. Extract matomo.js from the zip archive\n * 3. Generate integrity checksum:\n * - Run: `cat matomo.js | openssl dgst -sha384 -binary | openssl base64 -A`\n * - Add 'sha384-' prefix to the generated hash\n * 4. Add the new integrity hash to the array below (keep the old one)\n * 5. Release this package and update all dependent repositories\n *\n * Notes:\n * - The script will automatically use the matching integrity hash\n * - Old integrity values can be safely removed later if desired\n * - No console errors will occur during the transition\n * - This approach ensures zero analytics downtime during updates\n */\n document.documentElement.appendChild(\n Object.assign(document.createElement('script'), {\n async: true,\n src: new URL('/matomo.js', matomoHost).href,\n crossOrigin: 'anonymous',\n /**\n * To generate checksum:\n * 1. Download matomo.js via `curl -O https://matomo.lido.fi/matomo.js`\n * 2. Calculate checkusm via `cat matomo.js | openssl dgst -sha384 -binary | openssl base64 -A`\n * 3. Add sha384 prefix\n * For other options see https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity#tools_for_generating_sri_hashes\n */\n integrity: [\n 'sha384-cT0Nk8wS/smX3tvm0JOiaJhNeO5DbtYoG0ReQ6VlEE5EPNjmbcuZa1NwGwg14Hqa', // Matomo v 5.2.0 && Matomo v 5.2.2 without cookies (cookie-less analytics) deprecate later\n 'sha384-
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;AEGO,MAAM,4CAA2B;AACjC,MAAM,4CAA0B;AAChC,MAAM,2CAAmB;AAEzB,MAAM,4CAAsB;IACjC;IACA;CACD;AAEM,MAAM,4CAAkB;IAC7B,OAAO,OAAO,WAAW,eAAe,OAAO,SAAS;AAC1D;AAEA,MAAM,uDAAiC,CAAC;IACtC,MAAM,eAAe;IAErB,IAAI,OAAO,WAAW,aACpB,OAAO;IAGT,MAAM,gBAAgB,IAAI,OAAO,CAAC,KAAK,EAAE,IAAI,QAAQ,CAAC;IACtD,OAAO,AAAC,SAAS,OAAO,MAAM,gBAAgB,CAAC,EAAE,IAAe;AAClE;AAEO,MAAM,4CAAa,CAAC,WAAmB,GAAG;IAC/C,IAAI,CAAC,6CACH,CAAA,GAAA,yCAAS;IAGX,IAAI,OAAO,WAAW,aACpB;IAGF,MAAM,uBAAuB,qDAA+B,6C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AC;YAA4B;SAAK;KACnC;IAED,0BAA0B;IAC1B,MAAM,SAAS,IAAI;IACnB,KAAK,MAAM,CAAC,KAAK,MAAM,IAAI,UACzB,IAAI,CAAC,OAAO,IAAI,MACd,OAAO,IAAI,KAAK;IAIpB,QAAQ,MAAM,QACT,MAAM,KAAK,OAAO,WAClB,IAAI,CAAC,CAAC,KAAK,MAAM;QAChB,OAAQ;YACN,KAAK;gBACH,OAAO;YACT,KAAK;YACL,KAAK;gBACH,OAAO;oBAAC;iBAAI;YACd;gBACE,OAAO;oBAAC;oBAAK;iBAAM;QACvB;IACF,GACC,OAAO,CAAC,OAAyC,SAAS;IAG/D,yCAAmB;AACrB;;;;;;;;;;AG/GO,MAAM,4CAAqB,CAAyB,OAA+B,KACxF,QACI,CAAC,GAAG;QACF,CAAA,GAAA,yCAAS,EAAE,iBAAiB;QAC5B,OAAO,QAAQ;IACjB,IACA;;;;AJFN,mBAAmB;AACnB,CAAA,GAAA,yCAAS","sources":["packages/analytics/matomo/src/index.ts","packages/analytics/matomo/src/init.ts","packages/analytics/matomo/src/utils.ts","packages/analytics/matomo/src/type.ts","packages/analytics/matomo/src/decoratorts.ts"],"sourcesContent":["import { initMatomo } from './init'\n\nexport * from './type'\nexport * from './decoratorts'\nexport * from './utils'\nexport * from './init'\n\n// Run after import\ninitMatomo()\n","import { getDomain } from './utils'\n\ndeclare global {\n interface Window {\n _paq?: undefined | [string, ...unknown[]][]\n __env__: { matomoHost: string } & Record<string | number | symbol, unknown>\n }\n}\n\nconst injectMatomoScript = (matomoHost: string) => {\n /**\n * # How to update matomo\n *\n * To safely update Matomo without analytics downtime:\n *\n * 1. Download the new Matomo version zip from https://github.com/matomo-org/matomo/releases\n * 2. Extract matomo.js from the zip archive\n * 3. Generate integrity checksum:\n * - Run: `cat matomo.js | openssl dgst -sha384 -binary | openssl base64 -A`\n * - Add 'sha384-' prefix to the generated hash\n * 4. Add the new integrity hash to the array below (keep the old one)\n * 5. Release this package and update all dependent repositories\n *\n * Notes:\n * - The script will automatically use the matching integrity hash\n * - Old integrity values can be safely removed later if desired\n * - No console errors will occur during the transition\n * - This approach ensures zero analytics downtime during updates\n */\n document.documentElement.appendChild(\n Object.assign(document.createElement('script'), {\n async: true,\n src: new URL('/matomo.js', matomoHost).href,\n crossOrigin: 'anonymous',\n /**\n * To generate checksum:\n * 1. Download matomo.js via `curl -O https://matomo.lido.fi/matomo.js`\n * 2. Calculate checkusm via `cat matomo.js | openssl dgst -sha384 -binary | openssl base64 -A`\n * 3. Add sha384 prefix\n * For other options see https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity#tools_for_generating_sri_hashes\n */\n integrity: [\n 'sha384-cT0Nk8wS/smX3tvm0JOiaJhNeO5DbtYoG0ReQ6VlEE5EPNjmbcuZa1NwGwg14Hqa', // Matomo v 5.2.0 && Matomo v 5.2.2 without cookies (cookie-less analytics) deprecate later\n 'sha384-iu/OZ4/Rk57hZYRyQrM5W4VNMMHSRB5Wg/s2g4zAVSSXZu3UfuhTz7E/sAlLhQkz', // Matomo v 5.2.2 && Matomo v 5.8.0\n ].join(' '),\n }),\n )\n}\n\nexport type MatomoConfig = Array<[string, ...unknown[]]>\n\nexport const initMatomo = (matomoHost?: string, customConfig: MatomoConfig = []): void => {\n if (typeof window === 'undefined') {\n // SSR not supported!\n return\n }\n\n const _matomoHost = matomoHost || window?.__env__?.matomoHost || undefined\n\n if (!_matomoHost) {\n // Where Do I send analytics?\n return\n }\n\n if (window._paq) {\n // window._paq has been initialized\n return\n }\n\n window._paq ??= []\n\n const rawConfig = [\n // These are hardcoded values and cannot be changed\n ['setTrackerUrl', new URL('/matomo.php', _matomoHost).href],\n ['requireCookieConsent', true],\n // Add subdomain prefix to page titles to separate analytics by subdomain\n ['setDocumentTitle', window.location.hostname + '/' + (document.title || '')],\n\n // These are custom settings\n ...customConfig,\n\n // These are default settings, will be overwritten if custom set\n ['trackPageView', true],\n ['enableLinkTracking', true],\n ['setSiteId', '1'],\n ['setDomains', [`*.${getDomain()}`]],\n ['enableCrossDomainLinking', true],\n ]\n\n // Map keeps order of keys\n const config = new Map()\n for (const [key, value] of rawConfig) {\n if (!config.has(key)) {\n config.set(key, value)\n }\n }\n\n window?._paq?.push(\n ...Array.from(config.entries())\n .map(([key, value]) => {\n switch (value) {\n case false:\n return false\n case true:\n case undefined:\n return [key]\n default:\n return [key, value]\n }\n })\n .filter((item): item is [string, ...unknown[]] => item !== false),\n )\n\n injectMatomoScript(_matomoHost)\n}\n","import { initMatomo } from './init'\nimport { MatomoEventType } from './type'\n\nexport const COOKIE_ALLOWED_VALUE_YES = 'yes'\nexport const COOKIE_ALLOWED_MAIN_KEY = 'cookie-allowed'\nexport const META_INFO_COOKIE = 'meta-info'\n\nexport const COOKIE_ALLOWED_KEYS = [\n 'LIDO_WIDGET__COOKIES_ALLOWED', // will be deprecated soon\n COOKIE_ALLOWED_MAIN_KEY,\n]\n\nexport const matomoAvailable = (): boolean => {\n return typeof window !== 'undefined' && window._paq !== undefined\n}\n\nconst getCrossDomainCookieClientSide = (key: string): string | null => {\n const defaultValue = null\n\n if (typeof window === 'undefined') {\n return defaultValue\n }\n\n const cookieMatcher = new RegExp(`(^| )${key}=([^;]+)`)\n return (document.cookie.match(cookieMatcher)?.[2] as string) ?? defaultValue\n}\n\nexport const callMatomo = (apiMethod: string, ...args: unknown[]): void => {\n if (!matomoAvailable()) {\n initMatomo()\n }\n\n if (typeof window === 'undefined') {\n return\n }\n\n const customDimensionValue = getCrossDomainCookieClientSide(META_INFO_COOKIE) || 'none'\n window?._paq?.push(['setCustomDimension', 1, customDimensionValue])\n\n window?._paq?.push([apiMethod, ...args])\n}\n\nexport const trackEvent = (...event: MatomoEventType): void => {\n callMatomo('trackEvent', ...event)\n}\n\nexport const trackVisibleContentImpressions = (checkOnScroll = true, timeIntervalInMs = 750): void => {\n callMatomo('trackVisibleContentImpressions', checkOnScroll, timeIntervalInMs)\n}\n\nexport const getDomain = () => {\n return location.hostname.split('.').slice(-2).join('.')\n}\n","export type MatomoEventType = [category: string, action: string, name: string]\n","import { MatomoEventType } from './type'\nimport { callMatomo } from './utils'\n\nexport const wrapWithEventTrack = <A extends unknown[], R>(event: MatomoEventType | void, fn: (...args: A) => R) =>\n event\n ? (...args: A): R => {\n callMatomo('trackEvent', ...event)\n return fn?.(...args)\n }\n : fn\n"],"names":[],"version":3,"file":"index.mjs.map"}
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"url": "https://github.com/lidofinance/warehouse/issues"
|
|
8
8
|
},
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"version": "0.
|
|
10
|
+
"version": "0.58.0",
|
|
11
11
|
"files": [
|
|
12
12
|
"dist"
|
|
13
13
|
],
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"test": "jest"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@lidofinance/config-prettier": "~0.
|
|
36
|
+
"@lidofinance/config-prettier": "~0.58.0",
|
|
37
37
|
"@types/jest": "^29.2.4",
|
|
38
38
|
"jest": "^29.3.1",
|
|
39
39
|
"jest-environment-jsdom": "^28.0.0",
|