mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-20 02:18:01 +00:00
sentry electron sdk
This commit is contained in:
@@ -22,7 +22,6 @@ export class Application {
|
||||
app.commandLine.appendSwitch('lang', 'EN')
|
||||
|
||||
for (const flag of configData.flags || [['force_discrete_gpu', '0']]) {
|
||||
console.log('Setting Electron flag:', flag.join('='))
|
||||
app.commandLine.appendSwitch(flag[0], flag[1])
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import './sentry'
|
||||
import './lru'
|
||||
import { app, ipcMain, Menu } from 'electron'
|
||||
import { parseArgs } from './cli'
|
||||
@@ -46,7 +47,7 @@ if (argv.d) {
|
||||
electronDebug({
|
||||
isEnabled: true,
|
||||
showDevTools: true,
|
||||
devToolsMode: 'undocked'
|
||||
devToolsMode: 'undocked',
|
||||
})
|
||||
}
|
||||
|
||||
|
15
app/lib/sentry.ts
Normal file
15
app/lib/sentry.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
const { init } = process.type === 'main' ? require('@sentry/electron/dist/main') : require('@sentry/electron/dist/renderer')
|
||||
|
||||
|
||||
const SENTRY_DSN = 'https://4717a0a7ee0b4429bd3a0f06c3d7eec3@sentry.io/181876'
|
||||
let release
|
||||
try {
|
||||
release = require('electron').app.getVersion()
|
||||
} catch {
|
||||
release = require('electron').remote.app.getVersion()
|
||||
}
|
||||
|
||||
init({
|
||||
dsn: SENTRY_DSN,
|
||||
release,
|
||||
})
|
@@ -3,6 +3,7 @@ import { debounceTime } from 'rxjs/operators'
|
||||
import { BrowserWindow, app, ipcMain, Rectangle, screen } from 'electron'
|
||||
import ElectronConfig = require('electron-config')
|
||||
import * as os from 'os'
|
||||
import * as path from 'path'
|
||||
|
||||
import { loadConfig } from './config'
|
||||
|
||||
@@ -46,6 +47,7 @@ export class Window {
|
||||
minHeight: 300,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
preload: path.join(__dirname, 'sentry.js'),
|
||||
},
|
||||
frame: false,
|
||||
show: false,
|
||||
@@ -147,14 +149,14 @@ export class Window {
|
||||
this.window.webContents.send(event, ...args)
|
||||
}
|
||||
|
||||
isDestroyed() {
|
||||
isDestroyed () {
|
||||
return !this.window || this.window.isDestroyed();
|
||||
}
|
||||
|
||||
private setupWindowManagement () {
|
||||
this.window.on('show', () => {
|
||||
this.visible.next(true)
|
||||
this.window.webContents.send('host:window-shown')
|
||||
this.send('host:window-shown')
|
||||
})
|
||||
|
||||
this.window.on('hide', () => {
|
||||
@@ -164,20 +166,20 @@ export class Window {
|
||||
let moveSubscription = new Observable<void>(observer => {
|
||||
this.window.on('move', () => observer.next())
|
||||
}).pipe(debounceTime(250)).subscribe(() => {
|
||||
this.window.webContents.send('host:window-moved')
|
||||
this.send('host:window-moved')
|
||||
})
|
||||
|
||||
this.window.on('closed', () => {
|
||||
moveSubscription.unsubscribe()
|
||||
})
|
||||
|
||||
this.window.on('enter-full-screen', () => this.window.webContents.send('host:window-enter-full-screen'))
|
||||
this.window.on('leave-full-screen', () => this.window.webContents.send('host:window-leave-full-screen'))
|
||||
this.window.on('enter-full-screen', () => this.send('host:window-enter-full-screen'))
|
||||
this.window.on('leave-full-screen', () => this.send('host:window-leave-full-screen'))
|
||||
|
||||
this.window.on('close', event => {
|
||||
if (!this.closing) {
|
||||
event.preventDefault()
|
||||
this.window.webContents.send('host:window-close-request')
|
||||
this.send('host:window-close-request')
|
||||
return
|
||||
}
|
||||
this.windowConfig.set('windowBoundaries', this.windowBounds)
|
||||
|
@@ -6,33 +6,3 @@ import '@fortawesome/fontawesome-free/css/brands.css'
|
||||
import '@fortawesome/fontawesome-free/css/fontawesome.css'
|
||||
import 'ngx-toastr/toastr.css'
|
||||
import './preload.scss'
|
||||
|
||||
import * as Raven from 'raven-js'
|
||||
|
||||
const SENTRY_DSN = 'https://4717a0a7ee0b4429bd3a0f06c3d7eec3@sentry.io/181876'
|
||||
|
||||
Raven.config(
|
||||
SENTRY_DSN,
|
||||
{
|
||||
release: require('electron').remote.app.getVersion(),
|
||||
dataCallback: (data: any) => {
|
||||
const normalize = (filename: string) => {
|
||||
const splitArray = filename.split('/')
|
||||
return splitArray[splitArray.length - 1]
|
||||
}
|
||||
|
||||
data.exception.values[0].stacktrace.frames.forEach((frame: any) => {
|
||||
frame.filename = normalize(frame.filename)
|
||||
})
|
||||
|
||||
data.culprit = data.exception.values[0].stacktrace.frames[0].filename
|
||||
|
||||
return data
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
process.on('uncaughtException' as any, (err) => {
|
||||
Raven.captureException(err as any)
|
||||
console.error(err)
|
||||
})
|
||||
|
@@ -6,6 +6,7 @@ module.exports = {
|
||||
target: 'node',
|
||||
entry: {
|
||||
'index.ignore': 'file-loader?name=index.html!pug-html-loader!' + path.resolve(__dirname, './index.pug'),
|
||||
sentry: path.resolve(__dirname, 'lib/sentry.ts'),
|
||||
preload: path.resolve(__dirname, 'src/entry.preload.ts'),
|
||||
bundle: path.resolve(__dirname, 'src/entry.ts'),
|
||||
},
|
||||
@@ -78,5 +79,8 @@ module.exports = {
|
||||
},
|
||||
plugins: [
|
||||
new webpack.optimize.ModuleConcatenationPlugin(),
|
||||
new webpack.DefinePlugin({
|
||||
'process.type': '"renderer"'
|
||||
}),
|
||||
],
|
||||
}
|
||||
|
@@ -45,5 +45,8 @@ module.exports = {
|
||||
},
|
||||
plugins: [
|
||||
new webpack.optimize.ModuleConcatenationPlugin(),
|
||||
new webpack.DefinePlugin({
|
||||
'process.type': '"main"',
|
||||
}),
|
||||
],
|
||||
}
|
||||
|
Reference in New Issue
Block a user