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