mirror of
https://github.com/captbaritone/webamp.git
synced 2026-01-23 10:15:31 +00:00
Use redux-sentry-middleware rather than our own thing
This commit is contained in:
parent
1b188f1408
commit
016eb6f797
4 changed files with 7 additions and 49 deletions
|
|
@ -3,7 +3,7 @@
|
|||
import * as Sentry from "@sentry/browser";
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import createMiddleware from "./sentryMiddleware";
|
||||
import createMiddleware from "redux-sentry-middleware";
|
||||
import isButterchurnSupported from "butterchurn/lib/isSupported.min";
|
||||
import { WINDOWS } from "../../js/constants";
|
||||
import * as Selectors from "../../js/selectors";
|
||||
|
|
|
|||
|
|
@ -1,48 +0,0 @@
|
|||
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;
|
||||
|
|
@ -156,6 +156,7 @@
|
|||
"eslint-plugin-react-hooks": "^2.1.2",
|
||||
"fscreen": "^1.0.2",
|
||||
"react-dropzone": "^10.1.7",
|
||||
"redux-sentry-middleware": "^0.1.3",
|
||||
"xml-js": "^1.6.11"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9816,6 +9816,11 @@ redux-devtools-extension@^2.13.2:
|
|||
resolved "https://registry.yarnpkg.com/redux-devtools-extension/-/redux-devtools-extension-2.13.8.tgz#37b982688626e5e4993ff87220c9bbb7cd2d96e1"
|
||||
integrity sha512-8qlpooP2QqPtZHQZRhx3x3OP5skEV1py/zUdMY28WNAocbafxdG2tRD1MWE7sp8obGMNYuLWanhhQ7EQvT1FBg==
|
||||
|
||||
redux-sentry-middleware@^0.1.3:
|
||||
version "0.1.3"
|
||||
resolved "https://registry.yarnpkg.com/redux-sentry-middleware/-/redux-sentry-middleware-0.1.3.tgz#d2ab581b36ff06c54b7ded2ebb73d2e2bfd4941f"
|
||||
integrity sha512-Qg6Q5dD8fd7YShTrBzT3xINhdUmXrQOVSOKk11lYdgA9i2QYmnNGZ6P9BxNkkgnWslZpD2xAC/yunEKAYKdshw==
|
||||
|
||||
redux-thunk@^2.3.0:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.yarnpkg.com/redux-thunk/-/redux-thunk-2.3.0.tgz#51c2c19a185ed5187aaa9a2d08b666d0d6467622"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue