This package has been deprecated

Author message:

Unmaintained

@capraconsulting/sentry-utils-js
TypeScript icon, indicating that this package has built-in type declarations

5.1.0 • Public • Published

Utils for monitoring web applications with Sentry

Usage

Install the dependency:

npm install --save-exact @capraconsulting/sentry-utils-js

Find your DSN in Sentry under "Settings" -> "Client Keys", to be used in the next snippet.

Initialize Sentry in your application. This should be done as early as possible, preferably before other imports, so that it can catch errors during the rest of initialization.

initSentry({
  // Options specified by Sentry, see type Sentry.BrowserOptions.
  options: {
    release: 'ec1c1c',
    environment: '...',
    dsn: '...',
  },
  buildTime: '2019-04-11T00:06+02:00', // Optional
});

The following is a full example of how this can be done:

import {
  initSentry,
  reportSentryNotEnabled,
} from "@capraconsulting/sentry-utils-js";
import { getConfig } from "./common/config";

const config = getConfig();

if (config.sentryDsn) {
  initSentry({
    options: {
      release: __BUILD_INFO__.commitHash,
      environment: config.sentryEnv,
      dsn: config.sentryDsn,
    },
    buildTime: __BUILD_INFO__.appBuildTime,
  });
} else {
  reportSentryNotEnabled();
}

Capture log events when needed:

import { captureError } from "@capraconsulting/sentry-utils-js";

if (...) {
  captureError("Something bad happened")
}

See types for additional capture methods and parameters that can be used.

Features

  • Throttles messages to prevent flooding Sentry
  • Provides default configuration for Sentry initialization
  • Provides more opiniated helpers to capture messages
  • Includes buildTime as tag if provided during initialization

Throttling

Evaluate and throttle before sending message to Sentry in case of excessive amount of failures. This will allow for a spike of 4-5 requests, decaying using mean lifetime of 1 minute.

Contributing

This project uses semantic release to automate releases and follows Git commit guidelines from the Angular project.

Readme

Keywords

none

Package Sidebar

Install

npm i @capraconsulting/sentry-utils-js

Weekly Downloads

12

Version

5.1.0

License

Apache-2.0

Unpacked Size

42 kB

Total Files

17

Last publish

Collaborators

  • andeero
  • annelandro
  • capra-ci
  • ekern
  • evan-boone
  • jol-capraconsulting
  • kre-capra
  • oyk
  • paalfornebo
  • rastaflettus
  • sherriff
  • sondrehav
  • terjeruuda
  • trulsstenrud