Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
initialize() {
if (Config.isAnalyticsEnabled) {
// ERROR HANDLING
// eslint-disable-next-line global-require
this.errorFixer = require('@sentry/node');
this.errorFixer.init({
dsn: 'https://004caee3caa04c81a10f2ba31a945362@sentry.io/1795473',
release: `rnv@${pkg.version}`,
integrations: [new RewriteFrames({
root: '/',
iteratee: (frame) => {
if (frame.filename.includes(`rnv${path.sep}dist${path.sep}`) || frame.filename.includes(`rnv${path.sep}src${path.sep}`)) {
if (frame.filename.includes(`rnv${path.sep}dist${path.sep}`)) {
frame.filename = frame.filename.split(`rnv${path.sep}dist${path.sep}`)[1];
} else {
frame.filename = frame.filename.split(`rnv${path.sep}src${path.sep}`)[1];
}
} else if (frame.filename.includes(`${path.sep}node_modules${path.sep}`)) {
frame.filename = `node_modules/${frame.filename.split(`${path.sep}node_modules${path.sep}`)[1]}`;
}
return frame;
}
})]
});
}
): void {
// tslint:disable: strict-comparisons
if (options.defaultIntegrations === undefined) {
options.defaultIntegrations = [
new ReactNativeErrorHandlers(),
new Release(),
...defaultIntegrations.filter(
i => !IGNORED_DEFAULT_INTEGRATIONS.includes(i.name)
),
new Integrations.Breadcrumbs({
console: false, // If this in enabled it causes problems to native calls on >= RN 0.60
fetch: false
}),
new DebugSymbolicator(),
new RewriteFrames({
iteratee: (frame: StackFrame) => {
if (frame.filename) {
frame.filename = frame.filename
.replace(/^file\:\/\//, "")
.replace(/^address at /, "")
.replace(/^.*\/[^\.]+(\.app|CodePush|.*(?=\/))/, "");
const appPrefix = "app://";
// We always want to have a tripple slash
frame.filename =
frame.filename.indexOf("/") === 0
? `${appPrefix}${frame.filename}`
: `${appPrefix}/${frame.filename}`;
}
return frame;
}
if (!analytics) {
return;
}
const dsn = isProduction ? 'https://b0fb75c38ef4487dbf742f79c4ba62d2@sentry.servarr.com/12' :
'https://da610619280249f891ec3ee306906793@sentry.servarr.com/13';
sentry.init({
dsn,
environment: branch,
release,
sendDefaultPii: true,
beforeSend: cleanseData,
integrations: [
new Integrations.RewriteFrames({ iteratee: stripUrlBase }),
new Integrations.Dedupe()
]
});
sentry.configureScope((scope) => {
scope.setUser({ username: userHash });
scope.setTag('version', version);
scope.setTag('production', isProduction);
});
return createMiddleware();
}
export default async function init(): Promise {
if (secrets.SENTRY_DSN) {
Sentry.init({
dsn: secrets.SENTRY_DSN,
integrations: [new Integrations.RewriteFrames({ root: __dirname || process.cwd() })]
});
}
const network = setStellarNetwork();
logger.info(`Using ${network}`);
logger.info("Connecting to database...");
await createConnection({
type: "postgres",
host: secrets.DBHOST,
port: secrets.DBPORT,
username: secrets.DBUSER,
password: secrets.DBPASSWORD,
database: secrets.DB,
entities: ["./src/orm/entities/*.ts"],
synchronize: false,
export function initSentry(): Promise {
if (!SENTRY_DSN) {
return Promise.resolve(false);
}
Sentry.init({
dsn: SENTRY_DSN,
integrations: [
new Integrations.RewriteFrames({
root: __dirname ? `${__dirname}/../..` : process.cwd()
})
]
});
return Promise.resolve(true);
}