mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-18 14:31:30 +03:00
fix: dont initialize posthog / sentry analytics before onboarding complete
This commit is contained in:
parent
d6a882b1ba
commit
732a196505
22
app/src/lib/analytics/analytics.ts
Normal file
22
app/src/lib/analytics/analytics.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { initPostHog } from '$lib/analytics/posthog';
|
||||||
|
import { initSentry } from '$lib/analytics/sentry';
|
||||||
|
import { appAnalyticsConfirmed } from '$lib/config/appSettings';
|
||||||
|
import { appMetricsEnabled, appErrorReportingEnabled } from '$lib/config/appSettings';
|
||||||
|
|
||||||
|
export function initAnalyticsIfEnabled() {
|
||||||
|
const analyticsConfirmed = appAnalyticsConfirmed();
|
||||||
|
analyticsConfirmed.onDisk().then((confirmed) => {
|
||||||
|
if (confirmed) {
|
||||||
|
appErrorReportingEnabled()
|
||||||
|
.onDisk()
|
||||||
|
.then((enabled) => {
|
||||||
|
if (enabled) initSentry();
|
||||||
|
});
|
||||||
|
appMetricsEnabled()
|
||||||
|
.onDisk()
|
||||||
|
.then((enabled) => {
|
||||||
|
if (enabled) initPostHog();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import AnalyticsSettings from './AnalyticsSettings.svelte';
|
import AnalyticsSettings from './AnalyticsSettings.svelte';
|
||||||
import Button from './Button.svelte';
|
import Button from './Button.svelte';
|
||||||
|
import { initAnalyticsIfEnabled } from '$lib/analytics/analytics';
|
||||||
import type { Writable } from 'svelte/store';
|
import type { Writable } from 'svelte/store';
|
||||||
|
|
||||||
export let analyticsConfirmed: Writable<boolean>;
|
export let analyticsConfirmed: Writable<boolean>;
|
||||||
@ -17,6 +18,7 @@
|
|||||||
icon="chevron-right-small"
|
icon="chevron-right-small"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
$analyticsConfirmed = true;
|
$analyticsConfirmed = true;
|
||||||
|
initAnalyticsIfEnabled();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Continue
|
Continue
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import InfoMessage from './InfoMessage.svelte';
|
|
||||||
import Link from './Link.svelte';
|
import Link from './Link.svelte';
|
||||||
import SectionCard from './SectionCard.svelte';
|
import SectionCard from './SectionCard.svelte';
|
||||||
import Toggle from './Toggle.svelte';
|
import Toggle from './Toggle.svelte';
|
||||||
@ -7,16 +6,13 @@
|
|||||||
|
|
||||||
const errorReportingEnabled = appErrorReportingEnabled();
|
const errorReportingEnabled = appErrorReportingEnabled();
|
||||||
const metricsEnabled = appMetricsEnabled();
|
const metricsEnabled = appMetricsEnabled();
|
||||||
let updatedTelemetrySettings = false;
|
|
||||||
|
|
||||||
function toggleErrorReporting() {
|
function toggleErrorReporting() {
|
||||||
$errorReportingEnabled = !$errorReportingEnabled;
|
$errorReportingEnabled = !$errorReportingEnabled;
|
||||||
updatedTelemetrySettings = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleMetrics() {
|
function toggleMetrics() {
|
||||||
$metricsEnabled = !$metricsEnabled;
|
$metricsEnabled = !$metricsEnabled;
|
||||||
updatedTelemetrySettings = true;
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -60,14 +56,6 @@
|
|||||||
<Toggle id="metricsEnabledToggle" checked={$metricsEnabled} on:change={toggleMetrics} />
|
<Toggle id="metricsEnabledToggle" checked={$metricsEnabled} on:change={toggleMetrics} />
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</SectionCard>
|
</SectionCard>
|
||||||
|
|
||||||
{#if updatedTelemetrySettings}
|
|
||||||
<InfoMessage>
|
|
||||||
<svelte:fragment slot="content"
|
|
||||||
>Changes will take effect on the next application start.</svelte:fragment
|
|
||||||
>
|
|
||||||
</InfoMessage>
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
import { AIService } from '$lib/ai/service';
|
import { AIService } from '$lib/ai/service';
|
||||||
import { initPostHog } from '$lib/analytics/posthog';
|
import { initAnalyticsIfEnabled } from '$lib/analytics/analytics';
|
||||||
import { initSentry } from '$lib/analytics/sentry';
|
|
||||||
import { AuthService } from '$lib/backend/auth';
|
import { AuthService } from '$lib/backend/auth';
|
||||||
import { GitConfigService } from '$lib/backend/gitConfigService';
|
import { GitConfigService } from '$lib/backend/gitConfigService';
|
||||||
import { HttpClient } from '$lib/backend/httpClient';
|
import { HttpClient } from '$lib/backend/httpClient';
|
||||||
import { ProjectService } from '$lib/backend/projects';
|
import { ProjectService } from '$lib/backend/projects';
|
||||||
import { PromptService } from '$lib/backend/prompt';
|
import { PromptService } from '$lib/backend/prompt';
|
||||||
import { UpdaterService } from '$lib/backend/updater';
|
import { UpdaterService } from '$lib/backend/updater';
|
||||||
import { appMetricsEnabled, appErrorReportingEnabled } from '$lib/config/appSettings';
|
|
||||||
import { GitHubService } from '$lib/github/service';
|
import { GitHubService } from '$lib/github/service';
|
||||||
import { UserService } from '$lib/stores/user';
|
import { UserService } from '$lib/stores/user';
|
||||||
import lscache from 'lscache';
|
import lscache from 'lscache';
|
||||||
@ -24,16 +22,7 @@ export const prerender = false;
|
|||||||
export const csr = true;
|
export const csr = true;
|
||||||
|
|
||||||
export async function load() {
|
export async function load() {
|
||||||
appErrorReportingEnabled()
|
initAnalyticsIfEnabled();
|
||||||
.onDisk()
|
|
||||||
.then((enabled) => {
|
|
||||||
if (enabled) initSentry();
|
|
||||||
});
|
|
||||||
appMetricsEnabled()
|
|
||||||
.onDisk()
|
|
||||||
.then((enabled) => {
|
|
||||||
if (enabled) initPostHog();
|
|
||||||
});
|
|
||||||
|
|
||||||
// TODO: Find a workaround to avoid this dynamic import
|
// TODO: Find a workaround to avoid this dynamic import
|
||||||
// https://github.com/sveltejs/kit/issues/905
|
// https://github.com/sveltejs/kit/issues/905
|
||||||
|
Loading…
Reference in New Issue
Block a user