File tree Expand file tree Collapse file tree 5 files changed +22
-11
lines changed
Expand file tree Collapse file tree 5 files changed +22
-11
lines changed Original file line number Diff line number Diff line change 4444 " ntfy" ,
4545 " obtainium" ,
4646 " posthog" ,
47+ " prefs" ,
4748 " reconsent" ,
4849 " SIEM" ,
4950 " SPDY" ,
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ SPDX-License-Identifier: CC-BY-4.0 OR GPL-3.0-or-later
1111 * @module src/lib/stores
1212 */
1313
14- import { afterNavigate } from "$app/navigation" ;
1514import {
1615 shouldRemindUserToReconsent ,
1716 shouldTrackUser ,
@@ -76,12 +75,6 @@ export async function initPostHog() {
7675 } ) ;
7776
7877 ph . capture ( "$pageview" ) ;
79-
80- afterNavigate ( ( ) => {
81- if ( ph !== null && get ( trackingEnabled ) ) {
82- ph . capture ( "$pageview" ) ;
83- }
84- } ) ;
8578}
8679
8780/**
Original file line number Diff line number Diff line change @@ -14,4 +14,17 @@ SPDX-License-Identifier: CC-BY-4.0 OR GPL-3.0-or-later
1414
1515import { writable } from "svelte/store" ;
1616
17- export const trackingStatus = writable ( "unknown" ) ;
17+ /**
18+ * Writable tracking status store.
19+ * Initialized with fallback value and updated in browser context.
20+ * @type {import("svelte/store").Writable<string> }
21+ */
22+ export const trackingStatus = writable ( "⏳ Checking tracking preferences..." ) ;
23+
24+ // Dynamically import browser-only logic after mount
25+ if ( typeof window !== "undefined" ) {
26+ import ( "$lib/utils/trackingStatus.js" ) . then ( ( { getTrackingPreferences } ) => {
27+ const prefs = getTrackingPreferences ( ) ;
28+ trackingStatus . set ( prefs . status ) ;
29+ } ) ;
30+ }
Original file line number Diff line number Diff line change @@ -42,5 +42,3 @@ export function load({ url }) {
4242 meta : currentMeta , // Return the meta data (either from the route or the fallback)
4343 } ;
4444}
45-
46- // cspell:ignore posthog
Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ This file is part of Network Pro.
1010 export let data;
1111
1212 import { onMount } from " svelte" ;
13- import { initPostHog , showReminder } from " $lib/stores/posthog" ;
13+ import { afterNavigate } from " $app/navigation" ;
14+ import { initPostHog , showReminder , capture } from " $lib/stores/posthog" ;
1415 import { registerServiceWorker } from " $lib/registerServiceWorker.js" ;
1516 import { browser } from " $app/environment" ;
1617 import { shouldTrackUser } from " $lib/utils/privacy.js" ;
@@ -37,6 +38,11 @@ This file is part of Network Pro.
3738 registerServiceWorker ();
3839 initPostHog ();
3940
41+ // Register navigation tracking only on client
42+ afterNavigate (() => {
43+ capture (" $pageview" );
44+ });
45+
4046 if (browser) {
4147 const isDev = import .meta.env.MODE === " development" ;
4248
You can’t perform that action at this time.
0 commit comments