Skip to content

Commit

Permalink
Improve message errors for telemetry (#927)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuli-ferna authored Jul 15, 2024
1 parent e59058c commit 3e3a28a
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions apps/connect/src/providers/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3e3a28a

Please sign in to comment.