I have a Web Application and want to track user logins in AppInsights with the following code:
[HttpPost]
public async Task<ActionResult> Login(AccountViewModel model, string returnUrl)
{
var success = await _userManager.CheckPasswordAsync(model);
_telemetryClient.TrackEvent("Login",
new Dictionary<string, string>
{
{ "UserName", model.UserName },
{ "UsingPin", model.UsingPin.ToString()},
{ "ReturnUrl", returnUrl},
{ "LastUsedUrl", model.LastUsedUrl },
{ "Success", success.ToString() }
});
return View(model);
}
The code works, I get events in analytics portal... but only a subset of events! In the sessions table on the database side I have about 1000 unique user logins, but AI reports around 100...
What I have already checked:
- _telemetryClient is a singleton configured through Unity (
<lifetime type="singleton" />
) - there is no quota configured in Azure portal
- I have more than 1000 POST requests to the Login method, this looks just right (I mean every request comes to this exact server, returns 200 status, etc.)
So it looks like Azure just drops some of custom events... or they are not send to azure for some reason. Is there any configuration part I am missing?
_telemetryClient.Flush();
– Peter Bons