Skip to content

Commit 7cb2cef

Browse files
committed
Move initAnalyticsIfEnabled back into +layout.svelte
We want `initDependencies` to be free of side-effects, and only bootstrap deps.
1 parent 8cdf3de commit 7cb2cef

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

apps/desktop/src/lib/bootstrap/deps.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
PROMPT_SERVICE as AI_PROMPT_SERVICE
55
} from '$lib/ai/promptService';
66
import { AIService, AI_SERVICE } from '$lib/ai/service';
7-
import { initAnalyticsIfEnabled } from '$lib/analytics/analytics';
87
import { EVENT_CONTEXT, EventContext } from '$lib/analytics/eventContext';
98
import { POSTHOG_WRAPPER, PostHogWrapper } from '$lib/analytics/posthog';
109
import { type IBackend } from '$lib/backend';
@@ -107,7 +106,6 @@ export function initDependencies(args: {
107106

108107
const eventContext = new EventContext();
109108
const posthog = new PostHogWrapper(settingsService, backend, eventContext);
110-
initAnalyticsIfEnabled(appSettings, posthog);
111109

112110
// ============================================================================
113111
// AUTHENTICATION & SECURITY

apps/desktop/src/routes/+layout.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
import SwitchThemeMenuAction from '$components/SwitchThemeMenuAction.svelte';
1414
import ToastController from '$components/ToastController.svelte';
1515
import ZoomInOutMenuAction from '$components/ZoomInOutMenuAction.svelte';
16+
import { initAnalyticsIfEnabled } from '$lib/analytics/analytics';
1617
import { POSTHOG_WRAPPER } from '$lib/analytics/posthog';
1718
import { initDependencies } from '$lib/bootstrap/deps';
19+
import { APP_SETTINGS } from '$lib/config/appSettings';
1820
import { SETTINGS_SERVICE } from '$lib/config/appSettingsV2';
1921
import { ircEnabled, ircServer } from '$lib/config/uiFeatureFlags';
2022
import { GITHUB_CLIENT } from '$lib/forge/github/githubClient';
@@ -45,7 +47,11 @@
4547
initDependencies(data);
4648
4749
const clientState = inject(CLIENT_STATE);
50+
const appSettings = inject(APP_SETTINGS);
51+
const posthog = inject(POSTHOG_WRAPPER);
52+
4853
clientState.initPersist();
54+
initAnalyticsIfEnabled(appSettings, posthog);
4955
5056
// =============================================================================
5157
// CORE REACTIVE STATE & EFFECTS
@@ -79,8 +85,6 @@
7985
// ANALYTICS & NAVIGATION
8086
// =============================================================================
8187
82-
// Analytics for single page app navigation
83-
const posthog = inject(POSTHOG_WRAPPER);
8488
if (browser) {
8589
beforeNavigate(() => posthog.capture('$pageleave'));
8690
afterNavigate(() => posthog.capture('$pageview'));

0 commit comments

Comments
 (0)