Skip to content

Commit

Permalink
Set GPU info in Sentry context. (#79)
Browse files Browse the repository at this point in the history
* Get GPU information for Sentry.

* Set GPU in sentry error context.

* Set all available GPU as context.

* Prettier.
  • Loading branch information
robinjhuang authored Oct 14, 2024
1 parent 40a1b38 commit a5693f2
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"jest": "^29.7.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"systeminformation": "^5.23.5",
"tar": "^7.4.3",
"update-electron-app": "^3.0.0"
}
Expand Down
24 changes: 24 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import * as Sentry from '@sentry/electron/main';

import { updateElectronApp, UpdateSourceType } from 'update-electron-app';
import * as net from 'net';
import { graphics } from 'systeminformation';

log.initialize();
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
Expand Down Expand Up @@ -69,6 +70,29 @@ if (!gotTheLock) {
],
});

graphics()
.then((graphicsInfo) => {
log.info('GPU Info: ', graphicsInfo);

const gpuInfo = graphicsInfo.controllers.map((gpu, index) => ({
[`gpu_${index}`]: {
vendor: gpu.vendor,
model: gpu.model,
vram: gpu.vram,
driver: gpu.driverVersion,
},
}));

// Combine all GPU info into a single object
const allGpuInfo = Object.assign({}, ...gpuInfo);
log.info('GPU Info: ', allGpuInfo);
// Set Sentry context with all GPU information
Sentry.setContext('gpus', allGpuInfo);
})
.catch((e) => {
log.error('Error getting GPU info: ', e);
});

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
Expand Down
11 changes: 11 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5849,6 +5849,7 @@ __metadata:
react: "npm:^18.3.1"
react-dom: "npm:^18.3.1"
rimraf: "npm:^6.0.1"
systeminformation: "npm:^5.23.5"
tar: "npm:^7.4.3"
ts-jest: "npm:^29.2.5"
ts-node: "npm:^10.0.0"
Expand Down Expand Up @@ -12304,6 +12305,16 @@ __metadata:
languageName: node
linkType: hard

"systeminformation@npm:^5.23.5":
version: 5.23.5
resolution: "systeminformation@npm:5.23.5"
bin:
systeminformation: lib/cli.js
checksum: 10c0/849283b2886c46ff5e79594e939c87202b5283b8aa16cd0d665c595781dba51913060728bae95b94837b78c3a515a0f00ab0a0471604990c5c778f555bd075ea
conditions: (os=darwin | os=linux | os=win32 | os=freebsd | os=openbsd | os=netbsd | os=sunos | os=android)
languageName: node
linkType: hard

"tar@npm:^6.0.5, tar@npm:^6.1.11, tar@npm:^6.1.2, tar@npm:^6.2.1":
version: 6.2.1
resolution: "tar@npm:6.2.1"
Expand Down

0 comments on commit a5693f2

Please sign in to comment.