fix: Prevent manual tracking of internal events that are automatically tracked

This commit is contained in:
Dries Augustyns
2025-12-12 20:30:49 +01:00
parent a555a12736
commit f34052ed73
4 changed files with 419 additions and 3 deletions
+15
View File
@@ -55,6 +55,21 @@ export class Actions {
// Zod validation - errors automatically handled by global error handler
const {event, email, subscribed, data} = ActionSchemas.track.parse(req.body);
// Prevent manual tracking of reserved system events
if (EventService.isReservedEvent(event)) {
throw new ValidationError(
[
{
field: 'event',
message: `Event name "${event}" is reserved for system use and cannot be manually tracked`,
code: 'reserved_event',
received: event,
},
],
'Cannot track reserved system event',
);
}
// Create or update contact with persistent data only
// ContactService.upsert will filter out non-persistent fields
const contact = await ContactService.upsert(