Skip to content

Commit 6cce4b5

Browse files
Apply PR #15300: desktop: sentry integration
2 parents a763eec + 264070c commit 6cce4b5

File tree

16 files changed

+231
-16
lines changed

16 files changed

+231
-16
lines changed

.github/workflows/deploy.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,9 @@ jobs:
3636
PLANETSCALE_SERVICE_TOKEN_NAME: ${{ secrets.PLANETSCALE_SERVICE_TOKEN_NAME }}
3737
PLANETSCALE_SERVICE_TOKEN: ${{ secrets.PLANETSCALE_SERVICE_TOKEN }}
3838
STRIPE_SECRET_KEY: ${{ github.ref_name == 'production' && secrets.STRIPE_SECRET_KEY_PROD || secrets.STRIPE_SECRET_KEY_DEV }}
39+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
40+
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
41+
SENTRY_PROJECT: ${{ vars.WEB_SENTRY_PROJECT }}
42+
SENTRY_RELEASE: web@${{ github.sha }}
43+
VITE_SENTRY_DSN: ${{ vars.WEB_SENTRY_DSN }}
44+
VITE_SENTRY_RELEASE: web@${{ github.sha }}

.github/workflows/publish.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,13 @@ jobs:
490490
working-directory: packages/desktop-electron
491491
env:
492492
OPENCODE_CHANNEL: ${{ (github.ref_name == 'beta' && 'beta') || 'prod' }}
493+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
494+
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
495+
SENTRY_PROJECT: ${{ vars.WEB_SENTRY_PROJECT }}
496+
SENTRY_RELEASE: desktop@${{ needs.version.outputs.version }}
497+
VITE_SENTRY_DSN: ${{ vars.WEB_SENTRY_DSN }}
498+
VITE_SENTRY_ENVIRONMENT: ${{ (github.ref_name == 'beta' && 'beta') || 'production' }}
499+
VITE_SENTRY_RELEASE: desktop@${{ needs.version.outputs.version }}
493500

494501
- name: Package and publish
495502
if: needs.version.outputs.release

bun.lock

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

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@
7676
"@solidjs/meta": "0.29.4",
7777
"@solidjs/router": "0.15.4",
7878
"@solidjs/start": "https://pkg.pr.new/@solidjs/start@dfb2020",
79+
"@sentry/solid": "10.36.0",
80+
"@sentry/vite-plugin": "4.6.0",
7981
"solid-js": "1.9.10",
8082
"vite-plugin-solid": "2.11.10",
8183
"@lydell/node-pty": "1.2.0-beta.10"

packages/app/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"devDependencies": {
2828
"@happy-dom/global-registrator": "20.0.11",
2929
"@playwright/test": "catalog:",
30+
"@sentry/vite-plugin": "catalog:",
3031
"@tailwindcss/vite": "catalog:",
3132
"@tsconfig/bun": "1.0.9",
3233
"@types/bun": "catalog:",
@@ -40,6 +41,7 @@
4041
},
4142
"dependencies": {
4243
"@kobalte/core": "catalog:",
44+
"@sentry/solid": "catalog:",
4345
"@opencode-ai/sdk": "workspace:*",
4446
"@opencode-ai/ui": "workspace:*",
4547
"@opencode-ai/shared": "workspace:*",

packages/app/src/app.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import "@/index.css"
2+
import * as Sentry from "@sentry/solid"
23
import { I18nProvider } from "@opencode-ai/ui/context"
34
import { DialogProvider } from "@opencode-ai/ui/context/dialog"
45
import { FileComponentProvider } from "@opencode-ai/ui/context/file"
@@ -140,7 +141,12 @@ export function AppBaseProviders(props: ParentProps<{ locale?: Locale }>) {
140141
>
141142
<LanguageProvider locale={props.locale}>
142143
<UiI18nBridge>
143-
<ErrorBoundary fallback={(error) => <ErrorPage error={error} />}>
144+
<ErrorBoundary
145+
fallback={(error) => {
146+
Sentry.captureException(error)
147+
return <ErrorPage error={error} />
148+
}}
149+
>
144150
<DialogProvider>
145151
<MarkedProvider>
146152
<FileComponentProvider component={File}>{props.children}</FileComponentProvider>

packages/app/src/entry.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// @refresh reload
22

3+
import * as Sentry from "@sentry/solid"
34
import { render } from "solid-js/web"
45
import { AppBaseProviders, AppInterface } from "@/app"
56
import { type Platform, PlatformProvider } from "@/context/platform"
@@ -125,6 +126,25 @@ const platform: Platform = {
125126
setDefaultServer: writeDefaultServerUrl,
126127
}
127128

129+
if (import.meta.env.VITE_SENTRY_DSN) {
130+
Sentry.init({
131+
dsn: import.meta.env.VITE_SENTRY_DSN,
132+
environment: import.meta.env.VITE_SENTRY_ENVIRONMENT ?? import.meta.env.MODE,
133+
release: import.meta.env.VITE_SENTRY_RELEASE ?? `web@${pkg.version}`,
134+
initialScope: {
135+
tags: {
136+
platform: "web",
137+
},
138+
},
139+
integrations: (integrations) => {
140+
return integrations.filter(
141+
(i) =>
142+
i.name !== "Breadcrumbs" && !(import.meta.env.OPENCODE_CHANNEL === "prod" && i.name === "GlobalHandlers"),
143+
)
144+
},
145+
})
146+
}
147+
128148
if (root instanceof HTMLElement) {
129149
const server: ServerConnection.Http = { type: "http", http: { url: getCurrentUrl() } }
130150
render(

packages/app/src/env.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ interface ImportMetaEnv {
22
readonly VITE_OPENCODE_SERVER_HOST: string
33
readonly VITE_OPENCODE_SERVER_PORT: string
44
readonly VITE_OPENCODE_CHANNEL?: "dev" | "beta" | "prod"
5+
readonly OPENCODE_CHANNEL?: "dev" | "beta" | "prod"
6+
7+
readonly VITE_SENTRY_DSN?: string
8+
readonly VITE_SENTRY_ENVIRONMENT?: string
9+
readonly VITE_SENTRY_RELEASE?: string
510
}
611

712
interface ImportMeta {

packages/app/vite.config.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,33 @@
1+
import { sentryVitePlugin } from "@sentry/vite-plugin"
12
import { defineConfig } from "vite"
23
import desktopPlugin from "./vite"
34

5+
const sentry =
6+
process.env.SENTRY_AUTH_TOKEN && process.env.SENTRY_ORG && process.env.SENTRY_PROJECT
7+
? sentryVitePlugin({
8+
authToken: process.env.SENTRY_AUTH_TOKEN,
9+
org: process.env.SENTRY_ORG,
10+
project: process.env.SENTRY_PROJECT,
11+
telemetry: false,
12+
release: {
13+
name: process.env.SENTRY_RELEASE ?? process.env.VITE_SENTRY_RELEASE,
14+
},
15+
sourcemaps: {
16+
assets: "./dist/**",
17+
filesToDeleteAfterUpload: "./dist/**/*.map",
18+
},
19+
})
20+
: false
21+
422
export default defineConfig({
5-
plugins: [desktopPlugin] as any,
23+
plugins: [desktopPlugin, sentry] as any,
624
server: {
725
host: "0.0.0.0",
826
allowedHosts: true,
927
port: 3000,
1028
},
1129
build: {
1230
target: "esnext",
13-
// sourcemap: true,
31+
sourcemap: true,
1432
},
1533
})

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",

0 commit comments

Comments
 (0)