Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("works", () => {
const isSetup: boolean = Raven.isSetup();
// $ExpectError - Raven.isSetup returns a boolean
const isSetupString: string = Raven.isSetup();
});
});
export default function createMiddleware(dsn, cfg={}, options={}) {
/*
Function that generates a crash reporter for Sentry.
dsn - private Sentry DSN.
cfg - object to configure Raven.
options - customize extra data sent to sentry
actionTransformer - tranform the action object to send; default to identity function
stateTransformer - transform the state object to send; default to identity function
logger - the logger to use for logging; default to console.error
*/
if (!Raven.isSetup()) {
if (!dsn) {
// Skip this middleware if there is no DSN.
console.error('[redux-raven-middleware] Sentry DSN required.');
return store => next => action => {
return next(action);
};
}
Raven.config(dsn, cfg).install();
}
return store => next => action => {
const {
actionTransformer = identity,
stateTransformer = identity,
logger = console.error.bind(console, '[redux-raven-middleware] Reporting error to Sentry:')
} = options;
function reportException(ex) {
// take Mulder's advice - trustno1
if (Raven && Raven.isSetup()) {
if (Raven.captureException) {
Raven.captureException(ex);
}
}
}
// subscribe to all Stores
Object.keys(stores).forEach(
function(storeName) {
stores[storeName].addChangeListener(this.updateState);
}.bind(this)
);
if (globals.BADGES_ENABLED) {
this.loadBadgeData();
}
// The code below is only relevant to logged in users
if (!context.hasLoggedInUser()) return;
if (Raven && window.SENTRY_DSN) {
if (!Raven.isSetup()) {
Raven.config(window.SENTRY_DSN).install();
}
this.loadRavenData();
}
// IMPORTANT! We get one shot at this. If the instances and volumes aren't
// fetched before this component is mounted we miss our opportunity to migrate
// the users resources (so make sure they're fetched in the Splash Screen)
var instances = stores.InstanceStore.getInstancesNotInAProject(),
volumes = stores.VolumeStore.getVolumesNotInAProject(),
nullProject = new NullProject({
instances: instances,
volumes: volumes
});
let all_instances = stores.InstanceStore.getAll();
require.ensure(['raven-js'], function(require) {
const Raven = require('raven-js');
if (!Raven.isSetup()) Raven.config(pluginParams.dsn, pluginParams.config).install();
window.Raven = Raven;
});
}
isRavenUsable: computed(() => {
return !!(Raven && Raven.isSetup() === true);
}).volatile(),
setup(dsn: string) {
if (!Raven.isSetup() && dsn) {
Raven
.config(dsn, {
environment: 'web-frontend',
release: '$TRAVIS_COMMIT',
})
.install();
}
}