Skip to content

Commit 7f69b78

Browse files
committed
Add a script to send debug symbols to Sentry
1 parent 6a982fe commit 7f69b78

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed

update-sentry-symbols.js

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Taken straight from Sentry: https://github.com/getsentry/sentry-wizard/blob/master/scripts/Electron/symbols.js
5+
* This should be run (with @sentry/cli & electron-download installed) every time Electron is updated.
6+
*/
7+
8+
let SentryCli;
9+
let download;
10+
11+
try {
12+
SentryCli = require('@sentry/cli');
13+
download = require('electron-download');
14+
} catch (e) {
15+
console.error('ERROR: Missing required packages, please run:');
16+
console.error('npm install --save-dev @sentry/cli electron-download');
17+
process.exit(1);
18+
}
19+
20+
const VERSION = /\bv?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-z-]+(?:\.[\da-z-]+)*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?\b/i;
21+
const SYMBOL_CACHE_FOLDER = '.electron-symbols';
22+
const package = require('./package.json');
23+
const sentryCli = new SentryCli('./sentry.properties');
24+
25+
async function main() {
26+
let version = getElectronVersion();
27+
if (!version) {
28+
console.error('Cannot detect electron version, check package.json');
29+
return;
30+
}
31+
32+
console.log('We are starting to download all possible electron symbols');
33+
console.log('We need it in order to symbolicate native crashes');
34+
console.log(
35+
'This step is only needed once whenever you update your electron version',
36+
);
37+
console.log('Just call this script again it should do everything for you.');
38+
39+
let zipPath = await downloadSymbols({
40+
version,
41+
platform: 'darwin',
42+
arch: 'x64',
43+
dsym: true,
44+
});
45+
await sentryCli.execute(['upload-dif', '-t', 'dsym', zipPath], true);
46+
47+
zipPath = await downloadSymbols({
48+
version,
49+
platform: 'win32',
50+
arch: 'ia32',
51+
symbols: true,
52+
});
53+
await sentryCli.execute(['upload-dif', '-t', 'breakpad', zipPath], true);
54+
55+
zipPath = await downloadSymbols({
56+
version,
57+
platform: 'win32',
58+
arch: 'x64',
59+
symbols: true,
60+
});
61+
await sentryCli.execute(['upload-dif', '-t', 'breakpad', zipPath], true);
62+
63+
zipPath = await downloadSymbols({
64+
version,
65+
platform: 'linux',
66+
arch: 'x64',
67+
symbols: true,
68+
});
69+
await sentryCli.execute(['upload-dif', '-t', 'breakpad', zipPath], true);
70+
71+
console.log('Finished downloading and uploading to Sentry');
72+
console.log(`Feel free to delete the ${SYMBOL_CACHE_FOLDER}`);
73+
}
74+
75+
function getElectronVersion() {
76+
if (!package) {
77+
return false;
78+
}
79+
80+
let electronVersion =
81+
(package.dependencies && package.dependencies.electron) ||
82+
(package.devDependencies && package.devDependencies.electron);
83+
84+
if (!electronVersion) {
85+
return false;
86+
}
87+
88+
const matches = VERSION.exec(electronVersion);
89+
return matches ? matches[0] : false;
90+
}
91+
92+
async function downloadSymbols(options) {
93+
return new Promise((resolve, reject) => {
94+
download(
95+
{
96+
...options,
97+
cache: SYMBOL_CACHE_FOLDER,
98+
},
99+
(err, zipPath) => {
100+
if (err) {
101+
reject(err);
102+
} else {
103+
resolve(zipPath);
104+
}
105+
},
106+
);
107+
});
108+
}
109+
110+
main().catch(e => console.error(e));

0 commit comments

Comments
 (0)