Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function ServerRollbarLogger({ token, codeVersion, environment }) {
// https://rollbar.com/docs/notifier/rollbar.js/#quick-start-server
this._rollbar = new Rollbar({
accessToken: token,
captureUncaught: true,
captureUnhandledRejections: true,
code_version: codeVersion,
environment,
});
}
import Rollbar from 'rollbar'
import { isProd } from '../config'
import { rollbar as rollbarSecret } from '../../secret'
if (isProd) {
global.rollbar = new Rollbar({
accessToken: rollbarSecret.accessToken,
captureUncaught: true,
captureUnhandledRejections: true,
checkIgnore: (isUncaught, args) => {
const err = args[0]
// Never ignore uncaught errors
if (isUncaught) return false
// Ignore 'Bad Request' errors
if (err.status === 400) return true
// Ignore 'Forbidden' errors
if (err.status === 403) return true
// Ignore 'Not Found' errors
environment: '#rollbar_environment',
client: {
javascript: {
source_map_enabled: true,
code_version: '#code_version',
// Optionally have Rollbar guess which frames the error was thrown from
// when the browser does not provide line and column numbers.
guess_uncaught_frames: true,
},
},
},
};
let rollbar = {};
if ('#rollbar_client_token') {
rollbar = new Rollbar(rollbarConfig);
}
export default rollbar;
function loadRollbar() {
window.Rollbar = new rollbar({
enabled: true,
accessToken: readEnv().rollbarJsAccessToken,
captureUncaught: true,
captureUnhandledRejections: true,
transform: transform, // see note below
sendConfig: false, // not sure why, but this does not appear to work and we still see `notifier.configured_options``
// Throttle, mostly for limiting the impact of bugs in browser extensions
itemsPerMinute: 5,
maxItems: 20,
ignoreDuplicateErrors: true,
// Limit the data we send to Rollbar
captureIp: 'anonymize',
captureUsername: false,
captureEmail: false,
import debug from 'debug';
import Rollbar from 'rollbar';
import {
isHandledError,
unwrapHandledError
} from '../utils/create-handled-error.js';
const { ROLLBAR_APP_ID } = process.env;
const rollbar = new Rollbar(ROLLBAR_APP_ID);
const log = debug('fcc:middlewares:error-reporter');
const errTemplate = ({message, ...restError}, req) => `
Time: ${new Date(Date.now()).toISOString()}
Error: ${message}
Is authenticated user: ${!!req.user}
Route: ${JSON.stringify(req.route, null, 2)}
${JSON.stringify(restError, null, 2)}
`;
export default function errrorReporter() {
if (process.env.NODE_ENV !== 'production' && process.env.ERROR_REPORTER) {
return (err, req, res, next) => {
console.error(errTemplate(err, req));
import Rollbar from 'rollbar'
import { rollbarConfig } from '../config'
const rollbarLogger = new Rollbar(rollbarConfig)
const localLogger = console
function handleLog (rollbarLevel = 'debug', localLevel = rollbarLevel) {
return function () {
if (process.env.SILENT) return
if (rollbarConfig.enabled) {
rollbarLogger[rollbarLevel](...arguments)
} else if (rollbarConfig.verbose) {
localLogger[localLevel](...arguments)
}
}
}
export default {
critical: handleLog('critical', 'error'),
constructor(props) {
super(props);
this.state = {
rollbar: new Rollbar({
accessToken: 'POST_CLIENT_ITEM_TOKEN',
captureUncaught: true,
captureUnhandledRejections: true,
})
};
this.logInfo = this.logInfo.bind(this);
this.throwError = this.throwError.bind(this);
}
async register(container: Container.IContainer, options) {
return new Rollbar(options);
},
};