📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
upgraded swetrix.js to v3
Blue Mouse9e1819b486cd
diff --git a/app/utils/analytics.ts b/app/utils/analytics.tsindex d83a8fa7b..fb4ec9c22 100644--- a/app/utils/analytics.ts+++ b/app/utils/analytics.ts@@ -3,21 +3,54 @@ import { isSelfhosted } from 'redux/constants'const SWETRIX_PID = 'STEzHcB1rALV'-Swetrix.init(SWETRIX_PID)+const checkIgnore = (path: string | undefined | null, ignore: RegExp[]) => {+ if (!path) {+ return false+ }++ for (let i = 0; i < ignore.length; ++i) {+ if (ignore[i].test(path)) {+ return true+ }+ }++ return false+}++const pathsToIgnore = [+ /^\/projects\/(?!new$)[^/]+$/i,+ /^\/projects\/settings/i,+ /^\/verify/i,+ /^\/password-reset/i,+ /^\/change-email/i,+ /^\/share/i,+ /^\/captchas\/(?!new$)[^/]+$/i,+ /^\/captchas\/settings/i,+]++Swetrix.init(SWETRIX_PID, {+ devMode: true,+})const trackViews = () => {if (!isSelfhosted) {Swetrix.trackViews({- ignore: [- /^\/projects\/(?!new$)[^/]+$/i,- /^\/projects\/settings/i,- /^\/verify/i,- /^\/password-reset/i,- /^\/change-email/i,- /^\/share/i,- /^\/captchas\/(?!new$)[^/]+$/i,- /^\/captchas\/settings/i,- ],+ callback: ({ pg, prev }) => {+ const result = {+ pg,+ prev,+ }++ if (checkIgnore(pg, pathsToIgnore)) {+ result.pg = null+ }++ if (checkIgnore(prev, pathsToIgnore)) {+ result.prev = null+ }++ return result+ },heartbeatOnBackground: true,})}diff --git a/package.json b/package.jsonindex 9f381a871..b49cb3816 100644--- a/package.json+++ b/package.json@@ -71,7 +71,7 @@"remix-sitemap": "^2.2.7","remix-utils": "^6.6.0","spacetime": "^7.4.8",- "swetrix": "^3.0.0",+ "swetrix": "^3.0.3","timezone-soft": "^1.4.1","ts-jest": "^29.1.1"},