diff --git a/packages/api/src/routes/v2/report.ts b/packages/api/src/routes/v2/report.ts index 56f3596..44f65c2 100644 --- a/packages/api/src/routes/v2/report.ts +++ b/packages/api/src/routes/v2/report.ts @@ -2,7 +2,9 @@ import { FastifyInstance, RouteShorthandOptions } from 'fastify'; import { sendMail } from 'services/mailing'; type PostReportBody = { + reason?: string; url: string; + userAgent?: string; version: string; }; @@ -13,9 +15,15 @@ export default (server: FastifyInstance, options: RouteShorthandOptions, done: ( schema: { body: { properties: { + reason: { + type: 'string', + }, url: { type: 'string', }, + userAgent: { + type: 'string', + }, version: { type: 'string', }, @@ -26,8 +34,8 @@ export default (server: FastifyInstance, options: RouteShorthandOptions, done: ( }, }, async (request, reply) => { - const { url, version } = request.body; - const html = `Site: ${url}
Version: ${version}`; + const { reason = 'Unknown', url, userAgent = 'Unknown', version } = request.body; + const html = `Site: ${url}
Reason: ${reason}
User-Agent: ${userAgent}
Version: ${version}`; const subject = 'Cookie Dialog Monster Report'; const to = 'hello@wanhose.dev';