angular_sentry 0.0.7 copy "angular_sentry: ^0.0.7" to clipboard
angular_sentry: ^0.0.7 copied to clipboard

outdated

Helper to implements sentry with Angular

angular_sentry #

Helper to implements sentry.io with Angular.

Usage #

Basic #

import "package:angular/angular.dart";
import 'package:sentry/sentry.dart';
import "package:angular_sentry/angular_sentry.dart";

// ignore: uri_has_not_been_generated
import 'main.template.dart' as ng;

SentryClient sentryProdider() => SentryClient(
      dsn: "YOUR_DSN",
      environmentAttributes: Event(
        environment: 'production',
        release: '1.0.0',
      ),
    );

const sentryModule = Module(provide: [
  FactoryProvider(SentryClient, sentryProdider),
  ClassProvider(ExceptionHandler, useClass: AngularSentry),
]);

@GenerateInjector([sentryModule])
const scannerApp = ng.scannerApp$Injector;

main() {
  runApp(appComponentNgFactory, createInjector: scannerApp);
}

Advanced #

Implement your own class using AngularSentry

class AppSentry extends AngularSentry {
  AppSentry(SentryClient client) : super(client);

  @override
  Event transformEvent(Event e) {
    return super.transformEvent(e).copyWith(
      userContext: new User(id: '1', ipAddress: '0.0.0.0'),
      extra: {"location_url": window.location.href},
    );
  }

  @override
  void capture(exception, [trace, String reason]) {
    if (exception is ClientException) {
      logError("Network error");
    } else {
      super.capture(exception, trace, reason);
    }
  }
}

const sentryModule = Module(provide: [
  FactoryProvider(SentryClient, sentryProdider),
  ClassProvider(ExceptionHandler, useClass: AppSentry),
]);

main() {
  runApp(appComponentNgFactory, createInjector: scannerApp);
}
1
likes
0
pub points
41%
popularity

Publisher

unverified uploader

Helper to implements sentry with Angular

Homepage

License

unknown (LICENSE)

Dependencies

angular, http, logging, meta, sentry

More

Packages that depend on angular_sentry