i.e. I have a controller action:
public ActionResult Details(int? id)
{
telemetryClient.TrackEvent("CompanyDetailPage");
if (id == null)
{
return RedirectToAction("Error", "Error", new { Text = "id is not specified" });
}
var company = _companyService.CompanyDetail(id.Value);
if (company == null)
{
return RedirectToAction("Error", "Error", new { Text = "Invalid company id" });
}
// create model here and return to client view
return View(model);
}
Now I want to add a notification when:
- User calls method without id
- User passes invalid id
what is correct way to do it?
Add event (metric) like "CompanyDetailPageNullId", "CompanyDetailPageInvalidId"? But for CompanyDetailPageInvalidId I need to pass id also.
Add event (metric) like "CompanyDetailPageError" and pass in parameters what is a problem?
Or, probably, track a trace?