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 8961979
Show file tree
Hide file tree
Showing 4 changed files with 15 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
1 change: 1 addition & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:

env:
FORCE_COLOR: 3
PUBLIC_DISABLE_ANALYTICS: ''

jobs:
build:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
branches:
- master

env:
FORCE_COLOR: 3
PUBLIC_DISABLE_ANALYTICS: ''

jobs:
deploy:
name: build and deploys
Expand Down
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 8961979

Please sign in to comment.