From 0e72829dd76da6d99734d3ffb0e7c31fcdae05da Mon Sep 17 00:00:00 2001 From: qtchaos <72168435+qtchaos@users.noreply.github.com> Date: Mon, 26 Feb 2024 19:40:35 +0200 Subject: [PATCH] feat: make Google Analytics configurable with VITE_GA_ID --- src/setup/constants.ts | 2 +- src/setup/ga.ts | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/setup/constants.ts b/src/setup/constants.ts index def7c48f..a92cc880 100644 --- a/src/setup/constants.ts +++ b/src/setup/constants.ts @@ -2,5 +2,5 @@ export const APP_VERSION = import.meta.env.PACKAGE_VERSION; export const DISCORD_LINK = "https://discord.gg/gQYB6fGArX"; export const GITHUB_LINK = "https://github.com/movie-web/movie-web"; export const DONATION_LINK = "https://ko-fi.com/movieweb"; -export const GA_ID = "G-44YVXRL61C"; +export const GA_ID = import.meta.env.VITE_GA_ID; export const BACKEND_URL = import.meta.env.VITE_BACKEND_URL; diff --git a/src/setup/ga.ts b/src/setup/ga.ts index 1fbf488b..9b900c0d 100644 --- a/src/setup/ga.ts +++ b/src/setup/ga.ts @@ -2,8 +2,10 @@ import ReactGA from "react-ga4"; import { GA_ID } from "@/setup/constants"; -ReactGA.initialize([ - { - trackingId: GA_ID, - }, -]); +if (GA_ID) { + ReactGA.initialize([ + { + trackingId: GA_ID, + }, + ]); +}