Skip to content

Commit 1df1902

Browse files
committed
sentry integration
1 parent b420952 commit 1df1902

12 files changed

Lines changed: 116 additions & 12 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'

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@
7777
"@solidjs/meta": "0.29.4",
7878
"@solidjs/router": "0.15.4",
7979
"@solidjs/start": "https://pkg.pr.new/@solidjs/start@dfb2020",
80+
"@sentry/solid": "10.36.0",
81+
"@sentry/vite-plugin": "4.6.0",
8082
"solid-js": "1.9.10",
8183
"vite-plugin-solid": "2.11.10",
8284
"@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/core": "workspace:*",

packages/app/src/app.tsx

Lines changed: 14 additions & 6 deletions
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"
@@ -148,12 +149,19 @@ export function AppBaseProviders(props: ParentProps<{ locale?: Locale }>) {
148149
>
149150
<LanguageProvider locale={props.locale}>
150151
<UiI18nBridge>
151-
<ErrorBoundary fallback={(error) => <ErrorPage error={error} />}>
152-
<DialogProvider>
153-
<MarkedProvider>
154-
<FileComponentProvider component={File}>{props.children}</FileComponentProvider>
155-
</MarkedProvider>
156-
</DialogProvider>
152+
<ErrorBoundary
153+
fallback={(error) => {
154+
Sentry.captureException(error)
155+
return <ErrorPage error={error} />
156+
}}
157+
>
158+
<QueryProvider>
159+
<DialogProvider>
160+
<MarkedProvider>
161+
<FileComponentProvider component={File}>{props.children}</FileComponentProvider>
162+
</MarkedProvider>
163+
</DialogProvider>
164+
</QueryProvider>
157165
</ErrorBoundary>
158166
</UiI18nBridge>
159167
</LanguageProvider>

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
@@ -2,6 +2,10 @@ 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+
6+
readonly VITE_SENTRY_DSN?: string
7+
readonly VITE_SENTRY_ENVIRONMENT?: string
8+
readonly VITE_SENTRY_RELEASE?: string
59
}
610

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

packages/desktop/src/env.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
interface ImportMetaEnv {
2+
readonly VITE_SENTRY_DSN?: string
3+
readonly VITE_SENTRY_ENVIRONMENT?: string
4+
readonly VITE_SENTRY_RELEASE?: string
5+
}
6+
7+
interface ImportMeta {
8+
readonly env: ImportMetaEnv
9+
}

0 commit comments

Comments
 (0)