Skip to content

Commit 32b97f7

Browse files
committed
electron sentry integration
1 parent 88ec184 commit 32b97f7

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: {
@@ -57,13 +75,14 @@ export default defineConfig({
5775
},
5876
},
5977
renderer: {
60-
plugins: [appPlugin],
78+
plugins: [appPlugin, sentry],
6179
publicDir: "../../../app/public",
6280
root: "src/renderer",
6381
define: {
6482
"import.meta.env.VITE_OPENCODE_CHANNEL": JSON.stringify(channel),
6583
},
6684
build: {
85+
sourcemap: true,
6786
rollupOptions: {
6887
input: {
6988
main: "src/renderer/index.html",

packages/desktop-electron/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
"@lydell/node-pty": "catalog:",
3838
"@opencode-ai/app": "workspace:*",
3939
"@opencode-ai/ui": "workspace:*",
40+
"@sentry/solid": "catalog:",
41+
"@sentry/vite-plugin": "catalog:",
4042
"@solid-primitives/i18n": "2.2.1",
4143
"@solid-primitives/storage": "catalog:",
4244
"@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"
@@ -30,6 +31,19 @@ if (import.meta.env.DEV && !(root instanceof HTMLElement)) {
3031
throw new Error(t("error.dev.rootNotFound"))
3132
}
3233

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

3549
const deepLinkEvent = "opencode:deep-link"

0 commit comments

Comments
 (0)