From b9eda55a2c9b9b1410a1c27ca10a00afc81d2f5c Mon Sep 17 00:00:00 2001 From: Rafael Araujo Lehmkuhl Date: Tue, 30 Jul 2024 16:06:11 -0300 Subject: [PATCH] telemetry: Allow user to opt out of sending usage statistics --- src/main.ts | 23 ++++++++++++---------- src/stores/development.ts | 10 +++++++++- src/views/ConfigurationDevelopmentView.vue | 10 +++++++++- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/main.ts b/src/main.ts index de5b8c603..c3b0a11d1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -22,16 +22,19 @@ loadFonts() const app = createApp(App) -Sentry.init({ - app, - dsn: 'https://5176a29493da4d31a6384c55d291cd3d@o4507692193415168.ingest.us.sentry.io/4507692196036608', - integrations: [Sentry.browserTracingIntegration(), Sentry.replayIntegration()], - tracesSampleRate: 0.1, // Capture 10% of the transactions - tracePropagationTargets: [], - replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production. - replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur. - transport: Sentry.makeBrowserOfflineTransport(Sentry.makeFetchTransport), -}) +// Only track usage statistics if the user has not opted out +if (window.localStorage.getItem('cockpit-enable-usage-statistics-telemetry')) { + Sentry.init({ + app, + dsn: 'https://5176a29493da4d31a6384c55d291cd3d@o4507692193415168.ingest.us.sentry.io/4507692196036608', + integrations: [Sentry.browserTracingIntegration(), Sentry.replayIntegration()], + tracesSampleRate: 0.1, // Capture 10% of the transactions + tracePropagationTargets: [], + replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production. + replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur. + transport: Sentry.makeBrowserOfflineTransport(Sentry.makeFetchTransport), // Cache events and send them when the user comes back online + }) +} app.component('FontAwesomeIcon', FontAwesomeIcon) app.use(router).use(vuetify).use(createPinia()).use(FloatingVue).use(VueVirtualScroller) diff --git a/src/stores/development.ts b/src/stores/development.ts index d16e7c01e..a2c1f42f3 100644 --- a/src/stores/development.ts +++ b/src/stores/development.ts @@ -6,12 +6,20 @@ import { useBlueOsStorage } from '@/composables/settingsSyncer' export const systemLoggingEnablingKey = 'cockpit-enable-system-logging' export const blueOsSettingsSyncEnablingKey = 'cockpit-enable-blueos-settings-sync' +export const enableUsageStatisticsTelemetryKey = 'cockpit-enable-usage-statistics-telemetry' export const useDevelopmentStore = defineStore('development', () => { const developmentMode = ref(false) const widgetDevInfoBlurLevel = ref(3) const enableSystemLogging = useBlueOsStorage(systemLoggingEnablingKey, true) const enableBlueOsSettingsSync = useStorage(blueOsSettingsSyncEnablingKey, true) + const enableUsageStatisticsTelemetry = useStorage(enableUsageStatisticsTelemetryKey, true) - return { developmentMode, widgetDevInfoBlurLevel, enableSystemLogging, enableBlueOsSettingsSync } + return { + developmentMode, + widgetDevInfoBlurLevel, + enableSystemLogging, + enableBlueOsSettingsSync, + enableUsageStatisticsTelemetry, + } }) diff --git a/src/views/ConfigurationDevelopmentView.vue b/src/views/ConfigurationDevelopmentView.vue index 8beed042d..dd165ddfd 100644 --- a/src/views/ConfigurationDevelopmentView.vue +++ b/src/views/ConfigurationDevelopmentView.vue @@ -4,7 +4,7 @@