Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
});
const [command, ...subCommands] = input;
const options = {};
// Parse commands
for (let i = 0; i < subCommands.length; i += 1) {
options[subCommands[i]] = subCommands[i];
}
if (flags.report) {
console.clear();
console.log(chalk`{yellow {bold ERROR REPORTING}}`);
console.log();
const event_id = Sentry.captureMessage(`MESSAGE ${randomString(6)}`, Sentry.Severity.Info);
await SentryAPIClient.shared.userFeedBack(null, event_id);
process.exit(0);
}
if (flags.quiet) {
const emptyFunction = () => null;
console.log = console.info = emptyFunction;
if (spinner.fail) {
spinner.fail = emptyFunction;
}
if (spinner.start) {
spinner.start = emptyFunction;
}
render() {
Sentry.addBreadcrumb({
category: fileLabel,
message: `Preparing document (${
isServer() ? 'server' : 'browser'
})`,
level: Sentry.Severity.Debug,
});
return (
{/* PWA primary color */}
dns.lookup('api.unsplash.com', (error) => {
if (error && error.code === 'ENOTFOUND') {
Sentry.captureMessage('No Internet Connection', Sentry.Severity.Warning);
console.error(chalk.red('\n Please check your internet connection.\n'));
process.exit(1);
}
});
process.on('unhandledRejection', (reason, p): void => {
Sentry.captureMessage(`Unhandled Rejection at: Promise ${p}, reason: ${reason}`, Sentry.Severity.Error);
});
Sentry.withScope(scope => {
scope.setTag('report-type', 'user-report');
scope.setLevel(Sentry.Severity.Error);
scope.setExtra('report', JSON.stringify(m.payload));
Sentry.captureMessage(`User report: ${message}`);
});
});
function getSentryLevel(record: BunyanRecord): Sentry.Severity {
const { level } = record;
if (level >= 60) return Sentry.Severity.Critical;
if (level >= 50) return Sentry.Severity.Error;
if (level === 40) return Sentry.Severity.Warning;
return Sentry.Severity.Info;
}
const Sentry = require("@sentry/node");
const Transport = require("winston-transport");
const isError_ = require("lodash/isError");
const UserError = require("../UserError");
const WINSTON_TO_SENTRY_LEVEL = {
error: Sentry.Severity.Error,
warn: Sentry.Severity.Warning,
info: Sentry.Severity.Info,
verbose: Sentry.Severity.Info,
debug: Sentry.Severity.Debug
};
const convertLevel = ({ level, ...rest }) =>
level ? { level: WINSTON_TO_SENTRY_LEVEL[level], ...rest } : rest;
class SentryTransport extends Transport {
constructor(opts) {
super(opts);
this._sentry = opts.sentry;
this._sillyLogs = [];
}
_captureException(error, { level = "error", extra }) {
this._sentry.withScope(scope => {
scope.setLevel(WINSTON_TO_SENTRY_LEVEL[level]);
Sentry.withScope(scope => {
scope.setTag('report-type', 'csp');
scope.setLevel(Sentry.Severity.Error);
scope.setExtra('referrer', (m.payload as any).referrer);
scope.setExtra('violated-directive', (m.payload as any)['violated-directive']);
scope.setExtra('blocked-uri', (m.payload as any)['blocked-uri']);
scope.setExtra('source-file', (m.payload as any)['source-file']);
scope.setExtra('report', JSON.stringify(m.payload));
Sentry.captureMessage(`CSP violation: ${(m.payload as any)['blocked-uri']}`);
});
});
Sentry.withScope(scope => {
for (const key in extra) {
scope.setExtra(key, extra[key])
}
scope.setLevel(Sentry.Severity.Error)
Sentry.captureException(err)
})
}