Skip to content

📈 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!

ignore some refs

Blue Mouse021a663f7cc7
diff --git a/app/utils/analytics.ts b/app/utils/analytics.ts
index fb4ec9c22..9ce774b3a 100644
--- a/app/utils/analytics.ts
+++ b/app/utils/analytics.ts
@@ -1,5 +1,5 @@
import * as Swetrix from 'swetrix'
-import { isSelfhosted } from 'redux/constants'
+import { isDevelopment, isSelfhosted } from 'redux/constants'
const SWETRIX_PID = 'STEzHcB1rALV'
@@ -28,17 +28,29 @@ const pathsToIgnore = [
/^\/captchas\/settings/i,
]
+const refsToIgnore = [
+ /https:\/\/swetrix.com\/projects\/(?!new$)[^/]+$/i,
+ /https:\/\/swetrix.com\/projects\/settings/i,
+ /https:\/\/swetrix.com\/verify/i,
+ /https:\/\/swetrix.com\/password-reset/i,
+ /https:\/\/swetrix.com\/change-email/i,
+ /https:\/\/swetrix.com\/share/i,
+ /https:\/\/swetrix.com\/captchas\/(?!new$)[^/]+$/i,
+ /https:\/\/swetrix.com\/captchas\/settings/i,
+]
+
Swetrix.init(SWETRIX_PID, {
- devMode: true,
+ devMode: isDevelopment,
})
const trackViews = () => {
if (!isSelfhosted) {
Swetrix.trackViews({
- callback: ({ pg, prev }) => {
+ callback: ({ pg, prev, ref }) => {
const result = {
pg,
prev,
+ ref,
}
if (checkIgnore(pg, pathsToIgnore)) {
@@ -49,6 +61,10 @@ const trackViews = () => {
result.prev = null
}
+ if (checkIgnore(ref, refsToIgnore)) {
+ result.ref = undefined
+ }
+
return result
},
heartbeatOnBackground: true,