diff --git a/plugin-server/src/utils/event.ts b/plugin-server/src/utils/event.ts index 59ccbc6707d2e..3f02106b3b8a6 100644 --- a/plugin-server/src/utils/event.ts +++ b/plugin-server/src/utils/event.ts @@ -214,7 +214,7 @@ export function normalizeProcessPerson(event: PluginEvent, processPerson: boolea return event } -export function normalizeEvent(event: PluginEvent): PluginEvent { +export function normalizeEvent(event: T): T { event.distinct_id = sanitizeString(String(event.distinct_id)) let properties = event.properties ?? {} @@ -245,7 +245,7 @@ export function normalizeEvent(event: PluginEvent): PluginEvent { export function formPipelineEvent(message: Message): PipelineEvent { // TODO: inefficient to do this twice? const { data: dataStr, ...rawEvent } = JSON.parse(message.value!.toString()) - const combinedEvent = { ...JSON.parse(dataStr), ...rawEvent } + const combinedEvent: PipelineEvent = { ...JSON.parse(dataStr), ...rawEvent } // Track $set usage in events that aren't known to use it, before ingestion adds anything there if ( @@ -261,13 +261,13 @@ export function formPipelineEvent(message: Message): PipelineEvent { status.info('👀', 'Found $set usage in non-person event', { event: combinedEvent.event, team_id: combinedEvent.team_id, + token: combinedEvent.token, }) } } const event: PipelineEvent = normalizeEvent({ ...combinedEvent, - site_url: combinedEvent.site_url || null, }) return event } diff --git a/plugin-server/tests/main/ingestion-queues/each-batch.test.ts b/plugin-server/tests/main/ingestion-queues/each-batch.test.ts index 98f5f5d965a36..e693267599197 100644 --- a/plugin-server/tests/main/ingestion-queues/each-batch.test.ts +++ b/plugin-server/tests/main/ingestion-queues/each-batch.test.ts @@ -367,7 +367,7 @@ describe('eachBatchX', () => { ip: null, now: null, sent_at: null, - site_url: null, + site_url: '', team_id: 1, uuid: 'uuid1', })