https://github.com/leftyio/angular_sentry
https://github.com/leftyio/angular_sentry
angular browser dart sentry
Last synced: 24 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/leftyio/angular_sentry
- Owner: leftyio
- License: mit
- Created: 2018-02-20T13:50:40.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-10-23T13:31:42.000Z (over 4 years ago)
- Last Synced: 2025-11-01T04:06:14.851Z (5 months ago)
- Topics: angular, browser, dart, sentry
- Language: Dart
- Size: 28.3 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/leftyio/angular_sentry/actions/workflows/dart.yml)
# angular_sentry
Helper to implements [sentry.io](https://sentry.io) with Angular.
## Usage
### Inject Angular Sentry
```dart
import "package:angular/angular.dart";
import "package:angular_sentry/angular_sentry.dart";
// ignore: uri_has_not_been_generated
import 'main.template.dart' as ng;
const sentryModule = Module(provide: [
ClassProvider(ExceptionHandler, useClass: AngularSentry),
]);
@GenerateInjector([sentryModule])
const scannerApp = ng.scannerApp$Injector;
```
### Init Sentry and run your app
```dart
Future main() async {
await Sentry.init(
(options) {
options.dsn = 'https://example@sentry.io/add-your-dsn-here';
options.environment = 'production';
options.release = '1.0.0';
},
appRunner: initApp,
);
}
void initApp() {
runApp(ng.AppComponentNgFactory, createInjector: scannerApp);
}
```
### Advanced
Implement your own class using AngularSentry
```dart
class AppSentry extends AngularSentry {
@override
Event transformEvent(SentryEvent e) {
return super.transformEvent(e).copyWith(
user: SentryUser(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);
}
```