angular-application-insights
angular-application-insights copied to clipboard
i wanted to make a heartbeat in my angular application
when the application go offline i want to get an alert or i can know from azure Monitoring dashboard. also i can't finish any reference to use TrackRequest ?
My understanding from using ApplicationInsights is that Requests are typically for the server-side logging of requests made to an API. Typically all the interactions from the client-side (i.e. the Angular SPA), are through PageViews, Events, etc.
For your use-case, I would consider using TrackEvent instead.
// app-insight.service.ts (this package)
// https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md#trackevent
/**
* Log a user action or other occurrence.
* @param name A string to identify this event in the portal.
* @param properties map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty.
* @param measurements map[string, number] - metrics associated with this event, displayed in Metrics Explorer on the portal. Defaults to empty.
*/
trackEvent(eventName: string, eventProperties?: { [name: string]: string }, metricProperty?: { [name: string]: number }) {
try {
AppInsights.trackEvent(eventName, eventProperties, metricProperty);
} catch (ex) {
console.warn('Angular application insights Error [trackEvent]: ', ex);
}
}
You could then construct an Azure Logs query that would figure out the frequency that your application is losing internet connection and display a graph. For example:
customEvents
| summarize num_events = count() by bin(timestamp, 5min)
| render timechart