Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i wanted to make a heartbeat in my angular application #74

Open
mostafa-raafat opened this issue May 27, 2019 · 1 comment
Open

i wanted to make a heartbeat in my angular application #74

mostafa-raafat opened this issue May 27, 2019 · 1 comment
Labels

Comments

@mostafa-raafat
Copy link

mostafa-raafat commented May 27, 2019

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 ?

Screen Shot 2019-05-27 at 4 16 08 PM

@jonathankretzmer
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants