Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Add contexts to sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
anduong96 committed Dec 22, 2023
1 parent 146dcee commit 46f24ec
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
25 changes: 17 additions & 8 deletions src/services/airport.weather/get.airport.weather.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async function getAirport(airportIata: string) {
isNil(airport.timezone)
) {
Sentry.captureException(new Error('Airport is missing location data'), {
extra: {
contexts: {
airport,
},
});
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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());
});

Expand Down
6 changes: 5 additions & 1 deletion src/services/flight/get.flight.emissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
6 changes: 5 additions & 1 deletion src/services/flight/populate.flights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 46f24ec

Please sign in to comment.