#
So I don’t have to do a lot of coding using the SDK? Just import the SDK library, flip on 1 setting app-wide, and let it sit around and listen
While the Application Insights SDK does offer some automatic data collection with minimal setup, it’s not quite as simple as just importing the library and flipping one switch. Here’s a more accurate picture:
- You do need to add the Application Insights SDK to your application. This typically involves installing a package and adding some initialization code1.
- For basic telemetry, you’ll need to configure the SDK with your Application Insights resource’s connection string or instrumentation key1.
- Some features, like tracking page visit time, can be enabled by setting a single configuration option. For example, setting
autoTrackPageVisitTime: true
will automatically track the time users spend on each page23. - However, for more comprehensive monitoring, you’ll likely need to add some custom instrumentation:
- The level of automatic data collection depends on your application type and the SDK version you’re using. Web applications typically get more out-of-the-box tracking than other types of applications6.
- While the SDK does “sit around and listen” to some extent, you often need to actively instrument important parts of your code for the most valuable insights47.
In summary, while Application Insights does offer some automatic telemetry, getting the most value usually requires more than just importing the SDK and enabling a single setting. It’s designed to be relatively easy to implement, but some level of custom instrumentation is typically necessary for comprehensive monitoring67.
But things like user session duration will work with just app-wide config?
Yes, user session duration tracking can be enabled with minimal app-wide configuration in Azure Application Insights. By setting autoTrackPageVisitTime: true
in your Application Insights configuration, you can automatically track the time users spend on each page89.
This setting works as follows:
- It tracks the time spent on the previous page when a new page view occurs.
- The data is sent as a custom metric named “PageVisitTime” in milliseconds10.
- It uses the Date.now() function if available, or falls back to (new Date()).getTime() for older browsers10.
However, it’s important to note:
- You still need to properly initialize the Application Insights SDK in your application with the correct instrumentation key or connection string9.
- While this provides basic session duration tracking, more complex session analytics might require additional configuration or custom event tracking1112.
- The default session timeout is 30 minutes of inactivity, but this can be customized using
sessionRenewalMs
andsessionExpirationMs
settings1112.
Remember that while this app-wide configuration provides valuable data, getting the most comprehensive insights often requires some level of custom instrumentation beyond just the basic setup13.
-
https://stackoverflow.com/questions/45761999/azure-application-insights-to-track-time-spent-by-user-on-webpage ↩ ↩2
-
https://learn.microsoft.com/en-us/azure/azure-monitor/app/javascript-sdk-configuration ↩
-
https://blog.trustedtechteam.com/2021-03-31-youve-heard-of-application-insights-right/ ↩ ↩2
-
https://www.reddit.com/r/AZURE/comments/18j00zy/exploring_the_app_insights_sdk/ ↩
-
https://learn.microsoft.com/en-us/azure/azure-monitor/app/usage ↩ ↩2
-
https://stackoverflow.com/questions/45761999/azure-application-insights-to-track-time-spent-by-user-on-webpage ↩
-
https://search.r-project.org/CRAN/refmans/AzureAppInsights/html/config.html ↩ ↩2
-
https://learn.microsoft.com/en-us/azure/azure-monitor/app/javascript-sdk-configuration ↩ ↩2
-
https://github.com/Huachao/azure-content/blob/master/articles/application-insights/app-insights-web-track-usage.md ↩ ↩2
-
https://www.patrickvankleef.com/2018/02/07/application-insights-user-telemetry-data-send-to-azure/ ↩ ↩2
-
https://github.com/microsoft/ApplicationInsights-Announcements/issues/10 ↩