@dineroregnskab/datadog-angular
TypeScript icon, indicating that this package has built-in type declarations

3.3.0 • Public • Published

@dineroregnskab/datadog-angular

Datadog integration for Angular projects.

Has built-in unwrapping of HttpErrorResponse and UncaughtPromiseError.

Enrichers

Included enrichers for Logs and RUM:

  • @ngrx/store

Enrichers for Logs can be imported from: @dineroregnskab/datadog-angular/enrichers/logs
Enrichers for RUM can be imported from: @dineroregnskab/datadog-angular/enrichers/rum

Filters

Included filters for Logs and RUM:

  • Discard HTTP errors with status code 0
  • Discard HTTP errors with 0 Unknown Error message

Filters for Logs can be imported from: @dineroregnskab/datadog-angular/filters/logs
Filters for RUM can be imported from: @dineroregnskab/datadog-angular/filters/rum

Templates:

Enrichers:

Logs:

export const enricher = (log: LogsEvent, injector: Injector | null): void => {
    // Append data to log object.
};

RUM:

export const enricher = (
    event: RumEvent,
    context: RumEventDomainContext,
    injector: Injector | null,
): void => {
    // Append data to the event context here.
};

Filters:

Logs:

export const filter = (
    event: RumEvent,
    context: RumEventDomainContext,
    injector: Injector | null,
): boolean => {
    // Return true to discard the log.
};

RUM:

export const filter = (log: LogsEvent, injector: Injector | null): boolean => {
    // Return true to discard log.
};

Initialization

Initializer will instrument both Logs and RUM.

main.ts

import { setNgInjector } from '@dineroregnskab/datadog-angular';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app';

platformBrowserDynamic()
    .bootstrapModule(AppModule)
    .then((appRef) => {
        // Save a reference to the Angular DI injector for use in logging.
        setNgInjector(appRef.injector);
    })
    .catch((err) => console.error(err));

Error handler

import { ErrorHandler, Injectable } from '@angular/core';
import { DatadogErrorHandler } from '@dineroregnskab/datadog-angular';

@Injectable()
export class CustomErrorHandler
    extends DatadogErrorHandler
    implements ErrorHandler
{
    public constructor() {
        super();
    }

    public handleError(error: any): void {
        this.datadogLogger.error(error);
    }
}

Readme

Keywords

none

Package Sidebar

Install

npm i @dineroregnskab/datadog-angular

Weekly Downloads

434

Version

3.3.0

License

ISC

Unpacked Size

37.1 kB

Total Files

62

Last publish

Collaborators

  • larsnikolajsen
  • bgpedersen
  • baunegaard
  • daneskildsen
  • loubnielsen