-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add init from main - add init from render
- Loading branch information
Showing
11 changed files
with
61 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import { render } from 'react-dom'; | ||
import App from './App'; | ||
import { initSentry } from './utils/sentry'; | ||
initSentry(); | ||
|
||
render(<App />, document.getElementById('root')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import * as Sentry from '@sentry/electron/renderer'; | ||
import { User } from '../../main/types'; | ||
|
||
/** | ||
* Init Sentry in the renderer process | ||
* @param dsn Sentry DSN | ||
* @param enabled Whether Sentry should be enabled or not | ||
*/ | ||
export const initSentry = () => { | ||
Sentry.init({ | ||
dsn: process.env.SENTRY_DSN, | ||
enabled: true, // TODO: add env variable to enable/disable Sentry | ||
}); | ||
Sentry.captureMessage('Renderer process started'); | ||
}; | ||
|
||
/** | ||
* Reports an error to Sentry from the renderer process | ||
* | ||
* @param error The error to be reported | ||
* @param context The context to attach to the error such the userId, tags, boolean values... | ||
*/ | ||
export const reportError = ( | ||
error: unknown, | ||
context: Record<string, string> = {} | ||
) => { | ||
Sentry.captureException(error, context); | ||
}; | ||
|
||
|
||
/** | ||
* Set user context in Sentry | ||
* @param user User object | ||
*/ | ||
export const setUserContextForReports = (user: User) => { | ||
if (!user) { | ||
Sentry.setUser(null); | ||
return; | ||
} | ||
Sentry.setUser({ | ||
email: user.email, | ||
id: user.uuid, | ||
}); | ||
}; |