Skip to content

Commit a406a17

Browse files
GOOD BYE GOOGLE TAG MANAGER I HATED YOU
1 parent eae80e1 commit a406a17

7 files changed

Lines changed: 26 additions & 19 deletions

File tree

.env.sample

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
// Enable analytics during development - for debugging purposes
2+
// Analytics are always enabled in non-dev environments
3+
NEXT_PUBLIC_ENABLE_ANALYTICS=false
4+
// Enables ads during development - for debugging purposes
5+
// Ads are always enabled in non-dev environments
6+
NEXT_PUBLIC_ENABLE_ADS=false
7+
18
// Google Analytics measurement ID - not required
29
NEXT_PUBLIC_GA_MEASUREMENT_ID = "G-XXXXXXXXXX"
3-
// Google Tag Manager ID - not required
4-
NEXT_PUBLIC_GTM_ID = "GTM-XXXXXXXX"
510
// Google Adsense publisher ID - not required
611
NEXT_PUBLIC_ADSENSE_PUBLISHER_ID = "pub-XXXXXXXXXXXXXXXX"
712
// GitHub OAuth

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
"dependencies": {
5353
"@codemirror/language": "6.0.0",
5454
"@growthbook/growthbook-react": "^1.1.0",
55-
"@magicul/next-google-tag-manager": "^2.0.0",
5655
"@popperjs/core": "2.11.8",
5756
"@tippyjs/react": "^4.2.6",
5857
"@types/bootstrap": "^5.2.10",

src/components/Adsense/adsense.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ import { getEnvironment } from "@/scripts/Utils/Environment";
55
export function Adsense(): React.ReactNode {
66
React.useEffect(() => {
77
if (getEnvironment() === "development") {
8-
console.info("Google Adsense disabled during development");
8+
if (process.env.NEXT_PUBLIC_ENABLE_ADS) {
9+
console.info("Enabling Google Adsense during development");
10+
} else {
11+
console.info("Google Adsense disabled during development");
12+
return;
13+
}
914
}
1015
}, []);
1116

src/components/Analytics/analytics.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,22 @@ export function Analytics(): React.ReactNode {
6868
});
6969

7070
if (getEnvironment() === "development") {
71-
console.info("Google Analytics disabled during development");
72-
return;
71+
if (process.env.NEXT_PUBLIC_ENABLE_ANALYTICS) {
72+
console.info("Enabling Google Analytics during development");
73+
} else {
74+
console.info("Google Analytics disabled during development");
75+
return;
76+
}
7377
}
7478

7579
setUseGA(true);
7680
}, []);
7781

78-
return useGA ? <GoogleAnalytics trackPageViews /> : <></>;
82+
return useGA ? (
83+
<GoogleAnalytics trackPageViews={{ ignoreHashChange: true }} />
84+
) : (
85+
<></>
86+
);
7987
}
8088

8189
export default Analytics;

src/components/Navbar/ThemePicker/themePicker.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,10 @@ export function ThemeProxy({
158158

159159
React.useEffect(() => {
160160
if (loadedPreferredTheme) {
161+
const osWantsDark = window.matchMedia("(prefers-color-scheme: dark)");
161162
switch (dropdownTheme) {
162163
case "Auto": {
163-
setActualTheme(
164-
window.matchMedia("(prefers-color-scheme: dark)").matches
165-
? "Dark"
166-
: "Light",
167-
);
164+
setActualTheme(osWantsDark ? "Dark" : "Light");
168165
break;
169166
}
170167
default: {

src/pages/_app.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import "katex/dist/katex.min.css";
77
import "tippy.js/dist/tippy.css";
88
import Adsense from "../components/Adsense";
99
import Analytics from "../components/Analytics";
10-
import GoogleTagManager from "@magicul/next-google-tag-manager";
1110
import ErrorBoundary from "../components/ErrorBoundary";
1211
import { SessionProvider } from "next-auth/react";
1312
import { useRouter } from "next/router";
@@ -115,7 +114,6 @@ export default function AwesomeArcadeExtensions({
115114
options={{ showSpinner: false }}
116115
/>
117116
<Analytics />
118-
<GoogleTagManager id={process.env.NEXT_PUBLIC_GTM_ID!} />
119117
<Adsense />
120118
<GrowthBookProvider growthbook={growthbook}>
121119
<SessionProvider session={session}>

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,11 +1113,6 @@
11131113
dependencies:
11141114
"@lezer/common" "^1.0.0"
11151115

1116-
"@magicul/next-google-tag-manager@^2.0.0":
1117-
version "2.0.0"
1118-
resolved "https://registry.yarnpkg.com/@magicul/next-google-tag-manager/-/next-google-tag-manager-2.0.0.tgz#04a77b506a4385f84cf637267984bd6f334f5ce0"
1119-
integrity sha512-NXp0iGxdcAZL9IkkWwh2GS3dE1qSn4hGxXADnvt1li4gAXyxJ9AEDTrgqMVXIDzkGTD7Q0n37BJoCZdmwIXE+g==
1120-
11211116
"@monaco-editor/loader@^1.3.2":
11221117
version "1.4.0"
11231118
resolved "https://registry.yarnpkg.com/@monaco-editor/loader/-/loader-1.4.0.tgz#f08227057331ec890fa1e903912a5b711a2ad558"

0 commit comments

Comments
 (0)