fix(api): reduce event spam with block list

This commit is contained in:
Carl-Gerhard Lindesvärd
2026-02-05 21:23:48 +00:00
parent 02897e11cb
commit ef8c2a4eee
3 changed files with 127 additions and 0 deletions

View File

@@ -2,6 +2,8 @@ import { z } from 'zod';
import { RESERVED_EVENT_NAMES } from '@openpanel/constants';
import { isBlockedEventName } from './event-blocklist';
export const zTrackPayload = z
.object({
name: z.string().min(1),
@@ -12,6 +14,10 @@ export const zTrackPayload = z
message: `Event name cannot be one of the reserved names: ${RESERVED_EVENT_NAMES.join(', ')}`,
path: ['name'],
})
.refine((data) => !isBlockedEventName(data.name), {
message: 'Event name contains blocked content',
path: ['name'],
})
.refine(
(data) => {
if (data.name !== 'revenue') return true;