-
Notifications
You must be signed in to change notification settings - Fork 530
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor appSettings to accommodate new Tauri v2 API
- creates AppSettings class and injects it where needed - avoids `window` undeclared variable during vite build process
- Loading branch information
Showing
8 changed files
with
110 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,22 @@ | ||
import { initPostHog } from '$lib/analytics/posthog'; | ||
import { initSentry } from '$lib/analytics/sentry'; | ||
import { appAnalyticsConfirmed } from '$lib/config/appSettings'; | ||
import { | ||
appMetricsEnabled, | ||
appErrorReportingEnabled, | ||
appNonAnonMetricsEnabled | ||
} from '$lib/config/appSettings'; | ||
import { AppSettings } from '$lib/config/appSettings'; | ||
import posthog from 'posthog-js'; | ||
|
||
export function initAnalyticsIfEnabled() { | ||
const analyticsConfirmed = appAnalyticsConfirmed(); | ||
analyticsConfirmed.onDisk().then((confirmed) => { | ||
export function initAnalyticsIfEnabled(appSettings: AppSettings) { | ||
appSettings.appAnalyticsConfirmed.onDisk().then((confirmed) => { | ||
if (confirmed) { | ||
appErrorReportingEnabled() | ||
.onDisk() | ||
.then((enabled) => { | ||
if (enabled) initSentry(); | ||
}); | ||
appMetricsEnabled() | ||
.onDisk() | ||
.then((enabled) => { | ||
if (enabled) initPostHog(); | ||
}); | ||
appNonAnonMetricsEnabled() | ||
.onDisk() | ||
.then((enabled) => { | ||
enabled | ||
? posthog.capture('nonAnonMetricsEnabled') | ||
: posthog.capture('nonAnonMetricsDisabled'); | ||
}); | ||
appSettings.appErrorReportingEnabled.onDisk().then((enabled) => { | ||
if (enabled) initSentry(); | ||
}); | ||
appSettings.appMetricsEnabled.onDisk().then((enabled) => { | ||
if (enabled) initPostHog(); | ||
}); | ||
appSettings.appNonAnonMetricsEnabled.onDisk().then((enabled) => { | ||
enabled | ||
? posthog.capture('nonAnonMetricsEnabled') | ||
: posthog.capture('nonAnonMetricsDisabled'); | ||
}); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters