summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-10-30 11:33:27 +1100
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-10-30 11:34:25 +1100
commit5a5a20c20331de00d7ea691ab08412abeff89dbf (patch)
tree0399a4d567b35e3b0f845cfb5fcc038044a9d931 /src
parentAdded fast connect to index (diff)
downloadserver-5a5a20c20331de00d7ea691ab08412abeff89dbf.tar.xz
Sentry stuff?
Diffstat (limited to 'src')
-rw-r--r--src/bundle/Server.ts4
-rw-r--r--src/gateway/events/Message.ts13
2 files changed, 12 insertions, 5 deletions
diff --git a/src/bundle/Server.ts b/src/bundle/Server.ts
index b98a3776..2bc45f84 100644
--- a/src/bundle/Server.ts
+++ b/src/bundle/Server.ts
@@ -10,6 +10,7 @@ import { green, bold, yellow } from "picocolors";
 import { Config, initDatabase, BannedWords } from "@fosscord/util";
 import * as Sentry from "@sentry/node";
 import * as Tracing from "@sentry/tracing";
+import * as Integrations from "@sentry/integrations";
 
 const app = express();
 const server = http.createServer();
@@ -73,6 +74,9 @@ async function main() {
 				new Sentry.Integrations.Http({ tracing: true }),
 				new Tracing.Integrations.Express({ app }),
 				new Tracing.Integrations.Mysql(),
+				new Integrations.RewriteFrames({
+					root: __dirname,
+				}),
 			],
 			tracesSampleRate: Config.get().sentry.traceSampleRate,
 			environment: Config.get().sentry.environment,
diff --git a/src/gateway/events/Message.ts b/src/gateway/events/Message.ts
index 9fafae1e..4ed715b2 100644
--- a/src/gateway/events/Message.ts
+++ b/src/gateway/events/Message.ts
@@ -42,22 +42,25 @@ export async function Message(this: WebSocket, buffer: WS.Data) {
 		return;
 	}
 
-	const transaction = Sentry.startTransaction({
+	const transaction = data.op != 1 ? Sentry.startTransaction({
 		op: OPCODES[data.op],
 		name: `GATEWAY ${OPCODES[data.op]}`,
 		data: {
 			...data.d,
 			token: data?.d?.token ? "[Redacted]" : undefined,
 		},
-	});
+	}) : undefined;
 
 	try {
 		var ret = await OPCodeHandler.call(this, data);
-		transaction.finish();
+		transaction?.finish();
 		return ret;
 	} catch (error) {
-		Sentry.captureException(error);
-		transaction.finish();
+		Sentry.withScope((scope) => {
+			scope.setSpan(transaction);
+			Sentry.captureException(error);
+		});
+		transaction?.finish();
 		console.error(`Error: Op ${data.op}`, error);
 		// if (!this.CLOSED && this.CLOSING)
 		return this.close(CLOSECODES.Unknown_error);