Upgrade to new Sentry SDK (#956)

* Upgrade to new Sentry SDK

* Rename middleware to use Sentry instead of Raven
This commit is contained in:
Jordan Eldredge 2019-12-17 20:24:20 -08:00 committed by GitHub
parent 77823a07fe
commit a488a4b3f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 117 additions and 19 deletions

View File

@ -1,9 +1,9 @@
/* global SENTRY_DSN */
import Raven from "raven-js";
import * as Sentry from "@sentry/browser";
import React from "react";
import ReactDOM from "react-dom";
import createMiddleware from "raven-for-redux";
import createMiddleware from "./sentryMiddleware";
import isButterchurnSupported from "butterchurn/lib/isSupported.min";
import { WINDOWS } from "../../js/constants";
import * as Selectors from "../../js/selectors";
@ -80,12 +80,13 @@ function filterBreadcrumbActions(action) {
return !noisy;
}
Raven.config(SENTRY_DSN, {
Sentry.init({
dsn: SENTRY_DSN,
/* global COMMITHASH */
release: typeof COMMITHASH !== "undefined" ? COMMITHASH : "DEV",
}).install();
});
const ravenMiddleware = createMiddleware(Raven, {
const sentryMiddleware = createMiddleware(Sentry, {
filterBreadcrumbActions,
stateTransformer: Selectors.getDebugData,
});
@ -97,8 +98,7 @@ window.addEventListener("beforeinstallprompt", e => {
e.preventDefault();
});
Raven.context(async () => {
window.Raven = Raven;
async function main() {
const about = document.getElementsByClassName("about")[0];
if (screenshot) {
about.style.visibility = "hidden";
@ -156,7 +156,7 @@ Raven.context(async () => {
__initialWindowLayout,
__initialState: screenshot ? screenshotInitialState : initialState,
__butterchurnOptions,
__customMiddlewares: [ravenMiddleware],
__customMiddlewares: [sentryMiddleware],
});
if (disableMarquee || screenshot) {
@ -219,4 +219,6 @@ Raven.context(async () => {
<WebampIcon webamp={webamp} />,
document.getElementById("webamp-icon")
);
});
}
main();

View File

@ -0,0 +1,48 @@
const identity = x => x;
const getUndefined = () => {};
const getType = action => action.type;
const filter = () => true;
function createSentryMiddleware(sentry, options = {}) {
const {
breadcrumbDataFromAction = getUndefined,
breadcrumbMessageFromAction = getType,
actionTransformer = identity,
stateTransformer = identity,
breadcrumbCategory = "redux-action",
filterBreadcrumbActions = filter,
getUserContext,
getTags,
} = options;
return store => {
let lastAction;
sentry.addGlobalEventProcessor(event => {
const state = store.getState();
const reduxExtra = {
lastAction: actionTransformer(lastAction),
state: stateTransformer(state),
};
event.extra = Object.assign(reduxExtra, event.extra || {});
if (getUserContext) {
event.user = getUserContext(state);
}
if (getTags) {
event.tags = getTags(state);
}
return event;
});
return next => action => {
if (filterBreadcrumbActions(action)) {
sentry.addBreadcrumb({
category: breadcrumbCategory,
message: breadcrumbMessageFromAction(action),
data: breadcrumbDataFromAction(action),
});
}
lastAction = action;
return next(action);
};
};
}
module.exports = createSentryMiddleware;

View File

@ -67,6 +67,7 @@
"@babel/preset-react": "^7.7.0",
"@babel/preset-typescript": "^7.7.2",
"@babel/runtime": "^7.7.2",
"@sentry/browser": "5.9.1",
"@types/classnames": "^2.2.6",
"@types/css-font-loading-module": "^0.0.2",
"@types/fscreen": "^1.0.1",
@ -118,8 +119,6 @@
"postcss-loader": "^3.0.0",
"prettier": "^1.19.1",
"puppeteer": "^1.15.0",
"raven-for-redux": "^1.3.1",
"raven-js": "^3.19.1",
"rc-slider": "^8.7.1",
"react": "^16.8.6",
"react-dom": "^16.8.6",

View File

@ -1302,6 +1302,58 @@
version "1.1.3"
resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b"
"@sentry/browser@5.9.1":
version "5.9.1"
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-5.9.1.tgz#b2ec27ead501a49f26807a9c0774f44f4292f236"
integrity sha512-7AOabwp9yAH9h6Xe6TfDwlLxHbUSWs+SPWHI7bPlht2yDSAqkXYGSzRr5X0XQJX9oBQdx2cEPMqHyJrbNaP/og==
dependencies:
"@sentry/core" "5.8.0"
"@sentry/types" "5.7.1"
"@sentry/utils" "5.8.0"
tslib "^1.9.3"
"@sentry/core@5.8.0":
version "5.8.0"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.8.0.tgz#bbfd2f4711491951a8e3a0e8fa8b172fdf7bff6f"
integrity sha512-aAh2KLidIXJVGrxmHSVq2eVKbu7tZiYn5ylW6yzJXFetS5z4MA+JYaSBaG2inVYDEEqqMIkb17TyWxxziUDieg==
dependencies:
"@sentry/hub" "5.8.0"
"@sentry/minimal" "5.8.0"
"@sentry/types" "5.7.1"
"@sentry/utils" "5.8.0"
tslib "^1.9.3"
"@sentry/hub@5.8.0":
version "5.8.0"
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.8.0.tgz#56aaeb7324cb66d90db838011cb0127f5558007f"
integrity sha512-VdApn1ZCNwH1wwQwoO6pu53PM/qgHG+DQege0hbByluImpLBhAj9w50nXnF/8KzV4UoMIVbzCb6jXzMRmqqp9A==
dependencies:
"@sentry/types" "5.7.1"
"@sentry/utils" "5.8.0"
tslib "^1.9.3"
"@sentry/minimal@5.8.0":
version "5.8.0"
resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.8.0.tgz#b7ad5113504ab67f1ef2b0f465b7ba608e6b8dc5"
integrity sha512-MIlFOgd+JvAUrBBmq7vr9ovRH1HvckhnwzHdoUPpKRBN+rQgTyZy1o6+kA2fASCbrRqFCP+Zk7EHMACKg8DpIw==
dependencies:
"@sentry/hub" "5.8.0"
"@sentry/types" "5.7.1"
tslib "^1.9.3"
"@sentry/types@5.7.1":
version "5.7.1"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.7.1.tgz#4c4c1d4d891b6b8c2c3c7b367d306a8b1350f090"
integrity sha512-tbUnTYlSliXvnou5D4C8Zr+7/wJrHLbpYX1YkLXuIJRU0NSi81bHMroAuHWILcQKWhVjaV/HZzr7Y/hhWtbXVQ==
"@sentry/utils@5.8.0":
version "5.8.0"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.8.0.tgz#34683088159b9935f973b6e6cad1a1cc26bbddac"
integrity sha512-KDxUvBSYi0/dHMdunbxAxD3389pcQioLtcO6CI6zt/nJXeVFolix66cRraeQvqupdLhvOk/el649W4fCPayTHw==
dependencies:
"@sentry/types" "5.7.1"
tslib "^1.9.3"
"@sindresorhus/is@^0.7.0":
version "0.7.0"
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.7.0.tgz#9a06f4f137ee84d7df0460c1fdb1135ffa6c50fd"
@ -9454,14 +9506,6 @@ range-parser@~1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e"
raven-for-redux@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/raven-for-redux/-/raven-for-redux-1.3.1.tgz#865f0056ec1706073c1b3a33164640453ed4fed2"
raven-js@^3.19.1:
version "3.22.2"
resolved "https://registry.yarnpkg.com/raven-js/-/raven-js-3.22.2.tgz#85785928ebd664049e54efd0db8ff28da0cbb374"
raw-body@2.3.3:
version "2.3.3"
resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.3.3.tgz#1b324ece6b5706e153855bc1148c65bb7f6ea0c3"
@ -11270,6 +11314,11 @@ tslib@^1.8.1, tslib@^1.9.0:
version "1.9.3"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
tslib@^1.9.3:
version "1.10.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==
tsutils@^3.17.1:
version "3.17.1"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.17.1.tgz#ed719917f11ca0dee586272b2ac49e015a2dd759"