declare var newrelic ; declare var Raygun ; declare var Rollbar ; declare var trackJs ; import { Http } from "@angular/http" ; import { Injectable } from "@angular/core" ; import { Response } from "@angular/http" ; @ Injectable ( ) export class ErrorLogService { private http : Http ; constructor ( http ) { this . http = http ; } public logError ( error ) { this . sendToConsole ( error ) ; this . sendToServer ( error ) ; this . sendToNewRelic ( error ) ; this . sendToRaygun ( error ) ; this . sendToRollbar ( error ) ; this . sendToTrackJs ( error ) ; } private sendToConsole ( error ) { if ( console && console . group && console . error ) { console . group ( "Error Log Service" ) ; console . error ( error ) ; console . error ( error . message ) ; console . error ( error . stack ) ; console . groupEnd ( ) ; } } private sendToNewRelic ( error ) { newrelic . noticeError ( error ) ; } private sendToRaygun ( error ) { Raygun . send ( error ) ; } private sendToRollbar ( error ) { Rollbar . error ( error ) ; } private sendToServer ( error ) { this . http . post ( "./error-logging-endpoint" , { type : error . name , message : error . message , stack : error . stack , location : window . location . href } ) . subscribe ( ( httpResponse ) : void => { } , ( httpError ) : void => { } ) ; } private sendToTrackJs ( error ) { trackJs . track ( error ) ; } }