Skip to content

Wire Blazor WebView unhandled exceptions to App Insights #169

@davidortinau

Description

@davidortinau

Tracking issue surfaced during PR #166.

Gap

PR #166 wires server-side (API) exceptions into App Insights via UseExceptionHandler + OTel. Mobile app unhandled .NET exceptions are wired via AppDomain.CurrentDomain.UnhandledException + iOS/Android platform handlers (PR #165).

Unhandled JavaScript exceptions inside the Blazor WebView are NOT captured. A JS-side throw or unhandled Promise rejection is invisible to App Insights.

Work required

  • In the Blazor WebView's root JS (likely wwwroot/index.html or an injected bootstrap script), register:
    • window.addEventListener('error', ...) — synchronous and resource errors
    • window.addEventListener('unhandledrejection', ...) — async/Promise errors
  • Forward captured errors to the .NET side via DotNet.invokeMethodAsync or the existing JS-interop channel
  • On the .NET side, enrich with the current OTel Activity context (so JS errors share operation_Id with the API call that triggered them) and emit as an exception to App Insights
  • Verify in App Insights that JS errors appear in the exceptions table with correct cloud_RoleName and operation_Id

Context: PR #166

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions