Skip to content

Commit 8dacb78

Browse files
committed
style: make eslint happy
1 parent cf5c799 commit 8dacb78

File tree

6 files changed

+242
-0
lines changed

6 files changed

+242
-0
lines changed

.github/workflows/test-and-release.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ jobs:
99
main:
1010
runs-on: ubuntu-latest
1111

12+
environment: production
13+
1214
steps:
1315
- uses: actions/checkout@v4
1416

@@ -37,6 +39,7 @@ jobs:
3739
- name: Build
3840
env:
3941
PUBLIC_VERSION: ${{ github.sha }}
42+
PUBLIC_SENTRY_DSN: ${{ vars.SENTRY_DSN }}
4043
run: npm run build
4144

4245
- name: Install playwright

package-lock.json

Lines changed: 211 additions & 0 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
@@ -30,6 +30,8 @@
3030
],
3131
"dependencies": {
3232
"@nordicsemiconductor/from-env": "3.0.0",
33+
"@sentry/react": "7.91.0",
34+
"@sentry/browser": "7.91.0",
3335
"ajv": "8.12.0",
3436
"date-fns-tz": "2.0.0",
3537
"feather-icons": "4.29.1",

src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { App } from 'app/App'
22
import { log } from 'app/log'
33
import { StrictMode } from 'react'
44
import { createRoot } from 'react-dom/client'
5+
import 'app/sentry.js'
56

67
const l = (...args: any) => log('App', ...args)
78
l('Version:', import.meta.env.PUBLIC_VERSION)

src/sentry.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import * as Sentry from '@sentry/react'
2+
import { BrowserTracing } from '@sentry/browser'
3+
4+
const enableSentry = import.meta.env.PUBLIC_SENTRY_DSN !== undefined
5+
6+
if (enableSentry) {
7+
console.debug(`Sentry enabled.`)
8+
Sentry.init({
9+
dsn: import.meta.env.PUBLIC_SENTRY_DSN,
10+
integrations: [new BrowserTracing()],
11+
tracesSampleRate: 0.05,
12+
})
13+
Sentry.setContext('app', {
14+
version: import.meta.env.PUBLIC_VERSION,
15+
})
16+
} else {
17+
console.debug(`Sentry disabled.`)
18+
}
19+
20+
export const captureMessage = (message: string): void => {
21+
console.debug(message)
22+
if (!enableSentry) return
23+
Sentry.captureMessage(message)
24+
}

src/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ interface ImportMeta {
2626
PUBLIC_MANIFEST_SHORT_NAME: string
2727
PUBLIC_MANIFEST_THEME_COLOR: string
2828
PUBLIC_MANIFEST_BACKGROUND_COLOR: string
29+
PUBLIC_SENTRY_DSN: string
2930
}
3031
}
3132

0 commit comments

Comments
 (0)