Add metrics

This commit is contained in:
2025-09-15 00:13:57 +02:00
parent be5b042380
commit 33c7e2335f
8 changed files with 108 additions and 3 deletions
+19
View File
@@ -3,6 +3,11 @@ import { randomUUID } from 'node:crypto';
import { z } from 'zod';
import prisma from '~~/lib/prisma';
import { minioClient, s3Bucket, s3Host } from '~~/lib/s3';
import {
answerChanged,
answerFinalized,
imageUploaded
} from '~~/server/metrics';
export default defineEventHandler(async (event) => {
const { questId } = await useValidatedParams(
@@ -21,6 +26,7 @@ export default defineEventHandler(async (event) => {
},
select: {
id: true,
huntId: true,
hunt: {
select: {
teams: {
@@ -125,6 +131,9 @@ export default defineEventHandler(async (event) => {
undefined;
if (data.image) {
imageUploaded.inc({
hunt: quest.huntId
});
const uuid = randomUUID();
await minioClient.putObject(
s3Bucket,
@@ -215,5 +224,15 @@ export default defineEventHandler(async (event) => {
}
}
answerChanged.inc({
hunt: quest.huntId
});
if (data.final) {
answerFinalized.inc({
hunt: quest.huntId
});
}
return { ok: true };
});