Skip to content

A Blazor interop library that sets up client-side Application Insights

License

Notifications You must be signed in to change notification settings

soenneker/soenneker.blazor.applicationinsights

Repository files navigation

Soenneker.Blazor.ApplicationInsights

A Blazor interop library that sets up client-side Azure Application Insights.

Installation

dotnet add package Soenneker.Blazor.ApplicationInsights

Usage

  1. Insert the script in wwwroot/index.html at the bottom of your <body> but before the other scripts
<script src="_content/Soenneker.Blazor.ApplicationInsights/applicationinsights.js"></script>
  1. Register the interop within DI (Program.cs)
public static async Task Main(string[] args)
{
    ...
    builder.Services.AddApplicationInsights();
}
  1. Inject IApplicationInsightsInterop within your App.Razor file
@using Soenneker.Blazor.ApplicationInsights.Abstract
@inject IApplicationInsightsInterop AppInsightsInterop
  1. Initialize the interop in OnInitializedAsync within App.Razor using your Clarity project key
protected override async Task OnInitializedAsync()
{
    await AppInsightsInterop.Init("your-connection-string-here");
    ...
}

About

A Blazor interop library that sets up client-side Application Insights

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •  

Languages