Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve message errors for telemetry #927

Merged
merged 2 commits into from
Jul 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading