-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Normalize module path in main process
- Loading branch information
Showing
13 changed files
with
1,954 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
{ | ||
"method": "envelope", | ||
"sentryKey": "37f8a2ee37c0409d8970bc7559c7c7e4", | ||
"appId": "277345", | ||
"data": { | ||
"sdk": { | ||
"name": "sentry.javascript.electron", | ||
"packages": [ | ||
{ | ||
"name": "npm:@sentry/electron", | ||
"version": "{{version}}" | ||
} | ||
], | ||
"version": "{{version}}" | ||
}, | ||
"contexts": { | ||
"app": { | ||
"app_name": "webpack-main-process", | ||
"app_version": "1.0.0", | ||
"app_start_time": "{{time}}" | ||
}, | ||
"browser": { | ||
"name": "Chrome" | ||
}, | ||
"chrome": { | ||
"name": "Chrome", | ||
"type": "runtime", | ||
"version": "{{version}}" | ||
}, | ||
"device": { | ||
"arch": "{{arch}}", | ||
"family": "Desktop", | ||
"memory_size": 0, | ||
"free_memory": 0, | ||
"processor_count": 0, | ||
"processor_frequency": 0, | ||
"cpu_description": "{{cpu}}", | ||
"screen_resolution":"{{screen}}", | ||
"screen_density": 1, | ||
"language": "{{language}}" | ||
}, | ||
"node": { | ||
"name": "Node", | ||
"type": "runtime", | ||
"version": "{{version}}" | ||
}, | ||
"os": { | ||
"name": "{{platform}}", | ||
"version": "{{version}}" | ||
}, | ||
"runtime": { | ||
"name": "Electron", | ||
"version": "{{version}}" | ||
} | ||
}, | ||
"release": "[email protected]", | ||
"environment": "development", | ||
"user": { | ||
"ip_address": "{{auto}}", | ||
"id": "abc-123" | ||
}, | ||
"debug_meta": { | ||
"images": [ | ||
{ | ||
"code_file": "app:///dist/main.js", | ||
"type": "sourcemap" | ||
} | ||
] | ||
}, | ||
"exception": { | ||
"values": [ | ||
{ | ||
"type": "Error", | ||
"value": "Some main error", | ||
"stacktrace": { | ||
"frames": [ | ||
{ | ||
"colno": 0, | ||
"filename": "app:///dist/main.js", | ||
"function": "{{function}}", | ||
"in_app": true, | ||
"lineno": 0, | ||
"module": "main" | ||
} | ||
] | ||
}, | ||
"mechanism": { | ||
"handled": true, | ||
"type": "generic" | ||
} | ||
} | ||
] | ||
}, | ||
"level": "fatal", | ||
"event_id": "{{id}}", | ||
"platform": "node", | ||
"timestamp": 0, | ||
"breadcrumbs": [ | ||
{ | ||
"timestamp": 0, | ||
"category": "electron", | ||
"message": "app.will-finish-launching", | ||
"type": "ui" | ||
}, | ||
{ | ||
"timestamp": 0, | ||
"category": "electron", | ||
"message": "app.ready", | ||
"type": "ui" | ||
}, | ||
{ | ||
"timestamp": 0, | ||
"category": "electron", | ||
"message": "app.session-created", | ||
"type": "ui" | ||
}, | ||
{ | ||
"timestamp": 0, | ||
"category": "electron", | ||
"message": "app.web-contents-created", | ||
"type": "ui" | ||
}, | ||
{ | ||
"timestamp": 0, | ||
"category": "electron", | ||
"message": "app.browser-window-created", | ||
"type": "ui" | ||
}, | ||
{ | ||
"timestamp": 0, | ||
"category": "electron", | ||
"message": "renderer.dom-ready", | ||
"type": "ui" | ||
} | ||
], | ||
"tags": { | ||
"event.environment": "javascript", | ||
"event.origin": "electron", | ||
"event.process": "browser", | ||
"event_type": "javascript" | ||
} | ||
} | ||
} |
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,20 @@ | ||
{ | ||
"name": "webpack-main-process", | ||
"version": "1.0.0", | ||
"scripts": { | ||
"start": "electron .", | ||
"build": "webpack" | ||
}, | ||
"main": "dist/main.js", | ||
"devDependencies": { | ||
"@sentry/webpack-plugin": "^2.2.0", | ||
"csp-html-webpack-plugin": "^5.1.0", | ||
"html-webpack-plugin": "^5.3.2", | ||
"warnings-to-errors-webpack-plugin": "^2.0.1", | ||
"webpack": "^5.48.0", | ||
"webpack-cli": "^4.7.2" | ||
}, | ||
"dependencies": { | ||
"@sentry/electron": "3.0.0" | ||
} | ||
} |
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,4 @@ | ||
description: Webpack app with error in main process | ||
command: yarn && yarn build | ||
condition: supportsContextIsolation && supportsSandbox | ||
timeout: 120 |
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,36 @@ | ||
import * as path from 'path'; | ||
import * as url from 'url'; | ||
|
||
import { app, BrowserWindow } from 'electron'; | ||
// eslint-disable-next-line import/no-unresolved | ||
import { init } from '@sentry/electron'; | ||
|
||
init({ | ||
dsn: '__DSN__', | ||
debug: true, | ||
autoSessionTracking: false, | ||
onFatalError: () => {}, | ||
}); | ||
|
||
app.on('ready', () => { | ||
const window = new BrowserWindow({ | ||
show: false, | ||
webPreferences: { | ||
nodeIntegration: false, | ||
contextIsolation: true, | ||
sandbox: true, | ||
}, | ||
}); | ||
|
||
window.loadURL( | ||
url.format({ | ||
pathname: path.join(__dirname, 'index.html'), | ||
protocol: 'file:', | ||
slashes: true, | ||
}), | ||
); | ||
|
||
setTimeout(() => { | ||
throw new Error('Some main error'); | ||
}, 500); | ||
}); |
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,10 @@ | ||
// eslint-disable-next-line import/no-unresolved | ||
import { init, configureScope } from '@sentry/electron'; | ||
|
||
init({ | ||
debug: true, | ||
}); | ||
|
||
configureScope((scope) => { | ||
scope.setUser({ id: 'abc-123' }); | ||
}); |
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,51 @@ | ||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const CspHtmlWebpackPlugin = require('csp-html-webpack-plugin'); | ||
const WarningsToErrorsPlugin = require('warnings-to-errors-webpack-plugin'); | ||
const { sentryWebpackPlugin } = require('@sentry/webpack-plugin'); | ||
|
||
const sentryWebpackPluginOptions = { | ||
authToken: 'some invalid auth token', | ||
org: 'some invalid org', | ||
project: 'some invalid project', | ||
telemetry: false, | ||
sourcemaps: { | ||
assets: [], // no assets to upload - we just care about injecting debug IDs | ||
}, | ||
release: { | ||
inject: false, | ||
}, | ||
errorHandler() { | ||
// do nothing on errors :) | ||
// They will happen because of the invalid auth token | ||
}, | ||
}; | ||
|
||
module.exports = [ | ||
{ | ||
mode: 'production', | ||
entry: './src/main.js', | ||
target: 'electron-main', | ||
output: { | ||
libraryTarget: 'commonjs2', | ||
filename: 'main.js', | ||
}, | ||
plugins: [new WarningsToErrorsPlugin(), sentryWebpackPlugin(sentryWebpackPluginOptions)], | ||
}, | ||
{ | ||
mode: 'production', | ||
entry: './src/renderer.js', | ||
target: 'web', | ||
output: { | ||
filename: 'renderer.js', | ||
}, | ||
plugins: [ | ||
new HtmlWebpackPlugin(), | ||
new WarningsToErrorsPlugin(), | ||
new CspHtmlWebpackPlugin({ | ||
'default-src': "'self'", | ||
'script-src': "'self'", | ||
}), | ||
sentryWebpackPlugin(sentryWebpackPluginOptions), | ||
], | ||
}, | ||
]; |
Oops, something went wrong.