diff --git a/src/Imagile.Framework.Blazor.ApplicationInsights/Components/ApplicationInsightsInit.razor.cs b/src/Imagile.Framework.Blazor.ApplicationInsights/Components/ApplicationInsightsInit.razor.cs index f88e968..3afb1a8 100644 --- a/src/Imagile.Framework.Blazor.ApplicationInsights/Components/ApplicationInsightsInit.razor.cs +++ b/src/Imagile.Framework.Blazor.ApplicationInsights/Components/ApplicationInsightsInit.razor.cs @@ -62,6 +62,13 @@ protected override async Task OnAfterRenderAsync(bool firstRender) ApplicationInsights.InitJSRuntime(JSRuntime); + // Explicitly import the JS module to ensure window.blazorApplicationInsights is defined. + // The .lib.module.js auto-loading mechanism is not reliable for NuGet-distributed RCLs, + // so we import it explicitly here before making any interop calls. + await JSRuntime.InvokeAsync( + "import", + "./_content/Imagile.Framework.Blazor.ApplicationInsights/Imagile.Framework.Blazor.ApplicationInsights.lib.module.js"); + if (Config.Config != null) { try