diff --git a/packages/app-insights/src/node.ts b/packages/app-insights/src/node.ts index fcdd069e8..6f6546eb5 100644 --- a/packages/app-insights/src/node.ts +++ b/packages/app-insights/src/node.ts @@ -4,10 +4,18 @@ import type { TelemetryClient } from 'applicationinsights'; export const normalizeError = (error: unknown) => { const normalized = error instanceof Error ? error : new Error(String(error)); - // Add message if empty otherwise Application Insights will respond 400 - // and the error will not be recorded. + /** + * - Ensure the message if not empty otherwise Application Insights will respond 400 + * and the error will not be recorded. + * - We stringify error object here since other error properties won't show on the + * ApplicationInsights details page. + */ // eslint-disable-next-line @silverhand/fp/no-mutation - normalized.message ||= 'Error occurred.'; + normalized.message = JSON.stringify( + error, + // ApplicationInsights shows call stack, no need to stringify + Object.getOwnPropertyNames(error).filter((value) => value !== 'stack') + ); return normalized; };