From 99124c04e497b1a9332ded1c925c91d50c60f89e Mon Sep 17 00:00:00 2001 From: Dan Schultz Date: Fri, 7 Jan 2022 17:11:38 -0500 Subject: [PATCH] Integrate Sentry The application will report to sentry if the sentry environment variables are specified. Issue #4 --- .env.example | 9 +++++++++ README.md | 9 ++++++++- src/index.ts | 10 ++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..645c7afe --- /dev/null +++ b/.env.example @@ -0,0 +1,9 @@ +# Your Sentry Data Source Name (DSN) +# See https://docs.sentry.io/product/sentry-basics/dsn-explainer/ +# e.g. https://your@dsn.ingest.sentry.io/here" +SENTRY_DSN=${SENTRY_DSN} + +# The environment tag to associate with sentry entries +# See https://docs.sentry.io/product/sentry-basics/environments/ +# e.g. localhost +SENTRY_ENVIRONMENT=${SENTRY_ENVIRONMENT} diff --git a/README.md b/README.md index 807666e4..67bc1669 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,14 @@ This project uses NodeJS 16.x and contains an implementation of the SFTP protoco npm install ``` -2. Start the service +2. Configure your `.env` + +``` +cp .env.example .env +vi .env +``` + +3. Start the service ``` npm start diff --git a/src/index.ts b/src/index.ts index e69de29b..dec2d944 100644 --- a/src/index.ts +++ b/src/index.ts @@ -0,0 +1,10 @@ +import Sentry from '@sentry/node'; + +if ('SENTRY_DSN' in process.env + && 'SENTRY_ENVIRONMENT' in process.env) { + Sentry.init({ + dsn: process.env.SENTRY_DSN, + tracesSampleRate: 1, + environment: process.env.SENTRY_ENVIRONMENT, + }); +}