1.4.24 • Published 3 years ago

@santry/node v1.4.24

Weekly downloads
1
License
MIT
Repository
github
Last release
3 years ago

npm.io npm.io npm.io npm.io npm.io

npm.io


@santry/browser

clone project of sentry

Install

npm install @santry/node

Usage

After generating an error, place the function in the catch.

const { init, captureError, captureMessage, setContext } = require('@santry/node');

const dsn = '[token]@[url]';

init(dsn);

const testError = () => {
  try {
    throw new Error('testing Error');

    // If you have any messages you want to collect, please collect them as "captureMessage".
    captureMessage("hello I'm Hera");
  } catch (error) {

    // Collect errors with captureError.
    captureError(error);
  }
};

testError();

To use Express

Use errorHandler function as middleware.

// All controllers should live here
const express = require('express');
const {
  init,
  errorHandler,
  captureMessage,
  setContext,
} = require('@santry/node');

const app = express();
const dsn = '[dsn]@[url]';

init(dsn, {
  traceSampleRate: 1,
  release: 'santry@0.0.1',
  environment: 'production',
  unhandledRejectionLevel: 'critical',
  uncaughtExceptionLevel: 'warning',
});

app.get('/', function rootHandler(req, res) {
  res.end('Hello world!');
});

app.post('/debug-santry', function mainHandler(req, res) {
  setContext('myInfo', {
    name: 'Hera',
    age: 26,
  });
  captureMessage("hello I'm Hera");
  throw new Error('My second Santry error get!');
});

// The error handler must be before any other error middleware and after all controllers
app.use(errorHandler());

// Optional fallthrough error handler
app.use(function onError(err, req, res, next) {
  res.statusCode = 500;
  res.end('good santry!');
});

app.listen(3000);

Functions

init(dsn)

If you want to use functions, use it first.

options

  • traceSampleRate Set the percentage to collect errors or messages. This can be a number between 0 and 1.
  • release Set the release version of your code.
  • environment Set the environment of your code.
  • unhandleRejectionLevel Set the level when an unhandleRejection error occurs. This is the setting for the whole unhandleRejection error.
  • uncaughtExceptionLevel Set the level when an uncaughtException error occurs. This is the setting for the whole uncaughtException error.

captureError(error)

Errors can be collected.

setContext(context)

Set context of error or mesaage

errorHandler(, level)

Error collecting function of Express Middleware

1.4.24

3 years ago

1.4.23

3 years ago

1.4.22

3 years ago

1.4.21

3 years ago

1.4.20

3 years ago

1.4.19

3 years ago

1.4.18

3 years ago

1.4.17

3 years ago

1.4.16

3 years ago

1.4.15

3 years ago

1.4.13

3 years ago

1.4.12

3 years ago

1.4.14

3 years ago

1.4.11

3 years ago

1.4.9

3 years ago

1.4.8

3 years ago

1.4.6

3 years ago

1.4.5

3 years ago

1.4.4

3 years ago

1.4.7

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.3.0

3 years ago

2.0.0

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.1

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.0

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago