Skip to content

tomtomau/aurelia-sentry

Repository files navigation

aurelia-sentry

A wrapper around Sentry's Browser client to be added to Aurelia's LogManager.

Usage

Install the package:

$ yarn add aurelia-sentry

Add the library to your base template - this will catch more errors before Aurelia has chance to boot.

<script src="https://browser.sentry-cdn.com/8.0.0/bundle.min.js"
        crossorigin="anonymous"
></script>
<!-- Configure your DSN here too -->
<script>Sentry.init({ dsn: '{{ sentry_dsn }}' });</script>

Then update your main.js in Aurelia to add the SentryAppender as early as possible.

// main.js
import { LogManager } from 'aurelia-framework';
import { SentryAppender } from 'aurelia-sentry';

LogManager.addAppender(new SentryAppender());
LogManager.setLevel(LogManager.logLevel.error);

export function configure(aurelia) {
  aurelia.use
    .standardConfiguration()
    .developmentLogging();
  
  aurelia.start().then(() => aurelia.setRoot());
}

Configuration

You may optionally configure a minimum level to be logged:

import { LogManager, ConsoleAppender } from 'aurelia-framework';
import { SentryAppender } from 'aurelia-sentry';

if (typeof (window as any).Sentry !== 'undefined') {
  LogManager.addAppender(new SentryAppender({ minLevel: Levels.error}));
  LogManager.setLevel(LogManager.logLevel.warn);
} else {
  LogManager.setLevel(LogManager.logLevel.debug);
}

LogManager.addAppender(new ConsoleAppender());

About

Sentry LogAppender for Aurelia JS Framework

Resources

License

Stars

Watchers

Forks

Packages

No packages published