Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable Sentry in renderer process #397

Merged
merged 21 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
40490f8
send sourcemap to sentry
cristianoventura Nov 27, 2024
537250a
initialize sentry
cristianoventura Nov 27, 2024
dfaac67
Lint
cristianoventura Nov 27, 2024
bd84364
add sentry org and projec variables to release.yml
cristianoventura Nov 27, 2024
93f2055
Merge branch 'main' of github.com:grafana/k6-studio into feat/crash-r…
cristianoventura Dec 11, 2024
11996a9
Merge branch 'main' of github.com:grafana/k6-studio into feat/crash-r…
cristianoventura Dec 30, 2024
72c81a3
crash report settings
cristianoventura Dec 30, 2024
07c31d2
conditionally send event based on user preference
cristianoventura Dec 31, 2024
43631c7
temporarily remove link from sentry opt-in
cristianoventura Dec 31, 2024
989c43f
Remove learn more link
cristianoventura Jan 7, 2025
88c205d
Bump schema version
cristianoventura Jan 7, 2025
a425d5d
Merge branch 'main' into feat/crash-reporter-settings
cristianoventura Jan 7, 2025
879fa3c
Fix test
cristianoventura Jan 7, 2025
494642a
Merge branch 'feat/crash-reporter-settings' of github.com:grafana/k6-…
cristianoventura Jan 7, 2025
0f60ba8
Test v2 migration
cristianoventura Jan 7, 2025
ee8b656
Change copy for Telemetry settings
cristianoventura Jan 7, 2025
32367fd
enable Sentry in renderer process
cristianoventura Jan 7, 2025
ab6bb99
Merge branch 'main' of github.com:grafana/k6-studio into feat/sentry-…
cristianoventura Jan 9, 2025
f25083a
capture unhandled promise rejections
cristianoventura Jan 10, 2025
5c2908e
configure sentry for renderer and preload processes
cristianoventura Jan 11, 2025
38ca017
disable integrations
cristianoventura Jan 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { HarFile } from './types/har'
import { GeneratorFile } from './types/generator'
import { AddToastPayload } from './types/toast'
import { AppSettings } from './types/settings'
import * as Sentry from './sentry'

interface GetFilesResponse {
recordings: string[]
Expand Down Expand Up @@ -209,4 +210,6 @@ const studio = {

contextBridge.exposeInMainWorld('studio', studio)

Sentry.configureRendererProcess(studio.settings.getSettings)

export type Studio = typeof studio
3 changes: 3 additions & 0 deletions src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@
import { ProxyData } from './types'
import './index.tsx'
import { setMonacoEnv } from './components/Monaco/setMonacoEnv'
import * as Sentry from './sentry'

setMonacoEnv()

Sentry.configureRendererProcess()

// Proxy

window.studio.proxy.onProxyData((_data: ProxyData) => {})
25 changes: 25 additions & 0 deletions src/sentry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import * as SentryRenderer from '@sentry/electron/renderer'
import { AppSettings } from './types/settings'

export function configureRendererProcess(
getSettingsFn?: () => Promise<AppSettings>
) {
if (process.env.NODE_ENV !== 'development') {
SentryRenderer.init({
// conditionally send the event based on the user's settings
beforeSend: async (event) => {
const getSettings = getSettingsFn || window.studio.settings.getSettings
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

window isn't available in the preload context so I'm adding flexibility here to pass the getSettings function as an argument optionally.

const { telemetry } = await getSettings()
if (telemetry.errorReport) {
return event
}
return null
},
})

// attach event listener to catch unhandled promise rejections
window.addEventListener('unhandledrejection', (event) => {
SentryRenderer.captureException(event.reason)
})
}
}
Loading