Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return store => next => action => {
const {
actionTransformer = identity,
stateTransformer = identity,
logger = console.error.bind(console, '[redux-raven-middleware] Reporting error to Sentry:')
} = options;
try {
Raven.captureBreadcrumb({
category: 'redux',
message: action.type
});
return next(action);
} catch (err) {
logger(err);
// Send the report.
Raven.captureException(err, {
extra: {
action: actionTransformer(action),
state: stateTransformer(store.getState()),
}
});
}
Raven.context(() => {
Raven.captureBreadcrumb({
data: {
torrent
}
});
db.insert({
_id: torrent.link,
magnet: torrent.link,
title: torrent.title,
tvdbID: torrent['tv:show_name']['#'],
airdate: torrent['rss:pubdate']['#'],
downloaded: false
});
callback();
});
}
.then((resp) => resp.json().then(({ data: respData } = {}) => {
Raven.captureBreadcrumb({
message: 'Network resource call complete',
category: 'resource',
data: {
request: {
endpoint,
method,
data,
},
response: {
data: respData,
status: resp.status,
},
},
});
return cb(null, respData);
}))
captureBreadcrumb(breadcrumb) {
Raven.captureBreadcrumb(breadcrumb);
}
export const captureBreadcrumb = (o: *) => {
Raven.captureBreadcrumb(o)
}
.catch(err => {
Raven.captureBreadcrumb({
message: `API Error ${path}`,
data: {
path: path,
params: requestBody(data, method),
data: data,
method: method,
url: url
}
})
throw (err);
});
}
const errorReporter = (store) => (next) => (action) => {
try {
const result = next(action);
Raven.captureBreadcrumb({
message: 'State reduction in response to dispatched action',
category: 'redux',
data: {
action,
store: store.getState(),
},
});
return result;
} catch (err) {
Raven.captureException(err, {
extra: {
action,
store: store.getState(),
},
});
return new Promise((resolve, reject) => {
Raven.captureBreadcrumb(crumb);
resolve(crumb);
});
}