From 4f60c91d273e1b4213810296ac32f82c4e641bb4 Mon Sep 17 00:00:00 2001 From: Julian Rabe Date: Sun, 14 Jun 2020 20:08:26 +0200 Subject: [PATCH] fix: Resolve sentry.json --- src/lib/sentry.ts | 59 ++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/src/lib/sentry.ts b/src/lib/sentry.ts index 2649409..66173d8 100644 --- a/src/lib/sentry.ts +++ b/src/lib/sentry.ts @@ -1,39 +1,34 @@ import Sentry = require("@sentry/node"); -import fs = require("fs"); -import {flush} from "@sentry/node"; export function init(packageInformation: any) { try { - const sentry = JSON.parse(fs.readFileSync("./sentry.json", {encoding: "utf-8"})); - - if (sentry) { - - const os = require("os"); - - Sentry.init({ - dsn: sentry.dsn, - environment: process.env.NODE_ENV ? process.env.NODE_ENV : "development", - release: 'twitch2ma@' + packageInformation.version, - integrations: [ - new Sentry.Integrations.OnUncaughtException(), - new Sentry.Integrations.OnUnhandledRejection() - ], - debug: process.env.NODE_ENV === "development" - }); - - Sentry.setContext("os", { - name: os.platform(), - version: os.release() - }); - - Sentry.setContext("runtime", { - name: process.release.name, - version: process.version - }); - - if (process.env.NODE_ENV === "development" || process.env.NODE_ENV === "staging") { - Sentry.setUser({username: os.userInfo().username}); - } + const sentry = require("../../sentry.json"); + + const os = require("os"); + + Sentry.init({ + dsn: sentry.dsn, + environment: process.env.NODE_ENV ? process.env.NODE_ENV : "development", + release: 'twitch2ma@' + packageInformation.version, + integrations: [ + new Sentry.Integrations.OnUncaughtException(), + new Sentry.Integrations.OnUnhandledRejection() + ], + debug: process.env.NODE_ENV === "development" + }); + + Sentry.setContext("os", { + name: os.platform(), + version: os.release() + }); + + Sentry.setContext("runtime", { + name: process.release.name, + version: process.version + }); + + if (process.env.NODE_ENV === "development" || process.env.NODE_ENV === "staging") { + Sentry.setUser({username: os.userInfo().username}); } } catch (ignored) { }