Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
timfish committed Jan 9, 2025
1 parent fe57c22 commit 3b6d3a5
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 0 deletions.
84 changes: 84 additions & 0 deletions test/e2e/test-apps/native-sentry/unknown/event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"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": "native-sentry-unknown",
"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
},
"culture": {
"locale": "{{locale}}",
"timezone": "{{timezone}}"
},
"node": {
"name": "Node",
"type": "runtime",
"version": "{{version}}"
},
"os": {
"name": "{{platform}}",
"version": "{{version}}"
},
"runtime": {
"name": "Electron",
"version": "{{version}}"
}
},
"release": "[email protected]",
"environment": "development",
"event_id": "{{id}}",
"timestamp": 0,
"breadcrumbs": [
{
"category": "console",
"level": "log",
"message": "main process breadcrumb from second run"
}
],
"tags": {
"event.environment": "native",
"event.origin": "electron",
"event.process": "unknown",
"app-run": "second"
}
},
"attachments": [
{
"length": 12004,
"filename": "0dc9e285-df8d-47b7-8147-85308b54065a.dmp",
"attachment_type": "event.minidump"
}
]
}
8 changes: 8 additions & 0 deletions test/e2e/test-apps/native-sentry/unknown/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "native-sentry-unknown",
"version": "1.0.0",
"main": "src/main.js",
"dependencies": {
"@sentry/electron": "5.6.0"
}
}
5 changes: 5 additions & 0 deletions test/e2e/test-apps/native-sentry/unknown/recipe.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description: Native Unknown Crash
category: Native (Sentry Uploader)
command: yarn
condition: usesCrashpad
runTwice: true
15 changes: 15 additions & 0 deletions test/e2e/test-apps/native-sentry/unknown/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
</head>
<body>
<script>
const { init } = require('@sentry/electron/renderer');

init({
debug: true,
});
</script>
</body>
</html>
48 changes: 48 additions & 0 deletions test/e2e/test-apps/native-sentry/unknown/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const path = require('path');
const { writeFileSync } = require('fs');

const { app, BrowserWindow } = require('electron');
const { init, getCurrentScope } = require('@sentry/electron/main');

const VALID_LOOKING_MINIDUMP = Buffer.from(`MDMP${'X'.repeat(12000)}`);

const minidumpPath = path.join(
app.getPath('crashDumps'),
process.platform === 'win32' ? 'reports' : 'completed',
'0dc9e285-df8d-47b7-8147-85308b54065a.dmp'
);

init({
dsn: '__DSN__',
debug: true,
autoSessionTracking: false,
onFatalError: () => {},
});

getCurrentScope().setTag('app-run', process.env.APP_FIRST_RUN ? 'first' : 'second');

app.on('ready', () => {
const mainWindow = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
});

mainWindow.loadFile(path.join(__dirname, 'index.html'));

if (process.env.APP_FIRST_RUN) {
console.log('main process breadcrumb from first crashing run');

setTimeout(() => {
writeFileSync(minidumpPath, VALID_LOOKING_MINIDUMP);

setTimeout(() => {
process.exit();
});
}, 2000);
} else {
console.log('main process breadcrumb from second run');
}
});

0 comments on commit 3b6d3a5

Please sign in to comment.