Skip to content

Commit

Permalink
fix(types): Add better types to Airbrake logging (#2791)
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr authored Feb 15, 2024
1 parent 21da665 commit 4148a21
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 6 additions & 8 deletions api.planx.uk/modules/send/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ export async function logPaymentStatus({
}): Promise<void> {
if (!flowId || !sessionId) {
reportError({
message:
"Could not log the payment status due to missing context value(s)",
error: "Could not log the payment status due to missing context value(s)",
context: { sessionId, flowId, teamSlug },
});
} else {
Expand All @@ -38,21 +37,20 @@ export async function logPaymentStatus({
});
} catch (e) {
reportError({
message: "Failed to insert a payment status",
error: e,
govUkResponse,
error: `Failed to insert a payment status: ${e}`,
context: { govUkResponse },
});
}
}
}

// tmp explicit error handling
export function reportError(obj: object) {
export function reportError(report: { error: any; context: object }) {
if (airbrake) {
airbrake.notify(obj);
airbrake.notify(report);
return;
}
log(obj);
log(report);
}

// tmp logger
Expand Down
8 changes: 5 additions & 3 deletions api.planx.uk/modules/webhooks/service/validateInput/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ export const isCleanHTML = (input: unknown): boolean => {
*/
const logUncleanHTMLError = (input: string, cleanHTML: string) => {
reportError({
message: `Warning: Unclean HTML submitted!`,
input,
cleanHTML,
error: `Warning: Unclean HTML submitted!`,
context: {
input,
cleanHTML,
},
});
};

0 comments on commit 4148a21

Please sign in to comment.