feat(api): Add more Sentry logging

This commit is contained in:
Jesse Wierzbinski 2024-07-24 19:04:00 +02:00
parent daba8e8178
commit 0bc6a89706
No known key found for this signature in database
6 changed files with 14 additions and 0 deletions

1
app.ts
View file

@ -68,6 +68,7 @@ export const appFactory = async () => {
redirect: "manual",
}).catch((e) => {
serverLogger.error`${e}`;
sentry?.captureException(e);
serverLogger.error`The Frontend is not running or the route is not found: ${replacedUrl}`;
return null;
});

View file

@ -1,4 +1,5 @@
import { errorResponse } from "@/response";
import { sentry } from "@/sentry";
import { createMiddleware } from "@hono/hono/factory";
import { getLogger } from "@logtape/logtape";
import type { SocketAddress } from "bun";
@ -25,6 +26,7 @@ export const ipBans = createMiddleware(async (context, next) => {
logger.error`Error while parsing banned IP "${ip}" `;
logger.error`${e}`;
sentry?.captureException(e);
return errorResponse(
`A server error occured: ${(e as Error).message}`,

View file

@ -1,6 +1,7 @@
import { idValidator } from "@/api";
import { proxyUrl } from "@/response";
import { sanitizedHtmlStrip } from "@/sanitization";
import { sentry } from "@/sentry";
import { getLogger } from "@logtape/logtape";
import type {
Attachment as ApiAttachment,
@ -627,6 +628,7 @@ export class Note extends BaseInterface<typeof Notes, StatusWithRelations> {
const resolvedEmoji = await Emoji.fetchFromRemote(emoji).catch(
(e) => {
logger.error`${e}`;
sentry?.captureException(e);
return null;
},
);
@ -643,6 +645,7 @@ export class Note extends BaseInterface<typeof Notes, StatusWithRelations> {
attachment,
).catch((e) => {
logger.error`${e}`;
sentry?.captureException(e);
return null;
});

View file

@ -1,6 +1,7 @@
import { applyConfig, handleZodError, jsonOrForm } from "@/api";
import { randomString } from "@/math";
import { response } from "@/response";
import { sentry } from "@/sentry";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { SignJWT, jwtVerify } from "jose";
@ -136,6 +137,7 @@ export default (app: Hono) =>
audience: client_id,
}).catch((e) => {
console.error(e);
sentry?.captureException(e);
return null;
});

View file

@ -1,5 +1,6 @@
import { applyConfig, debugRequest, handleZodError } from "@/api";
import { errorResponse, jsonResponse, response } from "@/response";
import { sentry } from "@/sentry";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { getLogger } from "@logtape/logtape";
@ -183,6 +184,7 @@ export default (app: Hono) =>
)
.catch((e) => {
logger.error`${e}`;
sentry?.captureException(e);
return false;
});
@ -208,6 +210,7 @@ export default (app: Hono) =>
account,
).catch((e) => {
logger.error`${e}`;
sentry?.captureException(e);
return null;
});
@ -432,6 +435,7 @@ export default (app: Hono) =>
return errorResponse((e as ValidationError).message, 400);
}
logger.error`${e}`;
sentry?.captureException(e);
return jsonResponse(
{
error: "Failed to process request",

View file

@ -1,5 +1,6 @@
import { getLogger } from "@logtape/logtape";
import { markdownParse } from "~/classes/functions/status";
import { sentry } from "./sentry";
export const renderMarkdownInPath = async (
path: string,
@ -15,6 +16,7 @@ export const renderMarkdownInPath = async (
(await markdownParse(
(await extendedDescriptionFile.text().catch(async (e) => {
await getLogger("server").error`${e}`;
sentry?.captureException(e);
return "";
})) ||
defaultText ||