-
-
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.
- Loading branch information
Showing
56 changed files
with
744 additions
and
335 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Webpack 5 app with contextIsolation and sandbox with preload | ||
|
||
| Setting | Value | | ||
| ------------- | ------------------------ | | ||
| Build Command | yarn && yarn build | | ||
| Run Condition | supportsContextIsolation | | ||
| Timeout | 120s | |
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,139 @@ | ||
{ | ||
"method": "envelope", | ||
"sentryKey": "37f8a2ee37c0409d8970bc7559c7c7e4", | ||
"appId": "277345", | ||
"dumpFile": false, | ||
"data": { | ||
"sdk": { | ||
"name": "sentry.javascript.electron", | ||
"packages": [ | ||
{ | ||
"name": "npm:@sentry/electron", | ||
"version": "{{version}}" | ||
} | ||
], | ||
"version": "{{version}}" | ||
}, | ||
"contexts": { | ||
"app": { | ||
"app_name": "webpack-context-isolation-preload", | ||
"app_version": "1.0.0" | ||
}, | ||
"browser": { | ||
"name": "Chrome" | ||
}, | ||
"chrome": { | ||
"name": "Chrome", | ||
"type": "runtime", | ||
"version": "{{version}}" | ||
}, | ||
"device": { | ||
"arch": "{{arch}}", | ||
"family": "Desktop" | ||
}, | ||
"node": { | ||
"name": "Node", | ||
"type": "runtime", | ||
"version": "{{version}}" | ||
}, | ||
"os": { | ||
"name": "{{platform}}", | ||
"version": "{{version}}" | ||
}, | ||
"runtime": { | ||
"name": "Electron", | ||
"version": "{{version}}" | ||
}, | ||
"electron": { | ||
"crashed_process": "WebContents[1]", | ||
"crashed_url": "app:///dist/index.html" | ||
} | ||
}, | ||
"release": "webpack-context-isolation-preload@1.0.0", | ||
"environment": "production", | ||
"user": { | ||
"ip_address": "{{auto}}", | ||
"id": "abc-123" | ||
}, | ||
"exception": { | ||
"values": [ | ||
{ | ||
"type": "Error", | ||
"value": "Some renderer error", | ||
"stacktrace": { | ||
"frames": [ | ||
{ | ||
"colno": 0, | ||
"filename": "app:///dist/renderer.js", | ||
"function": "{{function}}", | ||
"in_app": true, | ||
"lineno": 0 | ||
}, | ||
{ | ||
"colno": 0, | ||
"filename": "app:///dist/renderer.js", | ||
"function": "{{function}}", | ||
"in_app": true, | ||
"lineno": 0 | ||
} | ||
] | ||
}, | ||
"mechanism": { | ||
"handled": true, | ||
"type": "generic" | ||
} | ||
} | ||
] | ||
}, | ||
"level": "error", | ||
"event_id": "{{id}}", | ||
"platform": "javascript", | ||
"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": "WebContents[1].dom-ready", | ||
"type": "ui" | ||
} | ||
], | ||
"request": { | ||
"url": "app:///dist/index.html" | ||
}, | ||
"tags": { | ||
"event.environment": "javascript", | ||
"event.origin": "electron", | ||
"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,18 @@ | ||
{ | ||
"name": "webpack-context-isolation-preload", | ||
"version": "1.0.0", | ||
"scripts": { | ||
"start": "electron .", | ||
"build": "webpack" | ||
}, | ||
"main": "dist/main.js", | ||
"devDependencies": { | ||
"html-webpack-plugin": "^5.3.2", | ||
"webpack": "^5.48.0", | ||
"webpack-cli": "^4.7.2", | ||
"warnings-to-errors-webpack-plugin": "^2.0.1" | ||
}, | ||
"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,33 @@ | ||
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: { | ||
preload: path.join(__dirname, 'preload.js'), | ||
nodeIntegration: false, | ||
contextIsolation: true, | ||
sandbox: true, | ||
}, | ||
}); | ||
|
||
window.loadURL( | ||
url.format({ | ||
pathname: path.join(__dirname, 'index.html'), | ||
protocol: 'file:', | ||
slashes: true, | ||
}), | ||
); | ||
}); |
14 changes: 14 additions & 0 deletions
14
examples/webpack-context-isolation-preload/src/renderer.js
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,14 @@ | ||
// eslint-disable-next-line import/no-unresolved | ||
import { init, configureScope } from '@sentry/electron'; | ||
|
||
init({ | ||
debug: true, | ||
}); | ||
|
||
configureScope((scope) => { | ||
scope.setUser({ id: 'abc-123' }); | ||
}); | ||
|
||
setTimeout(() => { | ||
throw new Error('Some renderer error'); | ||
}, 500); |
33 changes: 33 additions & 0 deletions
33
examples/webpack-context-isolation-preload/webpack.config.js
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,33 @@ | ||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const WarningsToErrorsPlugin = require('warnings-to-errors-webpack-plugin'); | ||
|
||
module.exports = [ | ||
{ | ||
mode: 'production', | ||
entry: './src/main.js', | ||
target: 'electron-main', | ||
output: { | ||
libraryTarget: 'commonjs2', | ||
filename: 'main.js', | ||
}, | ||
plugins: [new WarningsToErrorsPlugin()], | ||
}, | ||
{ | ||
mode: 'production', | ||
entry: '@sentry/electron/preload', | ||
target: 'electron-preload', | ||
output: { | ||
filename: 'preload.js', | ||
}, | ||
plugins: [new WarningsToErrorsPlugin()], | ||
}, | ||
{ | ||
mode: 'production', | ||
entry: './src/renderer.js', | ||
target: 'web', | ||
output: { | ||
filename: 'renderer.js', | ||
}, | ||
plugins: [new HtmlWebpackPlugin(), new WarningsToErrorsPlugin()], | ||
}, | ||
]; |
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
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** Ways to communicate between the renderer and main process */ | ||
export enum IPCMode { | ||
/** Configures Electron IPC to receive messages from renderers */ | ||
Classic = 1, | ||
/** Configures Electron protocol module to receive messages from renderers */ | ||
Protocol = 2, | ||
/** | ||
* Configures both methods for best compatibility. | ||
* | ||
* Renderers favour IPC but fall back to protocol if IPC has not | ||
* been configured in a preload script | ||
*/ | ||
Both = 3, | ||
} |
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
Oops, something went wrong.