aspnetcore
aspnetcore copied to clipboard
Web analytics and diagnostics
- [ ] Integration with web analytics systems (ex Azure Application Insights, Google Analytics)
Does Serilog "just work" for something like this?
https://github.com/serilog/serilog/wiki/Provided-Sinks
In general, .NET Standard 2.0 libraries should work from a Blazor app. Which sinks are most interesting to you?
Azure Application Insights and Seq, https://getseq.net, are the two I use most often.
I playing with setting up Application Insights inside Blazor. That seems trivial task if I just copy paste JS initialization code inside index.hml
. Then I could interop using JS api At the same time this does not allow me to set Instrumentation Key. Same question if I attempt to run AI inside Blazor's .NET code. I need somehow pass Instrumentation Key for configuration purposes. Any ideas how this could be done right now ?
At the same time this does not allow me to set Instrumentation Key.
Why not? Isn't the instrumentation key typically embedded in the JS code? https://docs.microsoft.com/en-us/azure/application-insights/app-insights-javascript#add-the-sdk-script-to-your-app-or-web-pages
I have project which will use different AI accounts for staging and for production. (Assuming that Blazor will take off). Also I use same AI key for API and for Blazor application, which require me to sync them, or worse - ask customer to manually replace AI key in two places.
In the ASP.NET Core (and regular ASP.NET and just AI SDK) I without problem could change AI key using appsettings.json
. Would be good to have this in the Blazor as well.
Since Blazor use index.html for serving application, and at the same time there no way to pass command line parameters when I embed Blazor in ASP.NET Core website (no parameters here app.UseBlazor<BlazorApp1.Program>();
). It may be not about AI itself, but rather ability to pass configuration from the application hosting Blazor.
Hi, I just created a Google Analytics extension for Blazor. I think it could be relevant to this ticket. https://github.com/isc30/blazor-analytics
This library can be extended for multiple analytics providers easily (+add TrackingService for complex operations)
Hi, I just created a Google Analytics extension for Blazor. I think it could be relevant to this ticket. https://github.com/isc30/blazor-analytics
This library can be extended for multiple analytics providers easily (+add TrackingService for complex operations)
I hope you don't mind but I have used your library for inspiration to implement as you suggest. https://github.com/robdavey555/Blazor.ApplicationInsights
Is there any update on this?
I would prefer to use dotnet rather than js to send telemetry events, as this would allow for easily consuming existing logging code in a wasm app.
Hi all,
I also would prefer registering AI instance into IoC container on the program.cs, like HttpClient, and then inject telemetry client each .razor pages. Otherwise, we can't track C# exceptions in a proper way.
Many Thanks
I just released https://github.com/IvanJosipovic/BlazorApplicationInsights It hooks all logging to App Insights and supports App Insights Apis like Track Event etc.
@kant2002
In the ASP.NET Core (and regular ASP.NET and just AI SDK) I without problem could change AI key using
appsettings.json
. Would be good to have this in the Blazor as well.
Check out https://docs.microsoft.com/en-us/aspnet/core/blazor/fundamentals/configuration?view=aspnetcore-5.0#app-settings-configuration
Specifically this section (no direct link available)
Since different environments typically have different configurations (i.e. Instrumentation Key), your deployment process should be responsible for putting the correct file (i.e. $"{environment}.json"
) in the deployed application. Then in your Startup class use builder.HostEnvironment.Environment
to interpolate the filename if you need it in your Blazor app.
You can also load this file in index.html and set it with the AI JS SDK.
This should enable the functionality you require.
Might be related to #30972
@danroth27 Is there an ETA for this? This issue has been languishing for over 4 years now; almost two years after @SteveSandersonMS has labelled it as a major severity. We had expected this to be ready with .net 6 release. The implication is that it is creating strong headwinds against us convincing folks #BlazorWASM has critical mass and is production ready.
@danroth27 Is there an ETA for this? This issue has been languishing for over 4 years now; almost two years after @SteveSandersonMS has labelled it as a major severity. We had expected this to be ready with .net 6 release. The implication is that it is creating strong headwinds against us convincing folks #BlazorWASM has critical mass and is production ready.
You can use the javascript appinsights sdk -> same with google analytics.
In my production app we use the following packages https://github.com/IvanJosipovic/BlazorApplicationInsights https://github.com/isc30/blazor-analytics
both are working very well without much work to setup
@CoryKoehler We are aware of the two packages [they have cropped up earlier in this thread years back ]. But the recent log4j scare has completely changed the landscape; especially in the enterprise sector. Mind you, they are official AppInsights plugins for react and angular; we are demanding parity for BlazorWASM and we solicit your support in this regard.
Hello, I am coming from - https://github.com/microsoft/ApplicationInsights-dotnet/issues/2143 that has referenced this issue. Also alternative - https://feedback.azure.com/d365community/idea/4f959530-1425-ec11-b6e6-000d3a4f09d0
Please inform us about plan and status for supporting Application insights in .NET 6 SDK via dotnet new blazorwasm
Thank you
For folks considering jumping from react to blazor, please add native blazor wasm support for Azure AI
I can confirm that this is causing headwinds for the same reasons @indcoder pointed out. Enterprise sentiment has shifted negatively towards third-party logging providers and having native support for Azure AI is definitely crucial. A similar discussion can be found at https://github.com/microsoft/ApplicationInsights-dotnet/issues/2143 @danroth27 is native Azure AI support something that the Blazor Team would even consider doing or is the SDK Team solely responsible for that? Their current status is 'this is not being actively worked on by anyone in the SDK team' - so hopefully not a ping-pong problem.
After 4 years I still haven't been able to associate logs with username or current url in Blazor Server. How this cannot be prioritized is beyond my understanding
@Liero I think that this should be resolved under Application Insights team and their SDK which should support Blazor WASM here is feature request - https://github.com/microsoft/ApplicationInsights-dotnet/issues/2143