From 46f24ec67730cf7d067e2e0bbdd0b0766a6e8d2c Mon Sep 17 00:00:00 2001 From: An Duong Date: Fri, 22 Dec 2023 09:19:00 -0500 Subject: [PATCH] Add contexts to sentry --- .../airport.weather/get.airport.weather.ts | 25 +++++++++++++------ src/services/flight/get.flight.emissions.ts | 6 ++++- src/services/flight/populate.flights.ts | 6 ++++- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/services/airport.weather/get.airport.weather.ts b/src/services/airport.weather/get.airport.weather.ts index a56afb9..1fcb32c 100644 --- a/src/services/airport.weather/get.airport.weather.ts +++ b/src/services/airport.weather/get.airport.weather.ts @@ -29,7 +29,7 @@ async function getAirport(airportIata: string) { isNil(airport.timezone) ) { Sentry.captureException(new Error('Airport is missing location data'), { - extra: { + contexts: { airport, }, }); @@ -102,12 +102,14 @@ export async function getAirportWeather( } } else if (throwIfNotFound) { Sentry.captureException(new Error('Airport weather not found'), { - extra: { - airportIata, - date, - hour, - month, - year, + contexts: { + query: { + airportIata, + date, + hour, + month, + year, + }, }, }); Logger.error( @@ -146,7 +148,14 @@ export async function getAirportWeather( : await getPayloadFromMetNo(airport).catch((error: Error) => { Logger.debug('getAirportWeather:: error=%s', error.message); Logger.error(error); - Sentry.captureException(error); + Sentry.captureException(error, { + contexts: { + query: { + airport, + requestingDate, + }, + }, + }); return getPayloadFromWeatherApi(airport, requestingDate.toDate()); }); diff --git a/src/services/flight/get.flight.emissions.ts b/src/services/flight/get.flight.emissions.ts index d5b31c8..2026332 100644 --- a/src/services/flight/get.flight.emissions.ts +++ b/src/services/flight/get.flight.emissions.ts @@ -30,7 +30,11 @@ export async function getFlightEmissions( }; } catch (error) { Logger.error('Unable to get flight details from Flightera', error); - Sentry.captureException(error); + Sentry.captureException(error, { + contexts: { + flight: params, + }, + }); return null; } } diff --git a/src/services/flight/populate.flights.ts b/src/services/flight/populate.flights.ts index f941467..dc145fd 100644 --- a/src/services/flight/populate.flights.ts +++ b/src/services/flight/populate.flights.ts @@ -34,7 +34,11 @@ function getFlights(params: FlightQueryParam) { ? getFlightsPayloadFromFlightStats(params) : getFlightsPayloadFromAeroDataBox(params); } catch (error) { - Sentry.captureException(error); + Sentry.captureException(error, { + contexts: { + params, + }, + }); return getFlightsPayloadFromAeroDataBox(params); } }