Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 18, 2022. It is now read-only.

Conversation

@xtina-starr
Copy link
Contributor

@xtina-starr xtina-starr commented Mar 1, 2019

Addresses: GROW-1120

This adds error tracking for the kaws project.

ToDo:

  • Setup Kaws projects in Sentry for staging and production.
  • Set the environment variables.

@peril-staging
Copy link
Contributor

peril-staging bot commented Mar 1, 2019

Warnings
⚠️ It looks like code was changed without adding anything to the Changelog.
You can add #trivial in the PR body to skip the check.

New dependencies added: @sentry/node.

@sentry/node

Author: Sentry

Description: Offical Sentry SDK for Node.js

Homepage: https://github.com/getsentry/sentry-javascript/tree/master/packages/node

Createdabout 1 year ago
Last Updated3 days ago
LicenseBSD-3-Clause
Maintainers9
Releases68
Direct Dependencies@sentry/core, @sentry/hub, @sentry/types, @sentry/utils, @types/stack-trace, cookie, https-proxy-agent, lru_map, lsmod, stack-trace and tslib
README


Official Sentry SDK for NodeJS

npm version
npm dm
npm dt
typedoc

Links

Usage

To use this SDK, call init(options) as early as possible in the main entry module. This will initialize the SDK and
hook into the environment. Note that you can turn off almost all side effects using the respective options.

// ES5 Syntax
const Sentry = require('@sentry/node');
// ES6 Syntax
import * as Sentry from '@sentry/node';

Sentry.init({
  dsn: '__DSN__',
  // ...
});

To set context information or send manual events, use the exported functions of @sentry/node. Note that these
functions will not perform any action before you have called init():

// Set user information, as well as tags and further extras
Sentry.configureScope(scope => {
  scope.setExtra('battery', 0.7);
  scope.setTag('user_mode', 'admin');
  scope.setUser({ id: '4711' });
  // scope.clear();
});

// Add a breadcrumb for future events
Sentry.addBreadcrumb({
  message: 'My Breadcrumb',
  // ...
});

// Capture exceptions, messages or manual events
Sentry.captureMessage('Hello, world!');
Sentry.captureException(new Error('Good bye'));
Sentry.captureEvent({
  message: 'Manual',
  stacktrace: [
    // ...
  ],
});

Generated by 🚫 dangerJS against 40db94a

src/index.ts Outdated
import { Connection, createConnection } from "typeorm"
import { databaseConfig } from "./config/database"
import { createSchema } from "./utils/createSchema"
const enableSentry = !!SENTRY_PRIVATE_DSN
Copy link
Contributor

@eessex eessex Mar 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this !! syntax? new to me

Copy link
Contributor

@l2succes l2succes Mar 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's the same as Boolean(SENTRY_PRIVATE_DSN) it basically converts a truthy or falsy value to a proper boolean

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean(SENTRY_PRIVATE_DSN) might actually be better.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that seems more communicative.

src/index.ts Outdated
// Setup Sentry
if (enableSentry) {
Sentry.init({
dsn: "https://[email protected]/1405985",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xtina-starr we should use the env variable for this correct?

Copy link
Contributor Author

@xtina-starr xtina-starr Mar 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh shoot I actually set it up that way and forgot to remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch @l2succes! This was for the staging environment. I'll go ahead and generate a new key.

Copy link
Contributor

@eessex eessex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice that this is so lightweight. Is it correct that we need the vars added to hokusai before merging?

@xtina-starr
Copy link
Contributor Author

@eessex I don't think so especially considering there is a conditional check for the presence of the env variable. I just added the ToDo to remind myself.

@l2succes l2succes merged commit 14d8a28 into master Mar 4, 2019
@l2succes l2succes deleted the add-sentry branch March 4, 2019 19:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants