Skip to content

Commit

Permalink
remove error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
marcjulian committed Nov 17, 2023
1 parent 6a8d4b6 commit dcd8058
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 207 deletions.
87 changes: 0 additions & 87 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,90 +146,3 @@ export class AppComponent {
}
}
```

## Error Handling

Use `PlausibleErrorHandler` to track error's in your Angular application. The event will only show up in Plausible when you create a [custom event goal](https://plausible.io/docs/custom-event-goals#2-create-a-custom-event-goal-in-your-plausible-analytics-account) for your page.

Create a custom event goal for the default event name: `Error`. Otherwise provide a custom event name by passing `plausibleErrorEvent` and create a custom event goal for custom event name.

```ts
import {
PlausibleErrorHandler,
PlausibleEventDirective,
PLAUSIBLE_ERROR_OPTIONS,
PlausibleErrorHandlerOptions,
} from '@notiz/ngx-plausible';
import { ErrorHandler, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { environment } from 'src/environments/environment';

const plausibleErrorOptions: PlausibleErrorHandlerOptions = {
logErrors: !environment.production,
plausibleErrorEvent: 'Error', // default event name
};

@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, AppRoutingModule, PlausibleEventDirective],
providers: [
{
provide: ErrorHandler,
useClass: PlausibleErrorHandler,
},
{
provide: PLAUSIBLE_ERROR_OPTIONS,
useValue: plausibleErrorOptions,
},
],
bootstrap: [AppComponent],
})
export class AppModule {}
```

Or use `createPlausibleErrorHandler` and `createPlausibleErrorHandlerProvider` to configure the `PlausibleErrorHandler` via a factory.

```ts
import {
PlausibleEventDirective,
createPlausibleErrorHandler,
PlausibleService,
} from '@notiz/ngx-plausible';
import { ErrorHandler, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { environment } from 'src/environments/environment';

@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, AppRoutingModule, PlausibleEventDirective],
providers: [
{
provide: ErrorHandler,
useFactory: (plausibleService: PlausibleService) =>
createPlausibleErrorHandler(plausibleService, {
logErrors: !environment.production,
plausibleErrorEvent: 'Error', // default event name
}),
deps: [PlausibleService],
},
// or use
createPlausibleErrorHandlerProvider({ logErrors: !environment.production, }),
],
bootstrap: [AppComponent],
})
export class AppModule {}
```

Configure `PlausibleErrorHandler` with `PlausibleErrorHandlerOptions`:

| Option | Default |
| --------------------- | --------------- |
| `logErrors` | `false` |
| `plausibleErrorEvent` | `Error` |
| `extractor` | Default provide |
119 changes: 0 additions & 119 deletions projects/ngx-plausible/src/lib/plausible-error-handler.ts

This file was deleted.

1 change: 0 additions & 1 deletion projects/ngx-plausible/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Public API Surface of ngx-plausible
*/

export * from './lib/plausible-error-handler';
export * from './lib/plausible-event.directive';
export * from './lib/plausible.service';
export * from './lib/plausible-types';

0 comments on commit dcd8058

Please sign in to comment.