Skip to content

Commit

Permalink
Actually not enable Adsense or Analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
UnsignedArduino committed Jul 13, 2024
1 parent 12f32d1 commit 836f5e3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 7 additions & 6 deletions src/components/Adsense/adsense.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@ export function Adsense(): React.ReactNode {
const [useGA, setUseGA] = React.useState<boolean>(false);

React.useEffect(() => {
if (
process.env.NEXT_PUBLIC_ADSENSE_PUBLISHER_ID === "pub-XXXXXXXXXXXXXXXX" ||
!process.env.NEXT_PUBLIC_ADSENSE_PUBLISHER_ID
) {
// console.info("No publisher ID provided, disabling Google Adsense");
return;
}
if (getEnvironment() === "development") {
if (process.env.NEXT_PUBLIC_ENABLE_ADS) {
console.info("Enabling Google Adsense during development");
} else {
console.info("Google Adsense disabled during development");
return;
}
} else if (
process.env.NEXT_PUBLIC_ADSENSE_PUBLISHER_ID === "pub-XXXXXXXXXXXXXXXX" ||
!process.env.NEXT_PUBLIC_ADSENSE_PUBLISHER_ID
) {
// console.info("No publisher ID provided, disabling Google Adsense");
return;
}

setUseGA(true);
Expand Down
13 changes: 7 additions & 6 deletions src/components/Analytics/analytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,20 @@ export function Analytics(): React.ReactNode {
analytics_storage: getAnalyticsStorageConsent(),
});

if (
process.env.NEXT_PUBLIC_GA_MEASUREMENT_ID === "G-XXXXXXXXXX" ||
!process.env.NEXT_PUBLIC_GA_MEASUREMENT_ID
) {
console.info("No measurement ID provided, disabling Google Analytics");
return;
}
if (getEnvironment() === "development") {
if (process.env.NEXT_PUBLIC_ENABLE_ANALYTICS) {
console.info("Enabling Google Analytics during development");
} else {
console.info("Google Analytics disabled during development");
return;
}
} else if (
process.env.NEXT_PUBLIC_GA_MEASUREMENT_ID === "G-XXXXXXXXXX" ||
!process.env.NEXT_PUBLIC_GA_MEASUREMENT_ID
) {
console.info("No measurement ID provided, disabling Google Analytics");
return;
}

setUseGA(true);
Expand Down

0 comments on commit 836f5e3

Please sign in to comment.