Skip to content

Commit 6dae76f

Browse files
feat: allow telemetry opt-out (#334)
* feat: allow telemetry opt-out * chore: remove junk * chore: tidy up * chore: leftover * chore: autogenerate api --------- Co-authored-by: Giuseppe Scuglia <[email protected]>
1 parent 9a56230 commit 6dae76f

File tree

13 files changed

+75
-1397
lines changed

13 files changed

+75
-1397
lines changed

main/src/main.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,15 @@ import {
3434
import log from './logger'
3535
import { getAppVersion } from './util'
3636

37+
import Store from 'electron-store'
38+
39+
const store = new Store<{
40+
isTelemetryEnabled: boolean
41+
}>({ defaults: { isTelemetryEnabled: true } })
42+
3743
Sentry.init({
3844
dsn: import.meta.env.VITE_SENTRY_DSN,
45+
beforeSend: (event) => (store.get('isTelemetryEnabled', true) ? event : null),
3946
})
4047

4148
// Forge environment variables
@@ -445,3 +452,21 @@ ipcMain.handle('shutdown-store:clear-history', () => {
445452
ipcMain.handle('get-app-version', () => {
446453
return getAppVersion()
447454
})
455+
456+
// ────────────────────────────────────────────────────────────────────────────
457+
// Sentry IPC handlers
458+
// ────────────────────────────────────────────────────────────────────────────
459+
460+
ipcMain.handle('sentry.is-enabled', () => {
461+
return store.get('isTelemetryEnabled', true)
462+
})
463+
464+
ipcMain.handle('sentry.opt-out', (): boolean => {
465+
store.set('isTelemetryEnabled', false)
466+
return store.get('isTelemetryEnabled', false)
467+
})
468+
469+
ipcMain.handle('sentry.opt-in', (): boolean => {
470+
store.set('isTelemetryEnabled', true)
471+
return store.get('isTelemetryEnabled', true)
472+
})

preload/src/preload.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ contextBridge.exposeInMainWorld('electronAPI', {
6464
}
6565
},
6666

67+
sentry: {
68+
isEnabled: () => ipcRenderer.invoke('sentry.is-enabled'),
69+
optIn: () => ipcRenderer.invoke('sentry.opt-in'),
70+
optOut: () => ipcRenderer.invoke('sentry.opt-out'),
71+
},
72+
6773
// Window controls
6874
windowControls: {
6975
minimize: () => ipcRenderer.invoke('window-minimize'),
@@ -118,6 +124,11 @@ export interface ElectronAPI {
118124
themeSource: 'system' | 'light' | 'dark'
119125
}>
120126
}
127+
sentry: {
128+
isEnabled: () => Promise<boolean>
129+
optIn: () => Promise<boolean>
130+
optOut: () => Promise<boolean>
131+
}
121132
isMac: boolean
122133
isWindows: boolean
123134
isLinux: boolean

renderer/src/common/api/generated/client/client.ts

Lines changed: 0 additions & 193 deletions
This file was deleted.

renderer/src/common/api/generated/client/index.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)