Drop @sentry/node (Sentry support) - untested and unused
This commit is contained in:
parent
3a0bded7f2
commit
0c3d8a792f
BIN
package-lock.json
generated
BIN
package-lock.json
generated
Binary file not shown.
@ -73,7 +73,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-s3": "^3.899.0",
|
"@aws-sdk/client-s3": "^3.899.0",
|
||||||
"@sentry/node": "^9.46.0",
|
|
||||||
"ajv": "^8.17.1",
|
"ajv": "^8.17.1",
|
||||||
"ajv-formats": "^3.0.1",
|
"ajv-formats": "^3.0.1",
|
||||||
"amqplib": "^0.10.9",
|
"amqplib": "^0.10.9",
|
||||||
|
|||||||
@ -22,7 +22,6 @@ import {
|
|||||||
ConnectionLoader,
|
ConnectionLoader,
|
||||||
Email,
|
Email,
|
||||||
JSONReplacer,
|
JSONReplacer,
|
||||||
Sentry,
|
|
||||||
WebAuthn,
|
WebAuthn,
|
||||||
initDatabase,
|
initDatabase,
|
||||||
initEvent,
|
initEvent,
|
||||||
@ -80,7 +79,6 @@ export class SpacebarServer extends Server {
|
|||||||
await Email.init();
|
await Email.init();
|
||||||
await ConnectionConfig.init();
|
await ConnectionConfig.init();
|
||||||
await initInstance();
|
await initInstance();
|
||||||
await Sentry.init(this.app);
|
|
||||||
WebAuthn.init();
|
WebAuthn.init();
|
||||||
|
|
||||||
const logRequests = process.env["LOG_REQUESTS"] != undefined;
|
const logRequests = process.env["LOG_REQUESTS"] != undefined;
|
||||||
@ -157,8 +155,6 @@ export class SpacebarServer extends Server {
|
|||||||
|
|
||||||
this.app.use(ErrorHandler);
|
this.app.use(ErrorHandler);
|
||||||
|
|
||||||
Sentry.errorHandler(this.app);
|
|
||||||
|
|
||||||
ConnectionLoader.loadConnections();
|
ConnectionLoader.loadConnections();
|
||||||
|
|
||||||
if (logRequests)
|
if (logRequests)
|
||||||
|
|||||||
@ -16,7 +16,6 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as Sentry from "@sentry/node";
|
|
||||||
import { checkToken, Rights } from "@spacebar/util";
|
import { checkToken, Rights } from "@spacebar/util";
|
||||||
import { NextFunction, Request, Response } from "express";
|
import { NextFunction, Request, Response } from "express";
|
||||||
import { HTTPError } from "lambert-server";
|
import { HTTPError } from "lambert-server";
|
||||||
@ -108,8 +107,6 @@ export async function Authentication(
|
|||||||
if (!req.headers.authorization)
|
if (!req.headers.authorization)
|
||||||
return next(new HTTPError("Missing Authorization Header", 401));
|
return next(new HTTPError("Missing Authorization Header", 401));
|
||||||
|
|
||||||
Sentry.setUser({ id: req.user_id });
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { decoded, user } = await checkToken(req.headers.authorization);
|
const { decoded, user } = await checkToken(req.headers.authorization);
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,6 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as Sentry from "@sentry/node";
|
|
||||||
import { EmbedHandlers } from "@spacebar/api";
|
import { EmbedHandlers } from "@spacebar/api";
|
||||||
import {
|
import {
|
||||||
Application,
|
Application,
|
||||||
@ -422,12 +421,6 @@ export async function postHandleMessage(message: Message) {
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`[Embeds] Error while generating embed for ${link}`, e);
|
console.error(`[Embeds] Error while generating embed for ${link}`, e);
|
||||||
Sentry.captureException(e, (scope) => {
|
|
||||||
scope.clear();
|
|
||||||
scope.setContext("request", { url: link });
|
|
||||||
return scope;
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ import * as Webrtc from "@spacebar/webrtc";
|
|||||||
import { CDNServer } from "@spacebar/cdn";
|
import { CDNServer } from "@spacebar/cdn";
|
||||||
import express from "express";
|
import express from "express";
|
||||||
import { green, bold } from "picocolors";
|
import { green, bold } from "picocolors";
|
||||||
import { Config, initDatabase, Sentry } from "@spacebar/util";
|
import { Config, initDatabase } from "@spacebar/util";
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const server = http.createServer();
|
const server = http.createServer();
|
||||||
@ -53,13 +53,11 @@ process.on("SIGTERM", async () => {
|
|||||||
await api.stop();
|
await api.stop();
|
||||||
await webrtc.stop();
|
await webrtc.stop();
|
||||||
server.close();
|
server.close();
|
||||||
Sentry.close();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
await initDatabase();
|
await initDatabase();
|
||||||
await Config.init();
|
await Config.init();
|
||||||
await Sentry.init(app);
|
|
||||||
|
|
||||||
const logRequests = process.env["LOG_REQUESTS"] != undefined;
|
const logRequests = process.env["LOG_REQUESTS"] != undefined;
|
||||||
if (logRequests) {
|
if (logRequests) {
|
||||||
@ -89,8 +87,6 @@ async function main() {
|
|||||||
webrtc.start(),
|
webrtc.start(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Sentry.errorHandler(app);
|
|
||||||
|
|
||||||
console.log(`[Server] ${green(`Listening on port ${bold(port)}`)}`);
|
console.log(`[Server] ${green(`Listening on port ${bold(port)}`)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,6 @@ import {
|
|||||||
Config,
|
Config,
|
||||||
initDatabase,
|
initDatabase,
|
||||||
registerRoutes,
|
registerRoutes,
|
||||||
Sentry,
|
|
||||||
} from "@spacebar/util";
|
} from "@spacebar/util";
|
||||||
import { CORS, BodyParser } from "@spacebar/api";
|
import { CORS, BodyParser } from "@spacebar/api";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
@ -45,7 +44,6 @@ export class CDNServer extends Server {
|
|||||||
await initDatabase();
|
await initDatabase();
|
||||||
await Config.init();
|
await Config.init();
|
||||||
await this.cleanupSignaturesInDb();
|
await this.cleanupSignaturesInDb();
|
||||||
await Sentry.init(this.app);
|
|
||||||
|
|
||||||
const logRequests = process.env["LOG_REQUESTS"] != undefined;
|
const logRequests = process.env["LOG_REQUESTS"] != undefined;
|
||||||
if (logRequests) {
|
if (logRequests) {
|
||||||
@ -123,8 +121,6 @@ export class CDNServer extends Server {
|
|||||||
);
|
);
|
||||||
this.log("verbose", "[Server] Route /guilds/banners registered");
|
this.log("verbose", "[Server] Route /guilds/banners registered");
|
||||||
|
|
||||||
Sentry.errorHandler(this.app);
|
|
||||||
|
|
||||||
return super.start();
|
return super.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,6 @@ import {
|
|||||||
Config,
|
Config,
|
||||||
initDatabase,
|
initDatabase,
|
||||||
initEvent,
|
initEvent,
|
||||||
Sentry,
|
|
||||||
} from "@spacebar/util";
|
} from "@spacebar/util";
|
||||||
import ws from "ws";
|
import ws from "ws";
|
||||||
import { Connection } from "./events/Connection";
|
import { Connection } from "./events/Connection";
|
||||||
@ -74,7 +73,6 @@ export class Server {
|
|||||||
await initDatabase();
|
await initDatabase();
|
||||||
await Config.init();
|
await Config.init();
|
||||||
await initEvent();
|
await initEvent();
|
||||||
await Sentry.init();
|
|
||||||
// temporary fix
|
// temporary fix
|
||||||
await cleanupOnStartup();
|
await cleanupOnStartup();
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,6 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as Sentry from "@sentry/node";
|
|
||||||
import { CLOSECODES, OPCODES, Payload, WebSocket } from "@spacebar/gateway";
|
import { CLOSECODES, OPCODES, Payload, WebSocket } from "@spacebar/gateway";
|
||||||
import { ErlpackType, PayloadSchema } from "@spacebar/util";
|
import { ErlpackType, PayloadSchema } from "@spacebar/util";
|
||||||
import fs from "fs/promises";
|
import fs from "fs/promises";
|
||||||
@ -25,6 +24,7 @@ import path from "path";
|
|||||||
import WS from "ws";
|
import WS from "ws";
|
||||||
import OPCodeHandlers from "../opcodes";
|
import OPCodeHandlers from "../opcodes";
|
||||||
import { check } from "../opcodes/instanceOf";
|
import { check } from "../opcodes/instanceOf";
|
||||||
|
|
||||||
const bigIntJson = BigIntJson({ storeAsString: true });
|
const bigIntJson = BigIntJson({ storeAsString: true });
|
||||||
|
|
||||||
let erlpack: ErlpackType | null = null;
|
let erlpack: ErlpackType | null = null;
|
||||||
@ -89,29 +89,8 @@ export async function Message(this: WebSocket, buffer: WS.Data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await Sentry.startSpan(
|
return await OPCodeHandler.call(this, data);
|
||||||
// Emma [it/its]@Rory&: is this the right function to migrate to in v8?
|
|
||||||
{
|
|
||||||
op: "websocket.server",
|
|
||||||
name: `GATEWAY ${OPCODES[data.op]}`,
|
|
||||||
attributes: {
|
|
||||||
// this needs to be reworked :)
|
|
||||||
...data.d,
|
|
||||||
token: data?.d?.token ? "[Redacted]" : undefined,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
async () => {
|
|
||||||
const ret = await OPCodeHandler.call(this, data);
|
|
||||||
Sentry.setUser({ id: this.user_id });
|
|
||||||
return ret;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Sentry.captureException(error, {
|
|
||||||
user: {
|
|
||||||
id: this.user_id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
console.error(`Error: Op ${data.op}`, error);
|
console.error(`Error: Op ${data.op}`, error);
|
||||||
// if (!this.CLOSED && this.CLOSING)
|
// if (!this.CLOSED && this.CLOSING)
|
||||||
return this.close(CLOSECODES.Unknown_error);
|
return this.close(CLOSECODES.Unknown_error);
|
||||||
|
|||||||
@ -35,7 +35,6 @@ import {
|
|||||||
RegionConfiguration,
|
RegionConfiguration,
|
||||||
RegisterConfiguration,
|
RegisterConfiguration,
|
||||||
SecurityConfiguration,
|
SecurityConfiguration,
|
||||||
SentryConfiguration,
|
|
||||||
TemplateConfiguration,
|
TemplateConfiguration,
|
||||||
UserConfiguration,
|
UserConfiguration,
|
||||||
} from "../config";
|
} from "../config";
|
||||||
@ -56,7 +55,6 @@ export class ConfigValue {
|
|||||||
kafka: KafkaConfiguration = new KafkaConfiguration();
|
kafka: KafkaConfiguration = new KafkaConfiguration();
|
||||||
templates: TemplateConfiguration = new TemplateConfiguration();
|
templates: TemplateConfiguration = new TemplateConfiguration();
|
||||||
metrics: MetricsConfiguration = new MetricsConfiguration();
|
metrics: MetricsConfiguration = new MetricsConfiguration();
|
||||||
sentry: SentryConfiguration = new SentryConfiguration();
|
|
||||||
defaults: DefaultsConfiguration = new DefaultsConfiguration();
|
defaults: DefaultsConfiguration = new DefaultsConfiguration();
|
||||||
external: ExternalTokensConfiguration = new ExternalTokensConfiguration();
|
external: ExternalTokensConfiguration = new ExternalTokensConfiguration();
|
||||||
email: EmailConfiguration = new EmailConfiguration();
|
email: EmailConfiguration = new EmailConfiguration();
|
||||||
|
|||||||
@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
|
||||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published
|
|
||||||
by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { hostname } from "os";
|
|
||||||
|
|
||||||
export class SentryConfiguration {
|
|
||||||
enabled: boolean = false;
|
|
||||||
endpoint: string =
|
|
||||||
"https://05e8e3d005f34b7d97e920ae5870a5e5@sentry.thearcanebrony.net/6";
|
|
||||||
traceSampleRate: number = 1.0;
|
|
||||||
environment: string = hostname();
|
|
||||||
}
|
|
||||||
@ -34,7 +34,6 @@ export * from "./RabbitMQConfiguration";
|
|||||||
export * from "./RegionConfiguration";
|
export * from "./RegionConfiguration";
|
||||||
export * from "./RegisterConfiguration";
|
export * from "./RegisterConfiguration";
|
||||||
export * from "./SecurityConfiguration";
|
export * from "./SecurityConfiguration";
|
||||||
export * from "./SentryConfiguration";
|
|
||||||
export * from "./subconfigurations";
|
export * from "./subconfigurations";
|
||||||
export * from "./TemplateConfiguration";
|
export * from "./TemplateConfiguration";
|
||||||
export * from "./UsersConfiguration";
|
export * from "./UsersConfiguration";
|
||||||
|
|||||||
@ -1,130 +0,0 @@
|
|||||||
/*
|
|
||||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
|
||||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published
|
|
||||||
by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { yellow } from "picocolors";
|
|
||||||
import { Config } from "./Config";
|
|
||||||
|
|
||||||
import * as Integrations from "@sentry/node";
|
|
||||||
import express from "express";
|
|
||||||
|
|
||||||
// Work around for when bundle calls api/etc
|
|
||||||
let errorHandlersUsed = false;
|
|
||||||
|
|
||||||
export const Sentry = {
|
|
||||||
/** Call BEFORE registering your routes */
|
|
||||||
init: async (app?: express.Application) => {
|
|
||||||
const { enabled, endpoint, traceSampleRate, environment } =
|
|
||||||
Config.get().sentry;
|
|
||||||
if (!enabled) return;
|
|
||||||
|
|
||||||
if (Integrations.getClient()) return; // we've already initialised sentry
|
|
||||||
|
|
||||||
console.log("[Sentry] Enabling sentry...");
|
|
||||||
|
|
||||||
if (traceSampleRate >= 0.8) {
|
|
||||||
console.log(
|
|
||||||
`[Sentry] ${yellow(
|
|
||||||
"Your sentry trace sampling rate is >= 80%. For large loads, this may degrade performance.",
|
|
||||||
)}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const integrations = [
|
|
||||||
Integrations.httpIntegration(),
|
|
||||||
Integrations.rewriteFramesIntegration({
|
|
||||||
root: __dirname,
|
|
||||||
}),
|
|
||||||
Integrations.httpIntegration(),
|
|
||||||
...Integrations.getAutoPerformanceIntegrations(),
|
|
||||||
];
|
|
||||||
|
|
||||||
//deprecated in v8? unable to test
|
|
||||||
// if (app)
|
|
||||||
// integrations.push(
|
|
||||||
// Integrations.expressIntegration({
|
|
||||||
// app,
|
|
||||||
// }),
|
|
||||||
// );
|
|
||||||
|
|
||||||
Integrations.init({
|
|
||||||
dsn: endpoint,
|
|
||||||
integrations,
|
|
||||||
tracesSampleRate: traceSampleRate, // naming?
|
|
||||||
environment,
|
|
||||||
});
|
|
||||||
|
|
||||||
Integrations.addEventProcessor((event) => {
|
|
||||||
if (event.transaction) {
|
|
||||||
// Rewrite things that look like IDs to `:id` for sentry
|
|
||||||
event.transaction = event.transaction
|
|
||||||
.split("/")
|
|
||||||
.map((x) => (!parseInt(x) ? x : ":id"))
|
|
||||||
.join("/");
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: does this even do anything?
|
|
||||||
delete event.request?.cookies;
|
|
||||||
if (event.request?.headers) {
|
|
||||||
delete event.request.headers["X-Real-Ip"];
|
|
||||||
delete event.request.headers["X-Forwarded-For"];
|
|
||||||
delete event.request.headers["X-Forwarded-Host"];
|
|
||||||
delete event.request.headers["X-Super-Properties"];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.breadcrumbs) {
|
|
||||||
event.breadcrumbs = event.breadcrumbs.filter((x) => {
|
|
||||||
// Filter breadcrumbs that we don't care about
|
|
||||||
if (x.message?.includes("identified as")) return false;
|
|
||||||
if (x.message?.includes("[WebSocket] closed")) return false;
|
|
||||||
if (
|
|
||||||
x.message?.includes(
|
|
||||||
"Got Resume -> cancel not implemented",
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return false;
|
|
||||||
if (x.message?.includes("[Gateway] New connection from"))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return event;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/** Call AFTER registering your routes */
|
|
||||||
errorHandler: (app: express.Application) => {
|
|
||||||
if (!Config.get().sentry.enabled) return;
|
|
||||||
if (errorHandlersUsed) return;
|
|
||||||
errorHandlersUsed = true;
|
|
||||||
|
|
||||||
Integrations.setupExpressErrorHandler(app);
|
|
||||||
|
|
||||||
// The typings for this are broken?
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
app.use(function onError(err: any, req: any, res: any, next: any) {
|
|
||||||
res.statusCode = 500;
|
|
||||||
res.end(res.sentry + "\n");
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
close: () => {
|
|
||||||
Integrations.close();
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@ -37,7 +37,6 @@ export * from "./Permissions";
|
|||||||
export * from "./RabbitMQ";
|
export * from "./RabbitMQ";
|
||||||
export * from "./Regex";
|
export * from "./Regex";
|
||||||
export * from "./Rights";
|
export * from "./Rights";
|
||||||
export * from "./Sentry";
|
|
||||||
export * from "./Snowflake";
|
export * from "./Snowflake";
|
||||||
export * from "./Stopwatch";
|
export * from "./Stopwatch";
|
||||||
export * from "./String";
|
export * from "./String";
|
||||||
|
|||||||
Reference in New Issue
Block a user