diff --git a/src/main/sessions.ts b/src/main/sessions.ts index 9037a4de..0c9e76d2 100644 --- a/src/main/sessions.ts +++ b/src/main/sessions.ts @@ -158,11 +158,10 @@ export function sessionCrashed(): void { logger.log('Setting session as crashed'); const errors = session.errors + 1; updateSession(session, { status: 'crashed', errors }); + captureSession(); } else { logger.log('Session already ended'); } - - captureSession(); } /** Sets the current session as ANR */ diff --git a/test/e2e/test-apps/sessions/native-crash-renderer-multiple/event.json b/test/e2e/test-apps/sessions/native-crash-renderer-multiple/event.json new file mode 100644 index 00000000..87745d54 --- /dev/null +++ b/test/e2e/test-apps/sessions/native-crash-renderer-multiple/event.json @@ -0,0 +1,73 @@ +{ + "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": "session-native-crash-renderer-multiple", + "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}}" + }, + "electron": { + "crashed_url": "app:///src/index.html" + } + }, + "release": "session-native-crash-renderer-multiple@1.0.0", + "environment": "development", + "event_id": "{{id}}", + "timestamp": 0, + "breadcrumbs": [], + "tags": { + "event.environment": "native", + "event.origin": "electron", + "event.process": "renderer" + } + } +} diff --git a/test/e2e/test-apps/sessions/native-crash-renderer-multiple/event2.json b/test/e2e/test-apps/sessions/native-crash-renderer-multiple/event2.json new file mode 100644 index 00000000..87745d54 --- /dev/null +++ b/test/e2e/test-apps/sessions/native-crash-renderer-multiple/event2.json @@ -0,0 +1,73 @@ +{ + "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": "session-native-crash-renderer-multiple", + "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}}" + }, + "electron": { + "crashed_url": "app:///src/index.html" + } + }, + "release": "session-native-crash-renderer-multiple@1.0.0", + "environment": "development", + "event_id": "{{id}}", + "timestamp": 0, + "breadcrumbs": [], + "tags": { + "event.environment": "native", + "event.origin": "electron", + "event.process": "renderer" + } + } +} diff --git a/test/e2e/test-apps/sessions/native-crash-renderer-multiple/package.json b/test/e2e/test-apps/sessions/native-crash-renderer-multiple/package.json new file mode 100644 index 00000000..93bafc08 --- /dev/null +++ b/test/e2e/test-apps/sessions/native-crash-renderer-multiple/package.json @@ -0,0 +1,8 @@ +{ + "name": "session-native-crash-renderer-multiple", + "version": "1.0.0", + "main": "src/main.js", + "dependencies": { + "@sentry/electron": "3.0.0" + } +} diff --git a/test/e2e/test-apps/sessions/native-crash-renderer-multiple/recipe.yml b/test/e2e/test-apps/sessions/native-crash-renderer-multiple/recipe.yml new file mode 100644 index 00000000..f358b362 --- /dev/null +++ b/test/e2e/test-apps/sessions/native-crash-renderer-multiple/recipe.yml @@ -0,0 +1,3 @@ +description: Session with Multiple Native Renderer Crashes +category: Sessions +command: yarn diff --git a/test/e2e/test-apps/sessions/native-crash-renderer-multiple/session-crash.json b/test/e2e/test-apps/sessions/native-crash-renderer-multiple/session-crash.json new file mode 100644 index 00000000..e4c8a2da --- /dev/null +++ b/test/e2e/test-apps/sessions/native-crash-renderer-multiple/session-crash.json @@ -0,0 +1,17 @@ +{ + "appId": "277345", + "sentryKey": "37f8a2ee37c0409d8970bc7559c7c7e4", + "method": "envelope", + "data": { + "sid": "{{id}}", + "init": false, + "started": 0, + "timestamp": 0, + "status": "crashed", + "errors": 1, + "duration": 0, + "attrs": { + "release": "session-native-crash-renderer-multiple@1.0.0" + } + } +} diff --git a/test/e2e/test-apps/sessions/native-crash-renderer-multiple/session-next.json b/test/e2e/test-apps/sessions/native-crash-renderer-multiple/session-next.json new file mode 100644 index 00000000..45593bf1 --- /dev/null +++ b/test/e2e/test-apps/sessions/native-crash-renderer-multiple/session-next.json @@ -0,0 +1,17 @@ +{ + "appId": "277345", + "sentryKey": "37f8a2ee37c0409d8970bc7559c7c7e4", + "method": "envelope", + "data": { + "sid": "{{id}}", + "init": false, + "started": 0, + "timestamp": 0, + "status": "ok", + "errors": 0, + "duration": 0, + "attrs": { + "release": "session-native-crash-renderer-multiple@1.0.0" + } + } +} diff --git a/test/e2e/test-apps/sessions/native-crash-renderer-multiple/session-start.json b/test/e2e/test-apps/sessions/native-crash-renderer-multiple/session-start.json new file mode 100644 index 00000000..a93115f0 --- /dev/null +++ b/test/e2e/test-apps/sessions/native-crash-renderer-multiple/session-start.json @@ -0,0 +1,17 @@ +{ + "appId": "277345", + "sentryKey": "37f8a2ee37c0409d8970bc7559c7c7e4", + "method": "envelope", + "data": { + "sid": "{{id}}", + "init": true, + "started": 0, + "timestamp": 0, + "status": "ok", + "errors": 0, + "duration": 0, + "attrs": { + "release": "session-native-crash-renderer-multiple@1.0.0" + } + } +} diff --git a/test/e2e/test-apps/sessions/native-crash-renderer-multiple/src/index.html b/test/e2e/test-apps/sessions/native-crash-renderer-multiple/src/index.html new file mode 100644 index 00000000..6f01bb92 --- /dev/null +++ b/test/e2e/test-apps/sessions/native-crash-renderer-multiple/src/index.html @@ -0,0 +1,19 @@ + + + + + + + + + diff --git a/test/e2e/test-apps/sessions/native-crash-renderer-multiple/src/main.js b/test/e2e/test-apps/sessions/native-crash-renderer-multiple/src/main.js new file mode 100644 index 00000000..0248a45e --- /dev/null +++ b/test/e2e/test-apps/sessions/native-crash-renderer-multiple/src/main.js @@ -0,0 +1,35 @@ +const path = require('path'); + +const { app, BrowserWindow } = require('electron'); +const { init, mainProcessSessionIntegration } = require('@sentry/electron/main'); + +init({ + dsn: '__DSN__', + debug: true, + integrations: [mainProcessSessionIntegration({ sendOnCreate: true })], + onFatalError: () => {}, +}); + +function createWindow() { + const mainWindow = new BrowserWindow({ + show: false, + webPreferences: { + nodeIntegration: true, + contextIsolation: false, + }, + }); + + mainWindow.loadFile(path.join(__dirname, 'index.html')); +} + +app.on('ready', () => { + createWindow(); +}); + +setTimeout(() => { + createWindow(); +}, 3000); + +setTimeout(() => { + app.quit(); +}, 10000); diff --git a/test/e2e/vitest.config.mts b/test/e2e/vitest.config.mts index 14bf6a08..818926b2 100644 --- a/test/e2e/vitest.config.mts +++ b/test/e2e/vitest.config.mts @@ -6,6 +6,6 @@ export default defineConfig({ retry: process.env.CI ? 3 : 0, disableConsoleIntercept: true, silent: false, - reporters: process.env.CI || process.env.DEBUG ? ['verbose', 'github-actions'] : ['verbose'], + reporters: process.env.DEBUG ? ['basic'] : process.env.CI ? ['verbose', 'github-actions'] : ['verbose'], }, });