Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@titelmedia/scoped-sentry-reporter

Package Overview
Dependencies
Maintainers
8
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@titelmedia/scoped-sentry-reporter

This package enables you to manage several sentry instances

  • 1.1.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
8
Weekly downloads
 
Created
Source

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.

FAQs

Package last updated on 17 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc