From the link you posted is one way to process diagnostic data. We use JSNLog for our applications.
Install JSNLog in Angular 2+ app
At the command prompt, install the NPM package:
npm install jsnlog
Send excluded JavaScript exceptions to the server
An uncaught exception is simply an exception that does not fall into your own code. You will need to register them on the server.
By default, Angular handles uncaught exceptions by sending error messages to the console (details). To change this, you create a provider for the ErrorHandler interface (example).
- Open the main module in your favorite editor. This is most often called app.module.ts.
Above the module definition, add an opaque exception handler that uses JSNLog to register a JavaScript exception on the server:
export class UncaughtExceptionHandler implements ErrorHandler { handleError(error: any) { JL().fatalException('Uncaught Exception', error); } }
The TypeScript compiler will complain because you did not import JSNLog and ErrorHandler. Do it now:
// ... other imports ...
import { JL } from 'jsnlog'; import { ErrorHandler } from '@angular/core'; Finally add your uncaught exception handler to the providers list, as a provider for the ErrorHandler interface: @NgModule({ ... providers: [ ... { provide: ErrorHandler, useClass: UncaughtExceptionHandler } ], ... })
For more information see this
Webruster
source share