diff --git a/api.planx.uk/modules/send/utils/helpers.ts b/api.planx.uk/modules/send/utils/helpers.ts index d527360434..06db45b327 100644 --- a/api.planx.uk/modules/send/utils/helpers.ts +++ b/api.planx.uk/modules/send/utils/helpers.ts @@ -21,8 +21,7 @@ export async function logPaymentStatus({ }): Promise { 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 { @@ -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 diff --git a/api.planx.uk/modules/webhooks/service/validateInput/utils.ts b/api.planx.uk/modules/webhooks/service/validateInput/utils.ts index 628aee405d..3f8b772598 100644 --- a/api.planx.uk/modules/webhooks/service/validateInput/utils.ts +++ b/api.planx.uk/modules/webhooks/service/validateInput/utils.ts @@ -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, + }, }); };