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: implement crash reporter #365

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

cristianoventura
Copy link
Collaborator

@cristianoventura cristianoventura commented Nov 27, 2024

Description

This PR integrates Sentry so we can collect information about crashes and other errors in the main process for production builds.

How to Test

This integration only works in production. You can either:

  • Option 1: test the artifacts for the temporary 0.8.1 release. This release has one commit ahead of this branch that calls an undefined function on startup which will report to Sentry
  • Option 2: change main.ts locally to work in development environment, start the app setting the SENTRY_DSN variable (which is available in the project's config in Sentry), and manually throw an error. (source maps will not be available in development mode)

Notes:

  • Secrets and env variables are stored in this repo settings
  • Sentry DSN is statically replaced during build time and shipped within the release artifacts
  • Optionally test the integration locally with SENTRY_DSN=xx npm start
  • You can simulate a crash using process.crash() anywhere in the main process

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (npm run lint) and all checks pass.
  • I have run tests locally (npm test) and all tests pass.
  • I have commented on my code, particularly in hard-to-understand areas.

Screenshots (if appropriate):

image

Related PR(s)/Issue(s)

Resolves #349

@cristianoventura cristianoventura self-assigned this Nov 27, 2024
// initialize Sentry
Sentry.init({
dsn: SENTRY_DSN,
integrations: [Sentry.electronMinidumpIntegration()],
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ElectronMinidump will enable integration with crashReporter. This is only configured in Prod mode to reduce noise.

const def = {
[VITE_DEV_SERVER_URL]:
command === 'serve'
? JSON.stringify(process.env[VITE_DEV_SERVER_URL])
: undefined,
[VITE_NAME]: JSON.stringify(name),
[SENTRY_DSN]: JSON.stringify(process.env.SENTRY_DSN),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We need the Sentry DSN variable to be statically replaced during build time since env variables are not available during runtime in Prod.

Comment on lines +30 to +34
sentryVitePlugin({
authToken: process.env.SENTRY_AUTH_TOKEN,
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
}),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This plugin uploads the source map to Sentry to help us identify the actual stack trace of an issue

@cristianoventura cristianoventura marked this pull request as ready for review November 27, 2024 15:58
@cristianoventura cristianoventura requested a review from a team as a code owner November 27, 2024 15:58
@cristianoventura cristianoventura requested review from going-confetti, e-fisher and Llandy3d and removed request for a team November 27, 2024 15:58
@cristianoventura cristianoventura marked this pull request as draft November 27, 2024 20:55
@cristianoventura cristianoventura marked this pull request as ready for review January 2, 2025 16:30
@cristianoventura cristianoventura requested review from Llandy3d, e-fisher and going-confetti and removed request for Llandy3d and e-fisher January 2, 2025 16:30
Copy link
Collaborator

@e-fisher e-fisher left a comment

Choose a reason for hiding this comment

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

Works as expected! Should we enable react for the renderer process as well, or perhaps that's a separate PR?

@cristianoventura
Copy link
Collaborator Author

Works as expected! Should we enable react for the renderer process as well, or perhaps that's a separate PR?

I'll add the integration to the renderer process on a separate PR to minimize the changes here, once the settings PR #393 is approved.

Copy link
Collaborator

@e-fisher e-fisher left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement crash reporter
3 participants