feat: add Sentry

This commit is contained in:
Alexis Tyler
2020-09-25 10:04:19 +09:30
parent 2dc1488cec
commit b7bba74e5c
4 changed files with 132 additions and 1 deletions

View File

@@ -3,10 +3,22 @@
* Written by: Alexis Tyler
*/
import os from 'os';
import am from 'am';
import * as Sentry from '@sentry/node';
import { core, loadServer } from '@unraid/core';
import { server } from './server';
// Send errors to server if enabled
Sentry.init({
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 1.0,
release: require('../package.json').short(),
environment: process.env.NODE_ENV,
serverName: os.hostname(),
enabled: Boolean(process.env.SENTRY_DSN)
});
// Boot app
am(async () => {
// Load core
@@ -17,8 +29,11 @@ am(async () => {
}, (error: NodeJS.ErrnoException) => {
// We should only end here if core has an issue loading
// Send last exception to Sentry
Sentry.captureException(error);
// Log last error
console.error(error);
console.error(error.message);
// Kill application
// eslint-disable-next-line unicorn/no-process-exit

View File

@@ -27,6 +27,10 @@ const envs = {
env_debug: {
DEBUG: true
},
env_staging: {
MOTHERSHIP_RELAY_WS_LINK: 'wss://staging.mothership.unraid.net/relay',
SENTRY_DSN: 'https://335a7a44d1a048648a585fc4fa053d65@o427961.ingest.sentry.io/5439629'
},
env_production: {
NODE_ENV: 'production',
PORT: '/var/run/graphql-api.sock'

111
package-lock.json generated
View File

@@ -1293,6 +1293,112 @@
"prop-types": "^15.6.2"
}
},
"@sentry/core": {
"version": "5.24.2",
"resolved": "https://registry.npmjs.org/@sentry/core/-/core-5.24.2.tgz",
"integrity": "sha512-nuAwCGU1l9hgMinl5P/8nIQGRXDP2FI9cJnq5h1qiP/XIOvJkJz2yzBR6nTyqr4vBth0tvxQJbIpDNGd7vHJLg==",
"requires": {
"@sentry/hub": "5.24.2",
"@sentry/minimal": "5.24.2",
"@sentry/types": "5.24.2",
"@sentry/utils": "5.24.2",
"tslib": "^1.9.3"
}
},
"@sentry/hub": {
"version": "5.24.2",
"resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-5.24.2.tgz",
"integrity": "sha512-xmO1Ivvpb5Qr9WgekinuZZlpl9Iw7iPETUe84HQOhUrXf+2gKO+LaUYMMsYSVDwXQEmR6/tTMyOtS6iavldC6w==",
"requires": {
"@sentry/types": "5.24.2",
"@sentry/utils": "5.24.2",
"tslib": "^1.9.3"
}
},
"@sentry/minimal": {
"version": "5.24.2",
"resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-5.24.2.tgz",
"integrity": "sha512-biFpux5bI3R8xiD/Zzvrk1kRE6bqPtfWXmZYAHRtaUMCAibprTKSY9Ta8QYHynOAEoJ5Akedy6HUsEkK5DoZfA==",
"requires": {
"@sentry/hub": "5.24.2",
"@sentry/types": "5.24.2",
"tslib": "^1.9.3"
}
},
"@sentry/node": {
"version": "5.24.2",
"resolved": "https://registry.npmjs.org/@sentry/node/-/node-5.24.2.tgz",
"integrity": "sha512-ddfU2tLTvhnY+NqzLIA/gxMt/uxq7R204Nb2J5qqE0WAgbh0dtylNAzfKZTizLdbZfRnpeISmd+CBILh3tavog==",
"requires": {
"@sentry/core": "5.24.2",
"@sentry/hub": "5.24.2",
"@sentry/tracing": "5.24.2",
"@sentry/types": "5.24.2",
"@sentry/utils": "5.24.2",
"cookie": "^0.4.1",
"https-proxy-agent": "^5.0.0",
"lru_map": "^0.3.3",
"tslib": "^1.9.3"
},
"dependencies": {
"agent-base": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.1.tgz",
"integrity": "sha512-01q25QQDwLSsyfhrKbn8yuur+JNw0H+0Y4JiGIKd3z9aYk/w/2kxD/Upc+t2ZBBSUNff50VjPsSW2YxM8QYKVg==",
"requires": {
"debug": "4"
}
},
"cookie": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz",
"integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA=="
},
"debug": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz",
"integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==",
"requires": {
"ms": "2.1.2"
}
},
"https-proxy-agent": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz",
"integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==",
"requires": {
"agent-base": "6",
"debug": "4"
}
}
}
},
"@sentry/tracing": {
"version": "5.24.2",
"resolved": "https://registry.npmjs.org/@sentry/tracing/-/tracing-5.24.2.tgz",
"integrity": "sha512-1uDgvGGVF8lb3hRXbhNnns+8DBUKjhRKOFR5Z3RExjrDFYTDbHmoNtV73Q12Ra+Iht9HTZnIBOqYD3oSZIbJ0w==",
"requires": {
"@sentry/hub": "5.24.2",
"@sentry/minimal": "5.24.2",
"@sentry/types": "5.24.2",
"@sentry/utils": "5.24.2",
"tslib": "^1.9.3"
}
},
"@sentry/types": {
"version": "5.24.2",
"resolved": "https://registry.npmjs.org/@sentry/types/-/types-5.24.2.tgz",
"integrity": "sha512-HcOK00R0tQG5vzrIrqQ0jC28+z76jWSgQCzXiessJ5SH/9uc6NzdO7sR7K8vqMP2+nweCHckFohC8G0T1DLzuQ=="
},
"@sentry/utils": {
"version": "5.24.2",
"resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-5.24.2.tgz",
"integrity": "sha512-oPGde4tNEDHKk0Cg9q2p0qX649jLDUOwzJXHKpd0X65w3A6eJByDevMr8CSzKV9sesjrUpxqAv6f9WWlz185tA==",
"requires": {
"@sentry/types": "5.24.2",
"tslib": "^1.9.3"
}
},
"@sindresorhus/is": {
"version": "0.14.0",
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz",
@@ -11422,6 +11528,11 @@
"yallist": "^3.0.2"
}
},
"lru_map": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/lru_map/-/lru_map-0.3.3.tgz",
"integrity": "sha1-tcg1G5Rky9dQM1p5ZQoOwOVhGN0="
},
"mailcomposer": {
"version": "3.12.0",
"resolved": "https://registry.npmjs.org/mailcomposer/-/mailcomposer-3.12.0.tgz",

View File

@@ -32,6 +32,7 @@
"dependencies": {
"@apollo/client": "^3.2.0",
"@gridplus/docker-events": "github:OmgImAlexis/docker-events",
"@sentry/node": "^5.24.2",
"@unraid/core": "github:unraid/core",
"accesscontrol": "^2.2.1",
"am": "^1.0.2",