Skip to content

Commit 88ec184

Browse files
committed
sentry integration
1 parent cccb907 commit 88ec184

13 files changed

Lines changed: 212 additions & 16 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,10 @@ 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.SENTRY_PROJECT }}
42+
SENTRY_RELEASE: web@${{ github.sha }}
43+
VITE_SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
44+
VITE_SENTRY_ENVIRONMENT: web-${{ github.ref_name }}
45+
VITE_SENTRY_RELEASE: web@${{ github.sha }}

.github/workflows/publish.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,13 @@ jobs:
368368
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
369369
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
370370
APPLE_API_KEY_PATH: ${{ runner.temp }}/apple-api-key.p8
371+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
372+
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
373+
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
374+
SENTRY_RELEASE: desktop@${{ needs.version.outputs.version }}
375+
VITE_SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
376+
VITE_SENTRY_ENVIRONMENT: desktop-${{ github.ref_name }}
377+
VITE_SENTRY_RELEASE: desktop@${{ needs.version.outputs.version }}
371378

372379
- name: Verify signed Windows desktop artifacts
373380
if: runner.os == 'Windows'

bun.lock

Lines changed: 103 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
@@ -74,6 +74,8 @@
7474
"@solidjs/meta": "0.29.4",
7575
"@solidjs/router": "0.15.4",
7676
"@solidjs/start": "https://pkg.pr.new/@solidjs/start@dfb2020",
77+
"@sentry/solid": "10.36.0",
78+
"@sentry/vite-plugin": "4.6.0",
7779
"solid-js": "1.9.10",
7880
"vite-plugin-solid": "2.11.10",
7981
"@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
<QueryProvider>
145151
<DialogProvider>
146152
<MarkedProvider>

packages/app/src/entry.tsx

Lines changed: 14 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,19 @@ const platform: Platform = {
125126
setDefaultServer: writeDefaultServerUrl,
126127
}
127128

129+
if (!import.meta.env.DEV && 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+
})
140+
}
141+
128142
if (root instanceof HTMLElement) {
129143
const server: ServerConnection.Http = { type: "http", http: { url: getCurrentUrl() } }
130144
render(

packages/app/src/env.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ interface ImportMetaEnv {
44
readonly VITE_OPENCODE_SERVER_HOST: string
55
readonly VITE_OPENCODE_SERVER_PORT: string
66
readonly OPENCODE_CHANNEL?: "dev" | "beta" | "prod"
7+
8+
readonly VITE_SENTRY_DSN?: string
9+
readonly VITE_SENTRY_ENVIRONMENT?: string
10+
readonly VITE_SENTRY_RELEASE?: string
711
}
812

913
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/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"dependencies": {
1616
"@opencode-ai/app": "workspace:*",
1717
"@opencode-ai/ui": "workspace:*",
18+
"@sentry/solid": "catalog:",
1819
"@solid-primitives/i18n": "2.2.1",
1920
"@solid-primitives/storage": "catalog:",
2021
"@tauri-apps/api": "^2",
@@ -35,6 +36,7 @@
3536
},
3637
"devDependencies": {
3738
"@actions/artifact": "4.0.0",
39+
"@sentry/vite-plugin": "catalog:",
3840
"@tauri-apps/cli": "^2",
3941
"@types/bun": "catalog:",
4042
"@typescript/native-preview": "catalog:",

0 commit comments

Comments
 (0)