📈 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
Locale / language tracking
Blue Mouse8f8b45194931
diff --git a/web/app/components/Header/index.tsx b/web/app/components/Header/index.tsxindex fe6f321a1..194a6e010 100644--- a/web/app/components/Header/index.tsx+++ b/web/app/components/Header/index.tsx@@ -20,7 +20,7 @@ import dayjs from 'dayjs'import duration from 'dayjs/plugin/duration'import utc from 'dayjs/plugin/utc'import { type t as i18nextT } from 'i18next'-import { changeLanguage } from 'i18next'+import { changeLanguage as changeLanguageI18n } from 'i18next'import _map from 'lodash/map'import _startsWith from 'lodash/startsWith'import { GaugeIcon, ChartPieIcon, BugIcon, PuzzleIcon, PhoneIcon } from 'lucide-react'@@ -42,6 +42,7 @@ import { useTheme } from '~/providers/ThemeProvider'import Dropdown from '~/ui/Dropdown'import Flag from '~/ui/Flag'import SwetrixLogo from '~/ui/icons/SwetrixLogo'+import { trackCustom } from '~/utils/analytics'import routes from '~/utils/routes'dayjs.extend(utc)@@ -83,6 +84,11 @@ const getSolutions = (t: typeof i18nextT) => [},]+const changeLanguage = (language: string) => {+ changeLanguageI18n(language)+ trackCustom('CHANGE_LANGUAGE', { language })+}+const getCallsToAction = (t: typeof i18nextT) => [{ name: t('header.watchDemo'), link: 'https://www.youtube.com/watch?v=XBp38fZREIE', icon: SiYoutube },{ name: t('header.contactSales'), link: routes.contact, icon: PhoneIcon },diff --git a/web/app/root.tsx b/web/app/root.tsxindex 7f412e617..b3d470729 100644--- a/web/app/root.tsx+++ b/web/app/root.tsx@@ -185,6 +185,7 @@ export async function loader({ request }: LoaderFunctionArgs) {DISABLE_MARKETING_PAGES: process.env.DISABLE_MARKETING_PAGES,STAGING: process.env.STAGING,PADDLE_CLIENT_SIDE_TOKEN: process.env.PADDLE_CLIENT_SIDE_TOKEN,+ LOCALE: locale,}return { locale, url, theme, REMIX_ENV, isAuthed, pathname: urlObject.pathname }diff --git a/web/app/utils/analytics.ts b/web/app/utils/analytics.tsindex 69ba6357a..94bd760c2 100644--- a/web/app/utils/analytics.ts+++ b/web/app/utils/analytics.ts@@ -1,7 +1,7 @@import _includes from 'lodash/includes'import * as Swetrix from 'swetrix'-import { isDevelopment, isSelfhosted } from '~/lib/constants'+import { isBrowser, isDevelopment, isSelfhosted } from '~/lib/constants'const SWETRIX_PID = 'STEzHcB1rALV'@@ -108,16 +108,21 @@ Swetrix.init(SWETRIX_PID, {const BLOG_PAGE_REGEX = /^\/blog\/.+$/export const trackViews = () => {- if (isSelfhosted) {+ if (isSelfhosted || !isBrowser) {return}Swetrix.trackViews({callback: ({ pg, ref }) => {+ const locale = window?.REMIX_ENV?.LOCALE || 'N/A'+const result = {pg,ref,- }+ meta: {+ locale,+ },+ } as Swetrix.IPageViewPayloadif (pg && BLOG_PAGE_REGEX.test(pg)) {return false@@ -144,7 +149,7 @@ export const trackPageview = (options: Swetrix.IPageviewOptions) => {}export const trackErrors = () => {- if (isSelfhosted) {+ if (isSelfhosted || !isBrowser) {return}@@ -162,7 +167,7 @@ export const trackErrors = () => {}export const trackCustom = (ev: string, meta?: Swetrix.TrackEventOptions['meta']) => {- if (isSelfhosted) {+ if (isSelfhosted || !isBrowser) {return}