There is a WPF application written in Visual Studio. Can I add Application Insights to this WPF app? I would like to know how many times a button/tile is clicked. Since there are multiple installations of the same application, I would like to know which button was clicked how many times from which user/installation. Can this be done with Application Insights?
Thanks Avanti
Application Insights is a feature of Azure Monitor that provides extensible application performance management (APM) and monitoring for live web apps. Developers and DevOps professionals can use Application Insights to: Automatically detect performance anomalies. Help diagnose issues by using powerful analytics tools.
While not listed as a supported app type this means there isn't default telemetry data collected/sent to application insights nor is there support for adding AI/creating an application insights resource. That being said it is possible to add to your WPF with a few manual steps so that you can track the specific scenarios you mention (like a button/tile click).
-From Visual studio add the "Application Insights API" NuGet to the project (.11 is the latest today).
This will add the Application Insights API reference and create an application insights configuration file to your project.
The applicationinsights.config file needs to be updated with your instrumentation key as follows:
<?xml version="1.0" encoding="utf-8"?> <ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings" schemaVersion="2014-05-30"> <TelemetryChannel> <DeveloperMode>false</DeveloperMode> </TelemetryChannel> <TelemetryModules> <Add Type="Microsoft.ApplicationInsights.Tracing.DiagnosticsTelemetryModule, Microsoft.ApplicationInsights"/> </TelemetryModules> <InstrumentationKey>**your-instrumentation-key-guid**</InstrumentationKey> </ApplicationInsights>
To create an application insights instrumentation key login to your azure subscription. https://portal.azure.com Click + to create an Application Insights resource. Then choose the properties tile on the application insights blade and copy the Instrumentation key and add it to your applicationinsights.config file. Now in your WPF app you can use the Application Insights sdk as described here: http://blogs.msdn.com/b/visualstudioalm/archive/2014/10/21/application-insights-sdk-0-11-0-prerelease.aspx
your events will be visible in the diagnostic search blade which can be selected on the application insights blade.
Note: telemetry is batched locally for 1 min before being sent to the service unless > 500 telemetry events are queued at which point they are sent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With