forked from exokitxr/exokit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbugsnag.js
executable file
·56 lines (52 loc) · 1.25 KB
/
bugsnag.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
#!/usr/bin/env node
const path = require('path');
const fs = require('fs');
const os = require('os');
const packageJson = require('./package.json');
const bugsnag = require('bugsnag');
const bugsnagApiKey = (() => {
try {
return fs.readFileSync(path.join(__dirname, 'bugsnag.txt'), 'utf8').match(/^(\S*)/)[1];
} catch (err) {
if (err.code !== 'ENOENT') {
console.warn(err.stack);
}
return null;
}
})();
if (bugsnagApiKey) {
bugsnag.register(bugsnagApiKey, {
metaData: {
packageJson,
arch: os.arch(),
cpus: os.cpus(),
endianness: os.endianness(),
homedir: os.homedir(),
hostname: os.hostname(),
loadavg: os.loadavg(),
networkInterfaces: os.networkInterfaces(),
freemem: os.freemem(),
platform: os.platform(),
release: os.release(),
tmpdir: os.tmpdir(),
totalmem: os.totalmem(),
type: os.type(),
uptime: os.uptime(),
userInfo: os.userInfo(),
},
});
}
if (require.main === module) {
const bs = [];
process.stdin.on('data', d => {
bs.push(d);
});
process.stdin.on('end', d => {
const b = Buffer.concat(bs);
const s = b.toString('utf8');
const err = new Error(s);
bugsnag.notify(err, {
stack: s,
});
});
}