diff --git a/package-lock.json b/package-lock.json index 406cb437..2a82dc2a 100644 Binary files a/package-lock.json and b/package-lock.json differ diff --git a/package.json b/package.json index 1eb8fbae..4786be16 100644 --- a/package.json +++ b/package.json @@ -68,8 +68,7 @@ }, "dependencies": { "@aws-sdk/client-s3": "^3.682.0", - "@sentry/integrations": "^7.66.0", - "@sentry/node": "^7.119.2", + "@sentry/node": "^8.35.0", "ajv": "^8.17.1", "ajv-formats": "2.1.1", "amqplib": "^0.10.4", diff --git a/src/gateway/events/Message.ts b/src/gateway/events/Message.ts index c20cee7a..f63ec37c 100644 --- a/src/gateway/events/Message.ts +++ b/src/gateway/events/Message.ts @@ -89,11 +89,11 @@ export async function Message(this: WebSocket, buffer: WS.Data) { } try { - return await Sentry.startActiveSpan( + return await Sentry.startSpan( // Emma [it/its]@Rory&: is this the right function to migrate to in v8? { op: "websocket.server", name: `GATEWAY ${OPCODES[data.op]}`, - data: { + attributes: { // this needs to be reworked :) ...data.d, token: data?.d?.token ? "[Redacted]" : undefined, }, diff --git a/src/util/util/Sentry.ts b/src/util/util/Sentry.ts index 74a23a1e..510ed453 100644 --- a/src/util/util/Sentry.ts +++ b/src/util/util/Sentry.ts @@ -19,8 +19,7 @@ import { yellow } from "picocolors"; import { Config } from "./Config"; -import * as Integrations from "@sentry/integrations"; -import * as SentryNode from "@sentry/node"; +import * as Integrations from "@sentry/node"; import express from "express"; // Work around for when bundle calls api/etc @@ -33,7 +32,7 @@ export const Sentry = { Config.get().sentry; if (!enabled) return; - if (SentryNode.getCurrentHub().getClient()) return; // we've already initialised sentry + if (Integrations.getClient()) return; // we've already initialised sentry console.log("[Sentry] Enabling sentry..."); @@ -46,32 +45,30 @@ export const Sentry = { } const integrations = [ - new SentryNode.Integrations.Http({ tracing: true }), - new Integrations.RewriteFrames({ + Integrations.httpIntegration(), + Integrations.rewriteFramesIntegration({ root: __dirname, }), - new SentryNode.Integrations.Http({ - tracing: true, - breadcrumbs: true, - }), - ...SentryNode.autoDiscoverNodePerformanceMonitoringIntegrations(), + Integrations.httpIntegration(), + ...Integrations.getAutoPerformanceIntegrations(), ]; - if (app) - integrations.push( - new SentryNode.Integrations.Express({ - app, - }), - ); + //deprecated in v8? unable to test + // if (app) + // integrations.push( + // Integrations.expressIntegration({ + // app, + // }), + // ); - SentryNode.init({ + Integrations.init({ dsn: endpoint, integrations, tracesSampleRate: traceSampleRate, // naming? environment, }); - SentryNode.addGlobalEventProcessor((event) => { + Integrations.addEventProcessor((event) => { if (event.transaction) { // Rewrite things that look like IDs to `:id` for sentry event.transaction = event.transaction @@ -109,11 +106,6 @@ export const Sentry = { return event; }); - - if (app) { - app.use(SentryNode.Handlers.requestHandler()); - app.use(SentryNode.Handlers.tracingHandler()); - } }, /** Call AFTER registering your routes */ @@ -122,7 +114,8 @@ export const Sentry = { if (errorHandlersUsed) return; errorHandlersUsed = true; - app.use(SentryNode.Handlers.errorHandler()); + Integrations.setupExpressErrorHandler(app); + // The typings for this are broken? // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars app.use(function onError(err: any, req: any, res: any, next: any) { @@ -132,6 +125,6 @@ export const Sentry = { }, close: () => { - SentryNode.close(); + Integrations.close(); }, };