From acd83c4ae43e0b25b090350c36027265c2c507ff Mon Sep 17 00:00:00 2001 From: Bastien DUMONT <bdumont@grandlyon.com> Date: Thu, 28 Sep 2023 12:25:29 +0000 Subject: [PATCH] chore(logs): improve logs --- .../EPGLConnect/FormLogin/FormLogin.tsx | 4 ++- .../EcogestureNotFound.spec.tsx} | 12 ++++--- .../EcogestureNotFound.tsx} | 13 +++---- .../EcogestureNotFound.spec.tsx.snap} | 6 ++-- .../ecogestureNotFound.scss} | 0 .../Ecogesture/SingleEcogestureView.tsx | 7 +++- src/components/Hooks/useKonnectorAuth.tsx | 2 +- src/components/Splash/SplashRoot.tsx | 2 +- src/migrations/migration.ts | 2 +- src/services/account.service.ts | 10 +++--- src/services/challenge.service.ts | 8 ++--- src/services/customPopup.service.ts | 2 +- src/services/duel.service.ts | 2 +- src/services/ecogesture.service.ts | 8 ++--- .../enedisMonthlyAnalysisData.service.ts | 2 +- src/services/fluidsPrices.service.ts | 4 +-- src/services/initialization.service.ts | 34 +++++++++---------- src/services/mail.service.ts | 2 +- src/services/partnersInfo.service.ts | 2 +- src/services/profileType.service.ts | 2 +- src/services/profileTypeEntity.service.ts | 2 +- src/services/terms.service.ts | 2 +- src/services/triggers.service.ts | 2 +- src/services/usageEvent.service.ts | 4 +-- src/targets/services/aggregatorUsageEvents.ts | 4 +-- src/targets/services/fluidsPrices.ts | 6 ++-- .../services/monthlyReportNotification.ts | 4 +-- 27 files changed, 80 insertions(+), 68 deletions(-) rename src/components/{CommonKit/ErrorPage/ErrorPage.spec.tsx => Ecogesture/EcogestureNotFound/EcogestureNotFound.spec.tsx} (72%) rename src/components/{CommonKit/ErrorPage/ErrorPage.tsx => Ecogesture/EcogestureNotFound/EcogestureNotFound.tsx} (90%) rename src/components/{CommonKit/ErrorPage/__snapshots__/ErrorPage.spec.tsx.snap => Ecogesture/EcogestureNotFound/__snapshots__/EcogestureNotFound.spec.tsx.snap} (98%) rename src/components/{CommonKit/ErrorPage/errorPage.scss => Ecogesture/EcogestureNotFound/ecogestureNotFound.scss} (100%) diff --git a/src/components/Connection/EPGLConnect/FormLogin/FormLogin.tsx b/src/components/Connection/EPGLConnect/FormLogin/FormLogin.tsx index 118d594a9..f2216ea1d 100644 --- a/src/components/Connection/EPGLConnect/FormLogin/FormLogin.tsx +++ b/src/components/Connection/EPGLConnect/FormLogin/FormLogin.tsx @@ -9,6 +9,7 @@ import { FluidType } from 'enums' import { Account, AccountAuthData } from 'models' import React, { useEffect, useState } from 'react' import { useAppSelector } from 'store/hooks' +import logApp from 'utils/logger' import { getPartnerPicto } from 'utils/picto' import './formLogin.scss' @@ -75,7 +76,8 @@ const FormLogin = () => { await update() } } catch (error) { - Sentry.captureException(JSON.stringify({ error })) + logApp.error(error) + Sentry.captureException(error) setLoading(false) } } diff --git a/src/components/CommonKit/ErrorPage/ErrorPage.spec.tsx b/src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.spec.tsx similarity index 72% rename from src/components/CommonKit/ErrorPage/ErrorPage.spec.tsx rename to src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.spec.tsx index d47cc5c52..9be727a77 100644 --- a/src/components/CommonKit/ErrorPage/ErrorPage.spec.tsx +++ b/src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.spec.tsx @@ -3,7 +3,7 @@ import { Button } from '@material-ui/core' import { mount } from 'enzyme' import toJson from 'enzyme-to-json' import React from 'react' -import ErrorPage from './ErrorPage' +import EcogestureNotFound from './EcogestureNotFound' const mockedNavigate = jest.fn() jest.mock('react-router-dom', () => ({ @@ -15,14 +15,18 @@ jest.mock('components/Header/Header', () => 'mock-header') jest.mock('components/Header/CozyBar', () => 'mock-cozybar') jest.mock('components/Content/Content', () => 'mock-content') -describe('ErrorPage component', () => { +describe('EcogestureNotFound component', () => { it('should be rendered correctly', async () => { - const wrapper = mount(<ErrorPage text="test" returnPage="ecogestures" />) + const wrapper = mount( + <EcogestureNotFound text="test" returnPage="ecogestures" /> + ) expect(toJson(wrapper)).toMatchSnapshot() }) it('should click on button and be redirected', () => { - const wrapper = mount(<ErrorPage text="test" returnPage="ecogestures" />) + const wrapper = mount( + <EcogestureNotFound text="test" returnPage="ecogestures" /> + ) wrapper.find(Button).simulate('click') expect(mockedNavigate).toHaveBeenCalledWith('/ecogestures') }) diff --git a/src/components/CommonKit/ErrorPage/ErrorPage.tsx b/src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.tsx similarity index 90% rename from src/components/CommonKit/ErrorPage/ErrorPage.tsx rename to src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.tsx index fcf61d99a..3c1ac059e 100644 --- a/src/components/CommonKit/ErrorPage/ErrorPage.tsx +++ b/src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.tsx @@ -7,14 +7,15 @@ import Header from 'components/Header/Header' import { useI18n } from 'cozy-ui/transpiled/react/I18n' import React, { useState } from 'react' import { useNavigate } from 'react-router-dom' -import './errorPage.scss' +import './ecogestureNotFound.scss' -interface ErrorPageProps { +const EcogestureNotFound = ({ + text, + returnPage, +}: { text: string returnPage: string -} - -const ErrorPage = ({ text, returnPage }: ErrorPageProps) => { +}) => { const { t } = useI18n() const navigate = useNavigate() const [headerHeight, setHeaderHeight] = useState<number>(0) @@ -49,4 +50,4 @@ const ErrorPage = ({ text, returnPage }: ErrorPageProps) => { ) } -export default ErrorPage +export default EcogestureNotFound diff --git a/src/components/CommonKit/ErrorPage/__snapshots__/ErrorPage.spec.tsx.snap b/src/components/Ecogesture/EcogestureNotFound/__snapshots__/EcogestureNotFound.spec.tsx.snap similarity index 98% rename from src/components/CommonKit/ErrorPage/__snapshots__/ErrorPage.spec.tsx.snap rename to src/components/Ecogesture/EcogestureNotFound/__snapshots__/EcogestureNotFound.spec.tsx.snap index f49c1b48e..fe29324f5 100644 --- a/src/components/CommonKit/ErrorPage/__snapshots__/ErrorPage.spec.tsx.snap +++ b/src/components/Ecogesture/EcogestureNotFound/__snapshots__/EcogestureNotFound.spec.tsx.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`ErrorPage component should be rendered correctly 1`] = ` -<ErrorPage +exports[`EcogestureNotFound component should be rendered correctly 1`] = ` +<EcogestureNotFound returnPage="ecogestures" text="test" > @@ -193,5 +193,5 @@ exports[`ErrorPage component should be rendered correctly 1`] = ` </WithStyles(ForwardRef(Button))> </div> </mock-content> -</ErrorPage> +</EcogestureNotFound> `; diff --git a/src/components/CommonKit/ErrorPage/errorPage.scss b/src/components/Ecogesture/EcogestureNotFound/ecogestureNotFound.scss similarity index 100% rename from src/components/CommonKit/ErrorPage/errorPage.scss rename to src/components/Ecogesture/EcogestureNotFound/ecogestureNotFound.scss diff --git a/src/components/Ecogesture/SingleEcogestureView.tsx b/src/components/Ecogesture/SingleEcogestureView.tsx index 6db69d518..3f9b7cefb 100644 --- a/src/components/Ecogesture/SingleEcogestureView.tsx +++ b/src/components/Ecogesture/SingleEcogestureView.tsx @@ -1,13 +1,14 @@ import { Collapse } from '@material-ui/core' import IconButton from '@material-ui/core/IconButton' +import * as Sentry from '@sentry/react' import doingDisabledIcon from 'assets/icons/ico/doing-disabled.svg' import doingEnabledIcon from 'assets/icons/ico/doing-enabled.svg' import objectiveDisabledIcon from 'assets/icons/ico/objective-disabled.svg' import objectiveEnabledIcon from 'assets/icons/ico/objective-enabled.svg' import defaultIcon from 'assets/icons/visu/ecogesture/default.svg' -import ErrorPage from 'components/CommonKit/ErrorPage/ErrorPage' import StyledIcon from 'components/CommonKit/Icon/StyledIcon' import Content from 'components/Content/Content' +import ErrorPage from 'components/Ecogesture/EcogestureNotFound/EcogestureNotFound' import CozyBar from 'components/Header/CozyBar' import Header from 'components/Header/Header' import useExploration from 'components/Hooks/useExploration' @@ -20,6 +21,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react' import { useParams } from 'react-router-dom' import EcogestureService from 'services/ecogesture.service' import { useAppSelector } from 'store/hooks' +import logApp from 'utils/logger' import { importIconById } from 'utils/utils' import EfficiencyRating from './EfficiencyRating/EfficiencyRating' import './singleEcogestureView.scss' @@ -89,6 +91,9 @@ const SingleEcogestureView = () => { setValidExploration(currentChallenge.exploration.id) } } + } else { + logApp.error(`Could not find ecogesture ${ecogestureID}`) + Sentry.captureException(new Error('Could not find ecogesture')) } setIsLoading(false) } diff --git a/src/components/Hooks/useKonnectorAuth.tsx b/src/components/Hooks/useKonnectorAuth.tsx index e0f926074..1750eff2d 100644 --- a/src/components/Hooks/useKonnectorAuth.tsx +++ b/src/components/Hooks/useKonnectorAuth.tsx @@ -83,7 +83,7 @@ const useKonnectorAuth = ( setLoading(false) sendUsageEventError(konnectorSlug) logApp.error(error) - Sentry.captureException(JSON.stringify({ error })) + Sentry.captureException(error) } } diff --git a/src/components/Splash/SplashRoot.tsx b/src/components/Splash/SplashRoot.tsx index a0cfaf2a2..49d280d31 100644 --- a/src/components/Splash/SplashRoot.tsx +++ b/src/components/Splash/SplashRoot.tsx @@ -373,7 +373,7 @@ const SplashRoot = ({ fadeTimer = 1000, children }: SplashRootProps) => { setInitStepErrors(InitStepsErrors.UNKNOWN_ERROR) } logApp.error(`[Initialization] Error : ${error}`) - Sentry.captureException(JSON.stringify({ error })) + Sentry.captureException(error) } finally { transaction.finish() } diff --git a/src/migrations/migration.ts b/src/migrations/migration.ts index b5e6819cb..22c34e25b 100644 --- a/src/migrations/migration.ts +++ b/src/migrations/migration.ts @@ -181,7 +181,7 @@ export async function migrate( } } catch (error: any) { console.error(error) - Sentry.captureException(JSON.stringify({ error })) + Sentry.captureException(error) result = { type: MIGRATION_RESULT_FAILED, errors: [error.toString()], diff --git a/src/services/account.service.ts b/src/services/account.service.ts index 13ffc78f8..3ed4c8bfc 100644 --- a/src/services/account.service.ts +++ b/src/services/account.service.ts @@ -57,7 +57,7 @@ export default class AccountService { const errorMessage = `Get account failed :${JSON.stringify(error)}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw new Error('Get account failed') } } @@ -106,7 +106,7 @@ export default class AccountService { const errorMessage = `Error GetAccountByType: ${JSON.stringify(error)}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) return null } } @@ -124,7 +124,7 @@ export default class AccountService { const errorMessage = `Error: GetAccountsByType: ${JSON.stringify(error)}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) return [] } } @@ -137,7 +137,7 @@ export default class AccountService { const errorMessage = `Update account failed: ${JSON.stringify(error)}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw new Error('Update account failed') } } @@ -150,7 +150,7 @@ export default class AccountService { const errorMessage = `Delete account failed` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw new Error(errorMessage) } } diff --git a/src/services/challenge.service.ts b/src/services/challenge.service.ts index ff4623e38..7a1ad1697 100644 --- a/src/services/challenge.service.ts +++ b/src/services/challenge.service.ts @@ -485,7 +485,7 @@ export default class ChallengeService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } @@ -540,7 +540,7 @@ export default class ChallengeService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } @@ -583,7 +583,7 @@ export default class ChallengeService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } @@ -803,7 +803,7 @@ export default class ChallengeService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } diff --git a/src/services/customPopup.service.ts b/src/services/customPopup.service.ts index 71c308900..f09472520 100644 --- a/src/services/customPopup.service.ts +++ b/src/services/customPopup.service.ts @@ -39,7 +39,7 @@ export default class CustomPopupService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) } } } diff --git a/src/services/duel.service.ts b/src/services/duel.service.ts index 204e9e708..e18c62a54 100644 --- a/src/services/duel.service.ts +++ b/src/services/duel.service.ts @@ -156,7 +156,7 @@ export default class DuelService { const errorMessage = `deleteAllDuelEntities:${JSON.stringify(error)}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } diff --git a/src/services/ecogesture.service.ts b/src/services/ecogesture.service.ts index 402795d9e..ce32ccb52 100644 --- a/src/services/ecogesture.service.ts +++ b/src/services/ecogesture.service.ts @@ -62,7 +62,7 @@ export default class EcogestureService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } @@ -102,7 +102,7 @@ export default class EcogestureService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } else { @@ -178,7 +178,7 @@ export default class EcogestureService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } @@ -201,7 +201,7 @@ export default class EcogestureService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } diff --git a/src/services/enedisMonthlyAnalysisData.service.ts b/src/services/enedisMonthlyAnalysisData.service.ts index 7d893b96e..0b85f2cdc 100644 --- a/src/services/enedisMonthlyAnalysisData.service.ts +++ b/src/services/enedisMonthlyAnalysisData.service.ts @@ -145,7 +145,7 @@ export default class EnedisMonthlyAnalysisDataService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } diff --git a/src/services/fluidsPrices.service.ts b/src/services/fluidsPrices.service.ts index 64ad119f7..9225a454c 100644 --- a/src/services/fluidsPrices.service.ts +++ b/src/services/fluidsPrices.service.ts @@ -113,7 +113,7 @@ export default class FluidPricesService { const errorMessage = `deleteAllFluidsPrices: ${JSON.stringify(error)}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) return false } } @@ -153,7 +153,7 @@ export default class FluidPricesService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } diff --git a/src/services/initialization.service.ts b/src/services/initialization.service.ts index 8dd6d371c..1383331b4 100644 --- a/src/services/initialization.service.ts +++ b/src/services/initialization.service.ts @@ -109,7 +109,7 @@ export default class InitializationService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } @@ -134,7 +134,7 @@ export default class InitializationService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } @@ -153,7 +153,7 @@ export default class InitializationService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } @@ -214,7 +214,7 @@ export default class InitializationService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } @@ -245,7 +245,7 @@ export default class InitializationService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } else { @@ -284,7 +284,7 @@ export default class InitializationService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } @@ -315,7 +315,7 @@ export default class InitializationService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } else { @@ -355,7 +355,7 @@ export default class InitializationService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } @@ -386,7 +386,7 @@ export default class InitializationService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } else { @@ -429,7 +429,7 @@ export default class InitializationService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } @@ -463,7 +463,7 @@ export default class InitializationService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } else { @@ -509,7 +509,7 @@ export default class InitializationService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } @@ -539,7 +539,7 @@ export default class InitializationService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } @@ -569,7 +569,7 @@ export default class InitializationService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } @@ -602,7 +602,7 @@ export default class InitializationService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } @@ -628,7 +628,7 @@ export default class InitializationService { const errorMessage = `Initialization error - : ${JSON.stringify(error)}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } @@ -673,7 +673,7 @@ export default class InitializationService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } finally { logDuration('[Initialization] initConsent finished', startTime) diff --git a/src/services/mail.service.ts b/src/services/mail.service.ts index 9528efdfd..1e425524b 100644 --- a/src/services/mail.service.ts +++ b/src/services/mail.service.ts @@ -16,7 +16,7 @@ export default class MailService { const errorMessage = `Failed to send mail` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw new Error(errorMessage) } } diff --git a/src/services/partnersInfo.service.ts b/src/services/partnersInfo.service.ts index 18bf02ce5..624137ddc 100644 --- a/src/services/partnersInfo.service.ts +++ b/src/services/partnersInfo.service.ts @@ -39,7 +39,7 @@ export default class PartnersInfoService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) } } } diff --git a/src/services/profileType.service.ts b/src/services/profileType.service.ts index a5a2900fc..689a15fdf 100644 --- a/src/services/profileType.service.ts +++ b/src/services/profileType.service.ts @@ -533,7 +533,7 @@ export default class ProfileTypeService { const errorMessage = `fetchDju error : ${JSON.stringify(error)}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) return heatingData.dju_average_by_month[month - 1] } } diff --git a/src/services/profileTypeEntity.service.ts b/src/services/profileTypeEntity.service.ts index bb68839a1..7e44d4dfa 100644 --- a/src/services/profileTypeEntity.service.ts +++ b/src/services/profileTypeEntity.service.ts @@ -168,7 +168,7 @@ export default class ProfileTypeEntityService { const errorMessage = `deleteProfileTypes: ${JSON.stringify(error)}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) return false } } diff --git a/src/services/terms.service.ts b/src/services/terms.service.ts index c9c3061a9..ed20aea33 100644 --- a/src/services/terms.service.ts +++ b/src/services/terms.service.ts @@ -92,7 +92,7 @@ export default class TermsService { const errorMessage = `Error creating new term: ${JSON.stringify(error)}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw error } } diff --git a/src/services/triggers.service.ts b/src/services/triggers.service.ts index 830b22746..d3478fcfc 100644 --- a/src/services/triggers.service.ts +++ b/src/services/triggers.service.ts @@ -103,7 +103,7 @@ export default class TriggerService { const errorMessage = `Delete trigger failed: ${JSON.stringify(error)}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw new Error('Delete trigger failed') } } diff --git a/src/services/usageEvent.service.ts b/src/services/usageEvent.service.ts index 7b396168c..fca68e79d 100644 --- a/src/services/usageEvent.service.ts +++ b/src/services/usageEvent.service.ts @@ -106,7 +106,7 @@ export default class UsageEventService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) } } @@ -134,7 +134,7 @@ export default class UsageEventService { )}` logStack('error', errorMessage) logApp.error(errorMessage) - Sentry.captureException(errorMessage) + Sentry.captureException(error) throw new Error('Could not update all events') } } diff --git a/src/targets/services/aggregatorUsageEvents.ts b/src/targets/services/aggregatorUsageEvents.ts index 6bf0bda5d..56f17c02d 100644 --- a/src/targets/services/aggregatorUsageEvents.ts +++ b/src/targets/services/aggregatorUsageEvents.ts @@ -85,7 +85,7 @@ const sendIndicator = async ( 'error', `Error while sending indicator ${indicator.measureName} to remote doctype: ${errorMessage}` ) - Sentry.captureException(JSON.stringify({ error })) + Sentry.captureException(error) throw error } } @@ -1231,7 +1231,7 @@ const AggregatorUsageEvents = async ({ error += `${el.doctype}, ` }) logStack('error', error) - Sentry.captureException(JSON.stringify({ error })) + Sentry.captureException(error) throw error } diff --git a/src/targets/services/fluidsPrices.ts b/src/targets/services/fluidsPrices.ts index 8bdfe52b4..21b4e081a 100644 --- a/src/targets/services/fluidsPrices.ts +++ b/src/targets/services/fluidsPrices.ts @@ -99,7 +99,7 @@ const synchroPricesToUpdate = async ( }) } catch (error) { logStack('error', `Error: ${error}`) - Sentry.captureException(JSON.stringify({ error })) + Sentry.captureException(error) } }) ) @@ -186,7 +186,7 @@ const aggregatePrices = async ( } while (date < today) } catch (error) { logStack('info', `Error : ${error}`) - Sentry.captureException(JSON.stringify({ error })) + Sentry.captureException(error) } }) ) @@ -326,7 +326,7 @@ const applyPrices = async (client: Client, fluidType: FluidType) => { } while (date < today) } catch (error) { logStack('error', `ERROR : ${error} `) - Sentry.captureException(JSON.stringify({ error })) + Sentry.captureException(error) } }) ) diff --git a/src/targets/services/monthlyReportNotification.ts b/src/targets/services/monthlyReportNotification.ts index 352409998..5f201313c 100644 --- a/src/targets/services/monthlyReportNotification.ts +++ b/src/targets/services/monthlyReportNotification.ts @@ -139,7 +139,7 @@ const getMonthlyReport = async ( return result } catch (error) { logStack('error', JSON.stringify(error)) - Sentry.captureException(JSON.stringify({ error })) + Sentry.captureException(error) return { year: parseInt(year), month: parseInt(month), @@ -178,7 +178,7 @@ const monthlyReportNotification = async ({ }) } catch (error) { logStack('error', 'Update mailToken user profile error : ' + error) - Sentry.captureException(JSON.stringify({ error })) + Sentry.captureException(error) throw error } } -- GitLab