updated sentry libs from raven to @sentry

This commit is contained in:
Danny Coates 2019-08-09 11:06:21 -07:00
parent 927c981cd7
commit 807ecff471
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
9 changed files with 106 additions and 71 deletions

View File

@ -1,7 +1,7 @@
import 'intl-pluralrules'; import 'intl-pluralrules';
import choo from 'choo'; import choo from 'choo';
import html from 'choo/html'; import html from 'choo/html';
import Raven from 'raven-js'; import * as Sentry from '@sentry/browser';
import { setApiUrlPrefix, getConstants } from '../app/api'; import { setApiUrlPrefix, getConstants } from '../app/api';
import metrics from '../app/metrics'; import metrics from '../app/metrics';
@ -82,7 +82,7 @@ function body(main) {
state.archive = new Archive([], DEFAULTS.EXPIRE_SECONDS); state.archive = new Archive([], DEFAULTS.EXPIRE_SECONDS);
state.storage = storage; state.storage = storage;
state.user = new User(storage, LIMITS); state.user = new User(storage, LIMITS);
state.raven = Raven; state.sentry = Sentry;
}); });
app.use(metrics); app.use(metrics);
app.route('/', body(home)); app.route('/', body(home));

View File

@ -12,7 +12,7 @@ export default function initialState(state, emitter) {
getAsset(name) { getAsset(name) {
return `${state.prefix}/${name}`; return `${state.prefix}/${name}`;
}, },
raven: { sentry: {
captureException: e => { captureException: e => {
console.error('ERROR ' + e + ' ' + e.stack); console.error('ERROR ' + e + ' ' + e.stack);
} }

View File

@ -76,7 +76,7 @@ export default function(state, emitter) {
state.storage.remove(ownedFile.id); state.storage.remove(ownedFile.id);
await ownedFile.del(); await ownedFile.del();
} catch (e) { } catch (e) {
state.raven.captureException(e); state.sentry.captureException(e);
} }
render(); render();
}); });
@ -181,9 +181,10 @@ export default function(state, emitter) {
} else { } else {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.error(err); console.error(err);
state.raven.captureException(err, { state.sentry.withScope(scope => {
duration: err.duration, scope.setExtra('duration', err.duration);
size: err.size scope.setExtra('size', err.size);
state.sentry.captureException(err);
}); });
metrics.stoppedUpload(archive, err.duration); metrics.stoppedUpload(archive, err.duration);
emitter.emit('pushState', '/error'); emitter.emit('pushState', '/error');
@ -264,10 +265,11 @@ export default function(state, emitter) {
state.transfer = null; state.transfer = null;
const location = err.message === '404' ? '/404' : '/error'; const location = err.message === '404' ? '/404' : '/error';
if (location === '/error') { if (location === '/error') {
state.raven.captureException(err, { state.sentry.withScope(scope => {
duration: err.duration, scope.setExtra('duration', err.duration);
size: err.size, scope.setExtra('size', err.size);
progress: err.progress scope.setExtra('progress', err.progress);
state.sentry.captureException(err);
}); });
const duration = Date.now() - start; const duration = Date.now() - start;
metrics.stoppedDownload({ metrics.stoppedDownload({

View File

@ -12,15 +12,15 @@ import pasteManager from './pasteManager';
import storage from './storage'; import storage from './storage';
import metrics from './metrics'; import metrics from './metrics';
import experiments from './experiments'; import experiments from './experiments';
import Raven from 'raven-js'; import * as Sentry from '@sentry/browser';
import './main.css'; import './main.css';
import User from './user'; import User from './user';
import { getTranslator } from './locale'; import { getTranslator } from './locale';
import Archive from './archive'; import Archive from './archive';
import { setTranslate, locale } from './utils'; import { setTranslate, locale } from './utils';
if (navigator.doNotTrack !== '1' && window.RAVEN_CONFIG) { if (navigator.doNotTrack !== '1' && window.SENTRY_CONFIG) {
Raven.config(window.SENTRY_ID, window.RAVEN_CONFIG).install(); Sentry.init(window.SENTRY_CONFIG);
} }
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {
@ -56,7 +56,7 @@ if (process.env.NODE_ENV === 'production') {
capabilities, capabilities,
translate, translate,
storage, storage,
raven: Raven, sentry: Sentry,
user: new User(storage, LIMITS, window.AUTH_CONFIG), user: new User(storage, LIMITS, window.AUTH_CONFIG),
transfer: null, transfer: null,
fileInfo: null fileInfo: null

127
package-lock.json generated
View File

@ -1508,6 +1508,79 @@
"any-observable": "^0.3.0" "any-observable": "^0.3.0"
} }
}, },
"@sentry/browser": {
"version": "5.6.1",
"resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-5.6.1.tgz",
"integrity": "sha512-EtuI3YUIXfSzbF2Z7c5UXcdkcjZj83Y0vj73kMXBxxYsmDkyU+KtJFFvonSUrLILMqYBNZXTgCrfglLfFkl7kA==",
"dev": true,
"requires": {
"@sentry/core": "5.6.1",
"@sentry/types": "5.6.1",
"@sentry/utils": "5.6.1",
"tslib": "^1.9.3"
}
},
"@sentry/core": {
"version": "5.6.1",
"resolved": "https://registry.npmjs.org/@sentry/core/-/core-5.6.1.tgz",
"integrity": "sha512-gK8XfkJIZLsBEQehkr2q2fdHI50B3yo4RXiixSZiNBVIzQ+1z3JcMssDzGwhbY81NHUzHZ7of3oQ4Ab4OGRI/g==",
"requires": {
"@sentry/hub": "5.6.1",
"@sentry/minimal": "5.6.1",
"@sentry/types": "5.6.1",
"@sentry/utils": "5.6.1",
"tslib": "^1.9.3"
}
},
"@sentry/hub": {
"version": "5.6.1",
"resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-5.6.1.tgz",
"integrity": "sha512-m+OhkIV5yTAL3R1+XfCwzUQka0UF/xG4py8sEfPXyYIcoOJ2ZTX+1kQJLy8QQJ4RzOBwZA+DzRKP0cgzPJ3+oQ==",
"requires": {
"@sentry/types": "5.6.1",
"@sentry/utils": "5.6.1",
"tslib": "^1.9.3"
}
},
"@sentry/minimal": {
"version": "5.6.1",
"resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-5.6.1.tgz",
"integrity": "sha512-ercCKuBWHog6aS6SsJRuKhJwNdJ2oRQVWT2UAx1zqvsbHT9mSa8ZRjdPHYOtqY3DoXKk/pLUFW/fkmAnpdMqRw==",
"requires": {
"@sentry/hub": "5.6.1",
"@sentry/types": "5.6.1",
"tslib": "^1.9.3"
}
},
"@sentry/node": {
"version": "5.6.1",
"resolved": "https://registry.npmjs.org/@sentry/node/-/node-5.6.1.tgz",
"integrity": "sha512-8gNjFRrTOG3vu2RpWZnUSxNx6Ui2Dthq2VHeVImt7PYtVaSddlYZvt0xl8L/fJC/TvFZEPfX0d8Is9v8yvsgRQ==",
"requires": {
"@sentry/core": "5.6.1",
"@sentry/hub": "5.6.1",
"@sentry/types": "5.6.1",
"@sentry/utils": "5.6.1",
"cookie": "0.3.1",
"https-proxy-agent": "2.2.1",
"lru_map": "0.3.3",
"tslib": "^1.9.3"
}
},
"@sentry/types": {
"version": "5.6.1",
"resolved": "https://registry.npmjs.org/@sentry/types/-/types-5.6.1.tgz",
"integrity": "sha512-Kub8TETefHpdhvtnDj3kKfhCj0u/xn3Zi2zIC7PB11NJHvvPXENx97tciz4roJGp7cLRCJsFqCg4tHXniqDSnQ=="
},
"@sentry/utils": {
"version": "5.6.1",
"resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-5.6.1.tgz",
"integrity": "sha512-rfgha+UsHW816GqlSRPlniKqAZylOmQWML2JsujoUP03nPu80zdN43DK9Poy/d9OxBxv0gd5K2n+bFdM2kqLQQ==",
"requires": {
"@sentry/types": "5.6.1",
"tslib": "^1.9.3"
}
},
"@sinonjs/commons": { "@sinonjs/commons": {
"version": "1.4.0", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.4.0.tgz", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.4.0.tgz",
@ -3168,11 +3241,6 @@
"integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==",
"dev": true "dev": true
}, },
"charenc": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz",
"integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc="
},
"chokidar": { "chokidar": {
"version": "2.1.6", "version": "2.1.6",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.6.tgz", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.6.tgz",
@ -4028,11 +4096,6 @@
"which": "^1.2.9" "which": "^1.2.9"
} }
}, },
"crypt": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz",
"integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs="
},
"crypto-browserify": { "crypto-browserify": {
"version": "3.12.0", "version": "3.12.0",
"resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz",
@ -8550,7 +8613,8 @@
"is-buffer": { "is-buffer": {
"version": "1.1.6", "version": "1.1.6",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==",
"dev": true
}, },
"is-builtin-module": { "is-builtin-module": {
"version": "1.0.0", "version": "1.0.0",
@ -9856,6 +9920,11 @@
"yallist": "^3.0.2" "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="
},
"magic-string": { "magic-string": {
"version": "0.23.2", "version": "0.23.2",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.23.2.tgz", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.23.2.tgz",
@ -9951,16 +10020,6 @@
"tiny-lru": "^1.6.1" "tiny-lru": "^1.6.1"
} }
}, },
"md5": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/md5/-/md5-2.2.1.tgz",
"integrity": "sha1-U6s41f48iJG6RlMp6iP6wFQBJvk=",
"requires": {
"charenc": "~0.0.1",
"crypt": "~0.0.1",
"is-buffer": "~1.1.1"
}
},
"md5.js": { "md5.js": {
"version": "1.3.5", "version": "1.3.5",
"resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz",
@ -13420,24 +13479,6 @@
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg=="
}, },
"raven": {
"version": "2.6.4",
"resolved": "https://registry.npmjs.org/raven/-/raven-2.6.4.tgz",
"integrity": "sha512-6PQdfC4+DQSFncowthLf+B6Hr0JpPsFBgTVYTAOq7tCmx/kR4SXbeawtPch20+3QfUcQDoJBLjWW1ybvZ4kXTw==",
"requires": {
"cookie": "0.3.1",
"md5": "^2.2.1",
"stack-trace": "0.0.10",
"timed-out": "4.0.1",
"uuid": "3.3.2"
}
},
"raven-js": {
"version": "3.27.2",
"resolved": "https://registry.npmjs.org/raven-js/-/raven-js-3.27.2.tgz",
"integrity": "sha512-mFWQcXnhRFEQe5HeFroPaEghlnqy7F5E2J3Fsab189ondqUzcjwSVi7el7F36cr6PvQYXoZ1P2F5CSF2/azeMQ==",
"dev": true
},
"raw-body": { "raw-body": {
"version": "2.4.0", "version": "2.4.0",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz",
@ -16030,11 +16071,6 @@
"integrity": "sha512-YwT8pjmNcAXBZqrubu22P4FYsh2D4dxRmnWBOL8Jk8bUcRUtc5326kx32tuTmFDAZtLOGEVNl8POAR8j896Iow==", "integrity": "sha512-YwT8pjmNcAXBZqrubu22P4FYsh2D4dxRmnWBOL8Jk8bUcRUtc5326kx32tuTmFDAZtLOGEVNl8POAR8j896Iow==",
"dev": true "dev": true
}, },
"timed-out": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz",
"integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8="
},
"timers-browserify": { "timers-browserify": {
"version": "2.0.10", "version": "2.0.10",
"resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.10.tgz", "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.10.tgz",
@ -16199,8 +16235,7 @@
"tslib": { "tslib": {
"version": "1.9.3", "version": "1.9.3",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz",
"integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ=="
"dev": true
}, },
"tty-browserify": { "tty-browserify": {
"version": "0.0.0", "version": "0.0.0",

View File

@ -67,6 +67,7 @@
"@dannycoates/webcrypto-liner": "^0.1.37", "@dannycoates/webcrypto-liner": "^0.1.37",
"@fullhuman/postcss-purgecss": "^1.2.0", "@fullhuman/postcss-purgecss": "^1.2.0",
"@mattiasbuelens/web-streams-polyfill": "0.2.1", "@mattiasbuelens/web-streams-polyfill": "0.2.1",
"@sentry/browser": "^5.6.1",
"asmcrypto.js": "^0.22.0", "asmcrypto.js": "^0.22.0",
"babel-loader": "^8.0.6", "babel-loader": "^8.0.6",
"babel-plugin-istanbul": "^5.2.0", "babel-plugin-istanbul": "^5.2.0",
@ -107,7 +108,6 @@
"prettier": "^1.18.2", "prettier": "^1.18.2",
"proxyquire": "^2.1.1", "proxyquire": "^2.1.1",
"puppeteer": "^1.19.0", "puppeteer": "^1.19.0",
"raven-js": "^3.27.2",
"raw-loader": "^3.1.0", "raw-loader": "^3.1.0",
"redis-mock": "^0.45.0", "redis-mock": "^0.45.0",
"rimraf": "^2.6.3", "rimraf": "^2.6.3",
@ -141,6 +141,7 @@
"@fluent/bundle": "^0.13.0", "@fluent/bundle": "^0.13.0",
"@fluent/langneg": "^0.3.0", "@fluent/langneg": "^0.3.0",
"@google-cloud/storage": "^3.0.4", "@google-cloud/storage": "^3.0.4",
"@sentry/node": "^5.6.1",
"aws-sdk": "^2.506.0", "aws-sdk": "^2.506.0",
"body-parser": "^1.19.0", "body-parser": "^1.19.0",
"choo": "^6.13.3", "choo": "^6.13.3",
@ -152,7 +153,6 @@
"mkdirp": "^0.5.1", "mkdirp": "^0.5.1",
"mozlog": "^2.2.0", "mozlog": "^2.2.0",
"node-fetch": "^2.6.0", "node-fetch": "^2.6.0",
"raven": "^2.6.4",
"redis": "^2.8.0", "redis": "^2.8.0",
"selenium-standalone": "^6.15.6", "selenium-standalone": "^6.15.6",
"ua-parser-js": "^0.7.20" "ua-parser-js": "^0.7.20"

View File

@ -1,13 +1,13 @@
const express = require('express'); const express = require('express');
const path = require('path'); const path = require('path');
const Raven = require('raven'); const Sentry = require('@sentry/node');
const config = require('../config'); const config = require('../config');
const routes = require('../routes'); const routes = require('../routes');
const pages = require('../routes/pages'); const pages = require('../routes/pages');
const expressWs = require('@dannycoates/express-ws'); const expressWs = require('@dannycoates/express-ws');
if (config.sentry_dsn) { if (config.sentry_dsn) {
Raven.config(config.sentry_dsn).install(); Sentry.init({ dsn: config.sentry_dsn });
} }
const app = express(); const app = express();

View File

@ -8,12 +8,10 @@ if (config.sentry_id) {
//eslint-disable-next-line node/no-missing-require //eslint-disable-next-line node/no-missing-require
const version = require('../dist/version.json'); const version = require('../dist/version.json');
sentry = ` sentry = `
var RAVEN_CONFIG = { var SENTRY_CONFIG = {
dsn: '${config.sentry_id}',
release: '${version.version}', release: '${version.version}',
tags: { beforeSend: function (data) {
commit: '${version.commit}'
},
dataCallback: function (data) {
var hash = window.location.hash; var hash = window.location.hash;
if (hash) { if (hash) {
return JSON.parse(JSON.stringify(data).replace(new RegExp(hash.slice(1), 'g'), '')); return JSON.parse(JSON.stringify(data).replace(new RegExp(hash.slice(1), 'g'), ''));
@ -21,7 +19,6 @@ var RAVEN_CONFIG = {
return data; return data;
} }
} }
var SENTRY_ID = '${config.sentry_id}';
`; `;
} }

View File

@ -114,6 +114,7 @@ const web = {
exclude: [ exclude: [
path.resolve(__dirname, 'node_modules/crc'), path.resolve(__dirname, 'node_modules/crc'),
path.resolve(__dirname, 'node_modules/@fluent'), path.resolve(__dirname, 'node_modules/@fluent'),
path.resolve(__dirname, 'node_modules/@sentry'),
path.resolve(__dirname, 'node_modules/tslib'), path.resolve(__dirname, 'node_modules/tslib'),
path.resolve(__dirname, 'node_modules/webcrypto-core') path.resolve(__dirname, 'node_modules/webcrypto-core')
], ],