1.1.1 • Published 4 years ago

@titelmedia/scoped-sentry-reporter v1.1.1

Weekly downloads
16
License
UNLICENSED
Repository
github
Last release
4 years ago

Scoped Sentry Reporter

Why?

In most cases, it is sufficient to initialize Sentry on a project level. Unfortunately, we needed a solution in which errors from different sources (javascript files) can be reported to different Sentry DSNs. We embed scripts from other projects that can also run on their own, directly into our main platform.

This repo deals with abovementioned errors and makes sure sourcemaps are working.

How?

Install

  yarn add @titelmedia/scoped-sentry-reporter
  npm install @titelmedia/scoped-sentry-reporter --save

Usage

  import ReporterManager from '@titelmedia/scoped-sentry-reporter';
  // const ReporterManager = require('@titelmedia/scoped-sentry-reporter/src/index.es5.js').default;

  // instead of Sentry.init, you'd call
  ReporterManager.initSentry('YOUR_DSN@sentry.io/GOES_HERE', [/.*/], {
    /* REGULAR SENTRY OPTIONS */
  });

Advanced Usage

The function initSentry expects an array of regular expressions as the second argument. With these, you can define patterns so that stackTraces will be picked up and logged into the defined Sentry account.

  ReporterManager.initSentry('YOUR_DSN@sentry.io/GOES_HERE', [/.*\/path\/to\/a\/file\.js/]);

The conditional logic is based on the Boolean operator or and will log the error to the respective DSN if one of the urls in the stackTraces match one of the conditions.

  ReporterManager.initSentry('YOUR_DSN@sentry.io/GOES_HERE', [
    /.*\/a\.js/,
    /.*\/b\.js/,
    /.*\/c\.js/
  ]);

Use a default reporter when nothing matches your conditions.

  // Let's say that you get an error d.js that will not be logged, because conditions do not match.
  ReporterManager.initSentry('YOUR_DSN@sentry.io/GOES_HERE', [/.*\/(a|b|c)\.js/]);

  // After setting a default reporter all errors that cannot be reported to any instance
  // will end up in this project.
  ReporterManager.setDefaultReporter('YOUR_DSN@sentry.io/GOES_HERE', {
    /* REGULAR SENTRY OPTIONS */
  });

Infos and Culprits

One big culprit could be that you'd expect the manager to report one error to all instances. This is not intended to work. The error should be logged into the Sentry instance that is closer to the thrown error location - this saves some duplicates on different Sentry projects.

Aditionally, the reporter only works in browsers.

1.1.1

4 years ago

1.1.0

5 years ago

1.0.0

5 years ago

1.0.0-beta2

5 years ago

1.0.0-beta1

5 years ago

1.0.0-alpha12

5 years ago

1.0.0-alpha11

5 years ago

1.0.0-alpha10

5 years ago

1.0.0-alpha9

5 years ago

1.0.0-alpha8

5 years ago

1.0.0-alpha7

5 years ago

1.0.0-alpha6

5 years ago

1.0.0-alpha5

5 years ago

1.0.0-alpha4

5 years ago

1.0.0-alpha3

5 years ago

1.0.0-alpha2

5 years ago

1.0.0-alpha1

5 years ago