Skip to content

Commit

Permalink
Updated sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
pastelsky committed Jan 2, 2024
1 parent da824fb commit 121415e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
20 changes: 1 addition & 19 deletions server.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "./server/init-sentry.js";
import fastifyStart from "fastify";
import fastifyStatic from "@fastify/static";
import next from "next";
Expand All @@ -22,8 +23,6 @@ import fastifyBasicAuth from "@fastify/basic-auth";
import "dotenv/config";
import heapdump from "heapdump";

import * as Sentry from "@sentry/node";

const dev = process.env.NODE_ENV !== "production";
const hostname = "localhost";
const port = 3000;
Expand Down Expand Up @@ -103,23 +102,6 @@ app
serve: false,
});

if (process.env.SENTRY_DSN) {
logger.info("Sentry integration is enabled");
fastify.register(require("@immobiliarelabs/fastify-sentry"), {
dsn: process.env.SENTRY_DSN,
environment: "production",
release: "1.0.0",
integrations: [
// enable HTTP calls tracing
new Sentry.Integrations.Http({ tracing: true }),
// Automatically instrument Node.js libraries and frameworks
// (This function is slow because of file I/O, consider manually adding additional integrations instead)
...Sentry.autoDiscoverNodePerformanceMonitoringIntegrations(),
],
tracesSampleRate: 1.0,
});
}

fastify.register(fastifyBasicAuth, {
validate(username, password, _req, reply, done) {
if (
Expand Down
24 changes: 24 additions & 0 deletions server/init-sentry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const Sentry = require("@sentry/node");
const path = require("path");

require("dotenv").config({
path: path.join(__dirname, "..", ".env"),
});

if (process.env.SENTRY_DSN) {
Sentry.init({
dsn: process.env.SENTRY_DSN,
includeLocalVariables: true,
integrations: [
new Sentry.Integrations.Console(),
new Sentry.Integrations.Http({ tracing: true }),
new Sentry.Integrations.OnUncaughtException(),
new Sentry.Integrations.OnUnhandledRejection(),
new Sentry.Integrations.ContextLines(),
new Sentry.Integrations.LocalVariables(),
new Sentry.Integrations.Undici(),
new Sentry.Integrations.RequestData(),
],
tracesSampleRate: 1.0,
});
}
1 change: 1 addition & 0 deletions server/workers/docs-builder-worker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require("esbuild-register/dist/node").register();
require("../init-sentry");

const {
generateDocsForPackage,
Expand Down

0 comments on commit 121415e

Please sign in to comment.