-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initialize Sentry after checking config file
- Loading branch information
Showing
9 changed files
with
96 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,32 @@ | ||
/* global module */ | ||
const { init } = require('@sentry/electron') | ||
const isDev = require('electron-is-dev') | ||
const log = require('electron-log') | ||
|
||
const { name } = require('../../package.json') | ||
const { getConfig } = require('../utils/config') | ||
|
||
const initializeSentry = async () => { | ||
log.info('Initializing Sentry in main...') | ||
try { | ||
const config = await getConfig() | ||
if (config && config.hasOwnProperty('advanced') | ||
&& config.advanced.send_crash_reports === true | ||
) { | ||
init({ | ||
enabled: process.env.NODE_ENV === 'production', | ||
dsn: 'https://[email protected]/1210892', | ||
environment: isDev ? 'development' : 'production', | ||
debug: isDev, | ||
appName: name | ||
}) | ||
log.info('Sentry initialized in main.') | ||
} else { | ||
log.debug('Crash reporting not enabled in config. Sentry not initialized in main.') | ||
} | ||
} catch (e) { | ||
log.error('Initializing Sentry failed: ', e) | ||
} | ||
} | ||
|
||
init({ | ||
enabled: process.env.NODE_ENV === 'production', | ||
dsn: 'https://[email protected]/1210892', | ||
environment: isDev ? 'development' : 'production', | ||
debug: isDev, | ||
appName: name | ||
}) | ||
module.exports = initializeSentry |
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,32 +1,48 @@ | ||
import * as Sentry from '@sentry/node' | ||
import { RewriteFrames } from '@sentry/integrations' | ||
// import { ipcRenderer } from 'electron' | ||
import log from 'electron-log' | ||
|
||
export const init = () => { | ||
if (process.env.NEXT_PUBLIC_SENTRY_DSN) { | ||
const integrations = [] | ||
if (process.env.NEXT_IS_SERVER === 'true') { | ||
// For Node.js, rewrite Error.stack to use relative paths, so that source | ||
// maps starting with ~/_next map to files in Error.stack with path | ||
// app:///_next | ||
integrations.push( | ||
new RewriteFrames({ | ||
iteratee: (frame) => { | ||
frame.filename = frame.filename.replace( | ||
__dirname, | ||
'app:///' | ||
) | ||
frame.filename = frame.filename.replace('.next', '_next') | ||
return frame | ||
}, | ||
export const init = async () => { | ||
try { | ||
const { ipcRenderer } = require('electron') | ||
const config = await ipcRenderer.invoke('get-fresh-config') | ||
if (config && config.hasOwnProperty('advanced') | ||
&& config.advanced.send_crash_reports === true | ||
) { | ||
log.info('Initializing Sentry in renderer...') | ||
if (process.env.NEXT_PUBLIC_SENTRY_DSN) { | ||
const integrations = [] | ||
if (process.env.NEXT_IS_SERVER === 'true') { | ||
// For Node.js, rewrite Error.stack to use relative paths, so that source | ||
// maps starting with ~/_next map to files in Error.stack with path | ||
// app:///_next | ||
integrations.push( | ||
new RewriteFrames({ | ||
iteratee: (frame) => { | ||
frame.filename = frame.filename.replace( | ||
__dirname, | ||
'app:///' | ||
) | ||
frame.filename = frame.filename.replace('.next', '_next') | ||
return frame | ||
}, | ||
}) | ||
) | ||
} | ||
|
||
Sentry.init({ | ||
enabled: process.env.NODE_ENV === 'production', | ||
integrations, | ||
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, | ||
release: process.env.NEXT_PUBLIC_COMMIT_SHA, | ||
}) | ||
) | ||
log.info('Sentry initialized in renderer.') | ||
} | ||
} else { | ||
log.debug('Crash reporting not enabled in config. Sentry not initialized in renderer.') | ||
} | ||
|
||
Sentry.init({ | ||
enabled: process.env.NODE_ENV === 'production', | ||
integrations, | ||
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, | ||
release: process.env.NEXT_PUBLIC_COMMIT_SHA, | ||
}) | ||
} catch (e) { | ||
log.error('Initializing Sentry failed: ', e) | ||
} | ||
} |
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 |
---|---|---|
|
@@ -6141,10 +6141,10 @@ electron-localshortcut@^3.1.0: | |
keyboardevent-from-electron-accelerator "^2.0.0" | ||
keyboardevents-areequal "^0.2.1" | ||
|
||
electron-log@^3.0.7: | ||
version "3.0.8" | ||
resolved "https://registry.yarnpkg.com/electron-log/-/electron-log-3.0.8.tgz#ea672dc40b560143ed5d887eff1ff1904fe9ef71" | ||
integrity sha512-B9+eJ8z3UbDnWEz+G33SIJvEDeKLznHEV4sCu6bR31KuOdp3dYN046QBWbLNsvKU+lzFI6eOi+xNCpNHZvatiw== | ||
electron-log@^4.3.1: | ||
version "4.3.1" | ||
resolved "https://registry.yarnpkg.com/electron-log/-/electron-log-4.3.1.tgz#1405fef9d4e6964a5fdb8790a69163aa237ffe91" | ||
integrity sha512-S/0CMjYjgyWUsZ3d27VvErPaI5W4oILp4jfeCuN4DhDqrJW6jKRUD2PxFfTdeZEIjM7+fttGg7A61rPcAcZC1w== | ||
|
||
[email protected]: | ||
version "3.1.5" | ||
|