File tree Expand file tree Collapse file tree 5 files changed +48
-21
lines changed Expand file tree Collapse file tree 5 files changed +48
-21
lines changed Original file line number Diff line number Diff line change 1717 "@sveltejs/kit" : " ^2.0.0" ,
1818 "@sveltejs/vite-plugin-svelte" : " ^4.0.4" ,
1919 "@tsconfig/svelte" : " ^5.0.4" ,
20+ "@types/gtag.js" : " ^0.0.20" ,
2021 "@types/topojson-client" : " ^3.1.5" ,
2122 "@typescript-eslint/parser" : " ^8.18.2" ,
2223 "autoprefixer" : " ^10.4.20" ,
4546 "maplibre-gl" : " ^4.7.1" ,
4647 "polygon-lookup" : " ^2.6.0" ,
4748 "svelte-i18n" : " ^4.0.1" ,
48- "svelte-use-click-outside" : " ^1.0.0" ,
49- "vite-plugin-radar" : " ^0.9.6"
49+ "svelte-use-click-outside" : " ^1.0.0"
5050 }
5151}
Original file line number Diff line number Diff line change 1+ <script lang =" ts" >
2+ import { page } from ' $app/stores'
3+
4+ const GA_ID = import .meta .env .VITE_GOOGLE_ANALYTICS_ID
5+
6+ $ : {
7+ if (typeof gtag !== ' undefined' ) {
8+ gtag (' config' , GA_ID , {
9+ page_title: document .title ,
10+ page_path: $page .url .pathname ,
11+ })
12+ }
13+ }
14+ </script >
15+
16+ <svelte:head >
17+ <script
18+ async
19+ src ={` https://www.googletagmanager.com/gtag/js?id=${GA_ID } ` }>
20+ </script >
21+ <script >
22+ window .dataLayer = window .dataLayer || []
23+
24+ function gtag () {
25+ dataLayer .push (arguments )
26+ }
27+
28+ gtag (' js' , new Date ())
29+ gtag (' config' , GA_ID )
30+ </script >
31+ </svelte:head >
Original file line number Diff line number Diff line change 11<script lang =" ts" >
22 import ' ../app.css' ;
33 import ' maplibre-gl/dist/maplibre-gl.css' ;
4+ import Analytics from ' ../components/Analytics.svelte' ;
45 import SEO from ' ../components/SEO.svelte' ;
6+
7+ const hasAnalytics = Boolean (import .meta .env [' VITE_GOOGLE_ANALYTICS_ID' ]);
58 </script >
69
10+ {#if hasAnalytics }
11+ <Analytics />
12+ {/if }
713<SEO />
814<slot />
Original file line number Diff line number Diff line change 11import { sveltekit } from '@sveltejs/kit/vite' ;
22import { defineConfig , loadEnv } from 'vite' ;
3- import radar from 'vite-plugin-radar' ;
43import postcss from './postcss.config.js' ;
54
65export default ( { mode } ) => {
@@ -9,12 +8,7 @@ export default ({ mode }) => {
98 return defineConfig ( {
109 css : { postcss } ,
1110 plugins : [
12- sveltekit ( ) ,
13- radar ( {
14- analytics : {
15- id : process . env . VITE_GOOGLE_ANALYTICS_ID
16- }
17- } )
11+ sveltekit ( )
1812 ]
1913 } ) ;
2014} ;
You can’t perform that action at this time.
0 commit comments