fix(api): reduce event spam with block list
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user