I am wondering how applications work with cookies because I would like to understand user and session tracking, so I studied and ...
Here is a brief introduction to the theory:
Whenever the Application Insights SDK receives a request that does not have a proxy for tracking user cookie tracking (as installed by the Insight JS application fragment), it will set this cookie and start a new session. (from apmtips )
2.
UserTelemetryInitializer updates the Id and AcquisitionDate properties of the User context for all telemetry elements with values retrieved from the ai_user cookie generated by the Application Insights JavaScript application code running in the user's browser.
SessionTelemetryInitializer updates the Session context's Id property for all telemetry elements with a value retrieved from the ai_session cookie generated by the JavaScript ApplicationInsights tool code running in the user's browser. (from azure documentation (configuring Insight SKD application with ApplicationInsights.config) )
So there are two cookies: ai_session and ai_user .
And here are my questions:
- When are they initialized?
- What does it do?
- How can I stop using them?
- If I wanted to save them, how can I change their expiration time?
Trying to remove them, I made a project using ASP.NET web applications using the default template for Web Api, which includes MVC and Web Api.
After researching, I found this approach to disable them, but I have no WebSessionTrackingTelemetryModule method. So I commented on "UserTelemetryInitializer" and "SessionTelemetryInitializer", and this is what I have:
<TelemetryInitializers> <Add Type="Microsoft.ApplicationInsights.Extensibility.Web.SyntheticTelemetryInitializer, Microsoft.ApplicationInsights.Extensibility.Web" /> <Add Type="Microsoft.ApplicationInsights.Extensibility.Web.ClientIpHeaderTelemetryInitializer, Microsoft.ApplicationInsights.Extensibility.Web" /> <Add Type="Microsoft.ApplicationInsights.Extensibility.Web.UserAgentTelemetryInitializer, Microsoft.ApplicationInsights.Extensibility.Web" /> <Add Type="Microsoft.ApplicationInsights.Extensibility.Web.OperationNameTelemetryInitializer, Microsoft.ApplicationInsights.Extensibility.Web" /> <Add Type="Microsoft.ApplicationInsights.Extensibility.Web.OperationIdTelemetryInitializer, Microsoft.ApplicationInsights.Extensibility.Web" /> <Add Type="Microsoft.ApplicationInsights.Extensibility.Web.AzureRoleEnvironmentTelemetryInitializer, Microsoft.ApplicationInsights.Extensibility.Web" /> <Add Type="Microsoft.ApplicationInsights.Extensibility.Web.DomainNameRoleInstanceTelemetryInitializer, Microsoft.ApplicationInsights.Extensibility.Web" /> <Add Type="Microsoft.ApplicationInsights.Extensibility.Web.BuildInfoConfigComponentVersionTelemetryInitializer, Microsoft.ApplicationInsights.Extensibility.Web" /> <Add Type="Microsoft.ApplicationInsights.Extensibility.Web.DeviceTelemetryInitializer, Microsoft.ApplicationInsights.Extensibility.Web" /> </TelemetryInitializers>
AND:
<TelemetryModules> <Add Type="Microsoft.ApplicationInsights.Extensibility.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.ApplicationInsights.Extensibility.DependencyCollector" /> <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.PerformanceCollectorModule, Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector"/> <Add Type="Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule, Microsoft.ApplicationInsights" /> <Add Type="Microsoft.ApplicationInsights.Extensibility.Web.RequestTrackingTelemetryModule, Microsoft.ApplicationInsights.Extensibility.Web"/> <Add Type="Microsoft.ApplicationInsights.Extensibility.Web.ExceptionTrackingTelemetryModule, Microsoft.ApplicationInsights.Extensibility.Web" /> <Add Type="Microsoft.ApplicationInsights.Extensibility.Web.DeveloperModeWithDebuggerAttachedTelemetryModule, Microsoft.ApplicationInsights.Extensibility.Web" /> </TelemetryModules>
But it does not matter. Either I leave the modules commented, or not, cookies are still generated.
Trying to delete cookies, I commented on the actions taken in Startup and excluded all .js files from my project, but cookies continue to appear after each request.
So, at this moment, I don’t understand where “Javascript” is happening, and I assume that what I am missing is something in the backend. I am wrong?
Finally, my Startup.cs comment looks like this:
[assembly: OwinStartupAttribute(typeof(Try001.Startup))] namespace Try001 { public partial class Startup { public void Configuration(IAppBuilder app) {
And my Global.asax.cs file looks like this:
public class MvcApplication : System.Web.HttpApplication { protected void Application_Start() {
Where RegisterRoutes just does the default routing. Therefore, I tried to do only the simplest things to make it work, but I do not know where to continue to dig.
Can anyone enlighten me?
Thanks for reading so far.