Skip to content

Instantly share code, notes, and snippets.

@ajmasia
Last active October 6, 2021 17:26
Show Gist options
  • Save ajmasia/c10005f6fd2ecd61bef5c0aa1fdf5803 to your computer and use it in GitHub Desktop.
Save ajmasia/c10005f6fd2ecd61bef5c0aa1fdf5803 to your computer and use it in GitHub Desktop.
Sentry config Electron + Vue2
import Vue from 'vue'
import * as Sentry from '@sentry/electron'
import * as SentryIntegrations from '@sentry/integrations'
import { sentryDSN, eviorement, releaseVersion } from '@/config/env'
export const ElectronCrashReporter = () =>
Sentry.init({
dsn: sentryDSN,
environment: eviorement,
release: releaseVersion,
})
export const VueCrashReporter = () => {
return Sentry.init({
dsn: sentryDSN,
environment: eviorement,
integrations: [
new SentryIntegrations.Vue({
Vue,
logErrors: true,
tracing: false,
}),
],
release: releaseVersion,
debug: true,
})
}
/**
* Electron main process (background.js): Import `ElectronCrashReporter` and call it
* Renderer process (main.js): Import `VueCrashReporter` and call it
*/
@mehrdadmms
Copy link

Yes I ran ElectronCrashReporter in backend.js and VueCrashReporter in main.js
should I run it in a specific function or any where in the file is ok ?
@ajmasia

@ajmasia
Copy link
Author

ajmasia commented Oct 6, 2021

@mehrdadmms, I imagine you have well configured environment variables and the sentyDSN is ok ....
Please check from your backend.js file a manual captureException or captureMessage

import {
  captureException as captureExceptionToSentry,
  captureMessage as captureMessageToSentry,
} from '@sentry/electron'

  captureExceptionToSentry('some error')
  captureMessageToSentry('some message')

If don't works it's seems its a config data issue 😄

@mehrdadmms
Copy link

Thank you @ajmasia I see it is working now.
I still don't get my errors in sentry but I think there's another problem.
I was creating errors in other parts of the code (not in background.js) and most of our code is imported in preload and sentry doesn't capture errors that are happening in preload

@ajmasia
Copy link
Author

ajmasia commented Oct 6, 2021

Thank you @ajmasia I see it is working now. I still don't get my errors in sentry but I think there's another problem. I was creating errors in other parts of the code (not in background.js) and most of our code is imported in preload and sentry doesn't capture errors that are happening in preload
💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment