angular_sentry 0.0.7

  • Readme
  • Changelog
  • Example
  • Installing
  • 60

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);
}

Changelog #

0.0.7 #

  • Fix logger
  • remove logErrorWindow
  • Breadcrumbs size limit can be set by injecting value with token breadcrumbsLimit

0.0.6 #

  • Fix Breadcrumb message
  • Upgrade sentry package to 3.0.0+1

0.0.5 #

  • Update angular 5
  • Update sentry package
  • Warning refactoring Breaking Change:
    • use OpaqueToken to pass release version, environment, dsn and logger sentryEnvironmentToken,sentryReleaseVersionToken, sentryLoggerToken, sentryDsnToken
    • no more tags and extra field, override transformEvent function instead
    • rename onCatch to capture

0.0.4 #

  • update sentry package to 1.0.0

0.0.3 #

  • fix logger
  • fix stacktrace parsing

0.0.2 #

  • Use sentry package instead of sentry_client

0.0.1 #

  • Initial version, created by Stagehand

example/main.dart

import 'dart:html' hide Event;

import "package:angular/angular.dart";
import 'package:http/http.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;

// ignore: uri_has_not_been_generated
import 'app.template.dart' as app;

SentryClient sentryProdider() => SentryClient(
      dsn: "https://public:secret@sentry.example.com/1",
      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(app.AppComponentNgFactory, createInjector: scannerApp);
}

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);
    }
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  angular_sentry: ^0.0.7

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:angular_sentry/angular_sentry.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
32
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
60
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
angular ^5.0.0 5.3.1 6.0.0-alpha+1
http ^0.12.0 0.12.0+4
logging ^0.11.0 0.11.4
meta ^1.1.0 1.1.8
sentry ^3.0.0+1 3.0.0+1
Transitive dependencies
analyzer 0.35.4 0.39.4
angular_ast 0.5.9 0.5.11
angular_compiler 0.4.3 0.4.5
args 1.5.2
async 2.4.0
build 1.2.2
build_config 0.4.1+1
built_collection 4.3.2
built_value 7.0.8
charcode 1.1.2
checked_yaml 1.0.2
code_builder 3.2.1
collection 1.14.12
convert 2.1.1
crypto 2.1.4
csslib 0.14.6+1 0.16.1
dart_style 1.2.4 1.3.3
fixnum 0.10.11
front_end 0.1.14 0.1.29
glob 1.2.0
http_parser 3.1.3
intl 0.15.8 0.16.1
js 0.6.1+1
json_annotation 3.0.1
kernel 0.3.14 0.3.29
matcher 0.12.6
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.1.0
path 1.6.4
pedantic 1.9.0
pub_semver 1.4.2
pubspec_parse 0.1.5
quiver 2.1.2+1
source_gen 0.9.4+4 0.9.4+7
source_span 1.6.0
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
usage 3.4.1
watcher 0.9.7+13
yaml 2.2.0
Dev dependencies
build_runner ^1.7.0
build_web_compilers ^2.7.0