https://github.com/undead25/trace-js
Getting stack traces in all web browsers
https://github.com/undead25/trace-js
angular2-error-handler crash-reporting error-handler error-monitoring
Last synced: 5 months ago
JSON representation
Getting stack traces in all web browsers
- Host: GitHub
- URL: https://github.com/undead25/trace-js
- Owner: undead25
- Created: 2017-05-03T06:01:36.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-07T18:34:15.000Z (over 8 years ago)
- Last Synced: 2025-09-14T08:47:04.743Z (6 months ago)
- Topics: angular2-error-handler, crash-reporting, error-handler, error-monitoring
- Language: TypeScript
- Homepage:
- Size: 259 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Usage
### Augular
> Angular means Angular 2+
Trace can be configured to catch any Angular-specific (2.x) exceptions reported through the [@angular/core/ErrorHandler](https://angular.io/docs/js/latest/api/core/index/ErrorHandler-class.html) component.
#### Installation
```bash
$ npm install trace-js --save
```
#### Configuration
In your main module file (where `@NgModule` is called, e.g. `app.module.ts`)
```typescript
import Trace = require('trace-js');
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, ErrorHandler } from '@angular/core';
import { AppComponent } from './app.component';
Trace.config({
apiKey: 'your apikey from your server client', // it can be empty string if your server do not configured
reportUrl: 'http://example.com/api/error' // your server api url to reveive the report
//... other configuration options, see api reference
});
export class TraceErrorHandler implements ErrorHandler {
handleError(err:any) : void {
Trace.captureException(err.originalError || err);
}
}
@NgModule({
imports: [ BrowserModule ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ],
providers: [ { provide: ErrorHandler, useClass: TraceErrorHandler } ]
})
export class AppModule { }
```
### Browser
Trace distributed in a few different methods, and should get included after any other libraries are included, but before your own scripts.
So for example:
```html
Trace.config({
apiKey: 'your apikey from your server client', // it can be empty string if your server do not configured
reportUrl: 'http://example.com/api/error' // your server api url to reveive the report
//... other configuration options, see api reference
});
```