Skip to content

Commit

Permalink
feat: allow disabling of wasm init
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanJosipovic committed Dec 15, 2023
1 parent 42a6ace commit 9816a7a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion samples/BlazorApplicationInsights.Sample.Wasm/App.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ApplicationInsightsInit IsWasmStandalone="true" />
<ApplicationInsightsInit IsWasmStandalone="true" IsWasmManualInit="true" />
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ public partial class ApplicationInsightsInit
[Parameter]
public bool IsWasmStandalone { get; set; }

/// <summary>
/// When enabled this library will not call UpdateCfg and configuration must be set manually in the index.html
/// </summary>
[Parameter]
public bool IsWasmManualInit { get; set; }

private string script { get; set; }

private static readonly JsonSerializerOptions SerializerOptions = new() { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull };
Expand All @@ -46,7 +52,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
{
await JSRuntime.InvokeAsync<IJSObjectReference>("import", "./_content/BlazorApplicationInsights/JsInterop.js");

if (Config.Config != null)
if (Config.Config != null && !IsWasmManualInit)
{
await ApplicationInsights.UpdateCfg(Config.Config);

Expand Down

0 comments on commit 9816a7a

Please sign in to comment.