Specific metrics
In addition to the metric we looked at earlier, we can add a method in our service so that we are able to send specific metrics, like so:
public metric(label:string, value:any){ this.http.post("https://api.yourwebsite/metric/", { label:label, value:value, }) }
Error reporting
Another way to enhance the transparency and observability of your application is to report each and every JavaScript error that occurs on the client side. Doing so is relatively simple in JavaScript; you simply need to attach a callback function to the window.onerror
event, as follows:
window.onerror = function myErrorHandler(errorMsg, url, lineNumber) { alert("Error occured: " + errorMsg); }
This will simply create an alert each time an error occurs. With Angular, however, you cannot use the same simple technique—not because it is complicated, but because it requires the creation of the ne
class. This new class will implement the Angular error handler interface like so:
class MyErrorHandler implements ErrorHandler...