https://github.com/soenneker/soenneker.blazor.applicationinsights
A Blazor interop library that sets up client-side Application Insights
https://github.com/soenneker/soenneker.blazor.applicationinsights
application-insights blazor csharp dotnet interop
Last synced: 25 days ago
JSON representation
A Blazor interop library that sets up client-side Application Insights
- Host: GitHub
- URL: https://github.com/soenneker/soenneker.blazor.applicationinsights
- Owner: soenneker
- License: mit
- Created: 2023-01-06T01:31:43.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2026-05-30T06:26:37.000Z (about 1 month ago)
- Last Synced: 2026-05-30T08:12:15.946Z (about 1 month ago)
- Topics: application-insights, blazor, csharp, dotnet, interop
- Language: C#
- Homepage:
- Size: 1.93 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
[](https://www.nuget.org/packages/Soenneker.Blazor.ApplicationInsights/)
[](https://github.com/soenneker/soenneker.blazor.applicationinsights/actions/workflows/publish-package.yml)
[](https://www.nuget.org/packages/Soenneker.Blazor.ApplicationInsights/)
[](https://github.com/soenneker/soenneker.blazor.applicationinsights/actions/workflows/codeql.yml)
#  Soenneker.Blazor.ApplicationInsights
### A Blazor interop library that sets up client-side Azure [Application Insights](https://learn.microsoft.com/en-us/azure/azure-monitor/app/app-insights-overview?tabs=net).
## Installation
```
dotnet add package Soenneker.Blazor.ApplicationInsights
```
## Usage
1. Register the interop within DI (`Program.cs`)
```csharp
public static async Task Main(string[] args)
{
...
builder.Services.AddApplicationInsightsInteropAsScoped();
}
```
2. Inject `IApplicationInsightsInterop` within your `App.Razor` file
```csharp
@using Soenneker.Blazor.ApplicationInsights.Abstract
@inject IApplicationInsightsInterop AppInsightsInterop
```
3. Call the interop from `OnAfterRenderAsync` in `App.razor`.
```csharp
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (!firstRender)
return;
await AppInsightsInterop.Init("your-connection-string-here");
}
```