summary refs log tree commit diff
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-22 21:39:40 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-22 21:39:40 +1000
commitdc77c2fc4439289a8e1d0d099f95cefabb71d3a7 (patch)
tree87e22105ee78bcd6831bfefbee31161130603fc0
parentFlter close messages in sentry (diff)
downloadserver-dc77c2fc4439289a8e1d0d099f95cefabb71d3a7.tar.xz
Sentry gateway tracking
-rw-r--r--gateway/src/events/Message.ts16
1 files changed, 15 insertions, 1 deletions
diff --git a/gateway/src/events/Message.ts b/gateway/src/events/Message.ts
index 1a177e0c..0b1a8b2c 100644
--- a/gateway/src/events/Message.ts
+++ b/gateway/src/events/Message.ts
@@ -9,6 +9,7 @@ import { Tuple } from "lambert-server";
 import { check } from "../opcodes/instanceOf";
 import WS from "ws";
 import BigIntJson from "json-bigint";
+import Sentry from "@Sentry/node";
 const bigIntJson = BigIntJson({ storeAsString: true });
 
 const PayloadSchema = {
@@ -50,9 +51,22 @@ export async function Message(this: WebSocket, buffer: WS.Data) {
 		return;
 	}
 
+	const transaction = Sentry.startTransaction({
+		op: OPCODES[data.op],
+		name: `GATEWAY ${OPCODES[data.op]}`,
+		data: {
+			...data.d,
+			token: data.d.token ? "[Redacted]" : undefined,
+		},
+	});
+
 	try {
-		return await OPCodeHandler.call(this, data);
+		var ret = await OPCodeHandler.call(this, data);
+		transaction.finish();
+		return ret;
 	} catch (error) {
+		Sentry.captureException(error);
+		transaction.finish();
 		console.error(`Error: Op ${data.op}`, error);
 		// if (!this.CLOSED && this.CLOSING)
 		return this.close(CLOSECODES.Unknown_error);