Using this library we are sending information from the client side of my OutSystems application to AppInsights. Calling the "Init" and "SetAuthenticatedUserContext" client actions from the OnApplicationReady of my UI module.
We are also using Application Management Dashboard to monitor applications. And we realized a difference in the number of users, getting less with AppInsights.
We think that the problem is that the OnApplicationReady event fires after the module loads. Initially there is no user information since we are not authenticated in OS (UserId=0). We believe this is what is causing users in AppInsights to go uncounted.
Where should we call the "SetAuthenticatedUserContext" client action to get correct results?
According to Application Insights API for custom events and metrics - Azure Monitor | Microsoft Learn, you should call this after a user has been authenticated. Wherever you do your login, call it once a user has successfully logged in.