From 3dcedd3cd50922cc66fceabd1d0ae059dcf3d28c Mon Sep 17 00:00:00 2001 From: Sunny Kolattukudy Date: Sat, 21 Mar 2026 05:49:23 -0400 Subject: [PATCH] =?UTF-8?q?fix(appinsights):=20=F0=9F=90=9B=20explicitly?= =?UTF-8?q?=20import=20JS=20module=20before=20interop=20calls=20to=20fix?= =?UTF-8?q?=20undefined=20blazorApplicationInsights?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/ApplicationInsightsInit.razor.cs | 7 +++++++ 1 file changed, 7 insertions(+) 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