From b3ec5423a64ad831f37bd3e5f107506239898be0 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Thu, 2 Mar 2023 11:19:37 +0530 Subject: [PATCH] revert unrelated changes --- src/services/exportService.ts | 1 - src/utils/sentry/index.ts | 57 ++++++++++++++--------------------- 2 files changed, 22 insertions(+), 36 deletions(-) diff --git a/src/services/exportService.ts b/src/services/exportService.ts index ce2a266d3..68a905dc6 100644 --- a/src/services/exportService.ts +++ b/src/services/exportService.ts @@ -87,7 +87,6 @@ class ExportService { exportType: ExportType ) { try { - // eslint-disable-next-line @typescript-eslint/no-misused-promises if (this.exportInProgress) { this.electronAPIs.sendNotification( ExportNotification.IN_PROGRESS diff --git a/src/utils/sentry/index.ts b/src/utils/sentry/index.ts index c89d7222f..a726d45c2 100644 --- a/src/utils/sentry/index.ts +++ b/src/utils/sentry/index.ts @@ -2,46 +2,33 @@ import * as Sentry from '@sentry/nextjs'; import { addLogLine } from 'utils/logging'; import { getSentryUserID } from 'utils/user'; -export const logError = ( +export const logError = async ( error: any, msg: string, info?: Record, skipAddLogLine = false ) => { - const main = async () => { - try { - if (isErrorUnnecessaryForSentry(error)) { - return; - } - const err = errorWithContext(error, msg); - if (!skipAddLogLine) { - addLogLine( - `error: ${error?.name} ${error?.message} ${ - error?.stack - } msg: ${msg} ${ - info ? `info: ${JSON.stringify(info)}` : '' - }` - ); - } - Sentry.captureException(err, { - level: Sentry.Severity.Info, - user: { id: await getSentryUserID() }, - contexts: { - ...(info && { - info: info, - }), - rootCause: { - message: error?.message, - completeError: error, - }, - }, - }); - } catch (e) { - addLogLine('error in logError', e); - // ignore - } - }; - void main(); + if (isErrorUnnecessaryForSentry(error)) { + return; + } + const err = errorWithContext(error, msg); + if (!skipAddLogLine) { + addLogLine( + `error: ${error?.name} ${error?.message} ${ + error?.stack + } msg: ${msg} ${info ? `info: ${JSON.stringify(info)}` : ''}` + ); + } + Sentry.captureException(err, { + level: Sentry.Severity.Info, + user: { id: await getSentryUserID() }, + contexts: { + ...(info && { + info: info, + }), + rootCause: { message: error?.message, completeError: error }, + }, + }); }; // copy of errorWithContext to prevent importing error util