Skip to content

Commit 7d7f429

Browse files
committed
electron sentry integration
1 parent 1df1902 commit 7d7f429

4 files changed

Lines changed: 38 additions & 1 deletion

File tree

bun.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/desktop-electron/electron.vite.config.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { sentryVitePlugin } from "@sentry/vite-plugin"
12
import { defineConfig } from "electron-vite"
23
import appPlugin from "@opencode-ai/app/vite"
34
import * as fs from "node:fs/promises"
@@ -12,6 +13,23 @@ const OPENCODE_SERVER_DIST = "../opencode/dist/node"
1213

1314
const nodePtyPkg = `@lydell/node-pty-${process.platform}-${process.arch}`
1415

16+
const sentry =
17+
process.env.SENTRY_AUTH_TOKEN && process.env.SENTRY_ORG && process.env.SENTRY_PROJECT
18+
? sentryVitePlugin({
19+
authToken: process.env.SENTRY_AUTH_TOKEN,
20+
org: process.env.SENTRY_ORG,
21+
project: process.env.SENTRY_PROJECT,
22+
telemetry: false,
23+
release: {
24+
name: process.env.SENTRY_RELEASE ?? process.env.VITE_SENTRY_RELEASE,
25+
},
26+
sourcemaps: {
27+
assets: "./out/renderer/**",
28+
filesToDeleteAfterUpload: "./out/renderer/**/*.map",
29+
},
30+
})
31+
: false
32+
1533
export default defineConfig({
1634
main: {
1735
define: {
@@ -61,13 +79,14 @@ export default defineConfig({
6179
},
6280
},
6381
renderer: {
64-
plugins: [appPlugin],
82+
plugins: [appPlugin, sentry],
6583
publicDir: "../../../app/public",
6684
root: "src/renderer",
6785
define: {
6886
"import.meta.env.VITE_OPENCODE_CHANNEL": JSON.stringify(channel),
6987
},
7088
build: {
89+
sourcemap: true,
7190
rollupOptions: {
7291
input: {
7392
main: "src/renderer/index.html",

packages/desktop-electron/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
"@lydell/node-pty": "catalog:",
3939
"@opencode-ai/app": "workspace:*",
4040
"@opencode-ai/ui": "workspace:*",
41+
"@sentry/solid": "catalog:",
42+
"@sentry/vite-plugin": "catalog:",
4143
"@solid-primitives/i18n": "2.2.1",
4244
"@solid-primitives/storage": "catalog:",
4345
"@solidjs/meta": "catalog:",

packages/desktop-electron/src/renderer/index.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
ServerConnection,
1515
useCommand,
1616
} from "@opencode-ai/app"
17+
import * as Sentry from "@sentry/solid"
1718
import type { AsyncStorage } from "@solid-primitives/storage"
1819
import { MemoryRouter } from "@solidjs/router"
1920
import { createEffect, createResource, onCleanup, onMount, Show } from "solid-js"
@@ -29,6 +30,19 @@ if (import.meta.env.DEV && !(root instanceof HTMLElement)) {
2930
throw new Error(t("error.dev.rootNotFound"))
3031
}
3132

33+
if (!import.meta.env.DEV && import.meta.env.VITE_SENTRY_DSN) {
34+
Sentry.init({
35+
dsn: import.meta.env.VITE_SENTRY_DSN,
36+
environment: import.meta.env.VITE_SENTRY_ENVIRONMENT ?? import.meta.env.MODE,
37+
release: import.meta.env.VITE_SENTRY_RELEASE ?? `desktop-electron@${pkg.version}`,
38+
initialScope: {
39+
tags: {
40+
platform: "desktop-electron",
41+
},
42+
},
43+
})
44+
}
45+
3246
void initI18n()
3347

3448
const deepLinkEvent = "opencode:deep-link"

0 commit comments

Comments
 (0)