From e6c3fef05b839c4730f18278604f3ad367a6f512 Mon Sep 17 00:00:00 2001 From: yuli-ferna Date: Mon, 15 Jul 2024 10:06:30 -0400 Subject: [PATCH 1/2] Message errors for telemetry --- apps/connect/src/providers/telemetry.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/apps/connect/src/providers/telemetry.ts b/apps/connect/src/providers/telemetry.ts index 1846c287b..bbc51e05a 100644 --- a/apps/connect/src/providers/telemetry.ts +++ b/apps/connect/src/providers/telemetry.ts @@ -21,6 +21,22 @@ const sendEvent = (e: any) => { } }; let lastChain: string; + +/* eslint-disable @typescript-eslint/no-explicit-any */ +const getErrorMessage = (error: any) => { + let message = ""; + if (error?.code) { + message += `Code: ${error.code} `; + } + if (error?.name) { + message += `Name: ${error.name} `; + } + if (error?.message) { + message += `Message: ${error.message}`; + } + return message; +} + /* eslint-disable @typescript-eslint/no-explicit-any */ export const eventHandler = (e: any) => { // Ignore the load event @@ -99,9 +115,8 @@ export const eventHandler = (e: any) => { } attributes["route"] = routeName; if (e.type === "transfer.error" || e.type === "transfer.redeem.error") { - console.log("Error", e.error?.original); attributes["error-type"] = e.error.type || "unknown"; - attributes["error-message"] = e.error?.original?.message || ""; + attributes["error-message"] = getErrorMessage(e.error?.original); } // Transfer event information From f1f5e96ec7a7d73502276844bb5ab933f2f3b56b Mon Sep 17 00:00:00 2001 From: yuli-ferna Date: Mon, 15 Jul 2024 10:59:41 -0400 Subject: [PATCH 2/2] Fix prettier --- apps/connect/src/providers/telemetry.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/connect/src/providers/telemetry.ts b/apps/connect/src/providers/telemetry.ts index bbc51e05a..bccb46367 100644 --- a/apps/connect/src/providers/telemetry.ts +++ b/apps/connect/src/providers/telemetry.ts @@ -35,7 +35,7 @@ const getErrorMessage = (error: any) => { message += `Message: ${error.message}`; } return message; -} +}; /* eslint-disable @typescript-eslint/no-explicit-any */ export const eventHandler = (e: any) => {