Skip to content

Commit

Permalink
Disable analytics in dev and via a manual env var setting
Browse files Browse the repository at this point in the history
  • Loading branch information
tyom committed Oct 4, 2023
1 parent dc8e7a7 commit 30e33c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
PUBLIC_GA_MEASUREMENT_ID=G-XXXXXXXXXX
PUBLIC_DISABLE_ANALYTICS=0
10 changes: 9 additions & 1 deletion src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<script>
import { dev } from '$app/environment';
import { PUBLIC_DISABLE_ANALYTICS } from '$env/static/public';
import Analytics from '$components/Analytics.svelte';
import '../global.css';
const enableAnalytics =
!dev && !['true', '1'].includes(PUBLIC_DISABLE_ANALYTICS);
</script>

<Analytics />
{#if enableAnalytics}
<Analytics />
{/if}

<slot />

0 comments on commit 30e33c6

Please sign in to comment.