Search code examples
azure-application-insightstelemetry

What to use as session id in application insights


I am considering adding some support in our app-backend to enable users and sessions to enable the analytics features in application insights.

As far as my understanding goes, i need to annotate the telemetry I send with user id and a session id.

For user id we have an id that is static for a user over time.

For the session id i am a bit puzzled on what to do.

  1. Will I, in the Azure portal, benefit from just inserting the user Id in the telemetry, without a sessionId
  2. What can i use as a sessionkey that is meaningfull? The backend is used by some apps that can not easily be modified

Solution

  • Application Insights have fields for three different identifiers. Expectations:

    1. UserId - user identifier, either stable id [never changes for this user] or at least same id across many sessions
    2. SessionId - session identifier [think about one browser session]
    3. OperationId - operation identifier [think about one operation, such as "login" or "buy a car"], multiple operations per session

    If data in these identifiers follow above guidelines - this will result in the best user experience.

    On another side, if, for instance, all three identifiers are initialized with UserId, then Transaction view will become unusable since it will show everything what user did ever and individual transactions (such as "buy a car") will be very hard to troubleshoot using this particular view.