0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-25 02:49:32 +01:00

feat: Add sent-at property during normalizeEvent (#15151)

This commit is contained in:
Tomás Farías Santana 2023-04-21 11:31:59 +02:00 committed by GitHub
parent e846228a54
commit 5d7900dfd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -84,6 +84,10 @@ export function normalizeEvent(event: PluginEvent): PluginEvent {
if (!['$snapshot', '$performance_event'].includes(event.event)) {
properties = personInitialAndUTMProperties(properties)
}
if (event.sent_at) {
properties['$sent_at'] = event.sent_at
}
event.properties = properties
return event
}

View File

@ -20,8 +20,8 @@ describe('normalizeEvent()', () => {
const event = { distinct_id: 'something' }
expect(normalizeEvent(event as any).properties).toEqual({})
const event2 = { distinct_id: 'something', properties: { a: 1 } }
expect(normalizeEvent(event2 as any).properties).toEqual({ a: 1 })
const event2 = { distinct_id: 'something', properties: { a: 1 }, sent_at: '2020-02-23T02:15:00.000Z' }
expect(normalizeEvent(event2 as any).properties).toEqual({ a: 1, $sent_at: '2020-02-23T02:15:00.000Z' })
})
it('combines .properties $set and $set_once with top-level $set and $set_once', () => {
@ -127,7 +127,7 @@ describe('formPipelineEvent()', () => {
sent_at: '2020-02-23T02:15:00Z',
token: 'phc_sometoken',
event: 'some-event',
properties: { foo: 123, $set: {}, $set_once: {} },
properties: { foo: 123, $set: {}, $set_once: {}, $sent_at: '2020-02-23T02:15:00Z' },
timestamp: '2020-02-24T02:15:00Z',
offset: 0,
$set: {},
@ -178,7 +178,7 @@ describe('formPipelineEvent()', () => {
sent_at: '2020-02-23T02:15:00Z',
token: 'phc_sometoken',
event: 'some-event',
properties: { foo: 123, $set: {}, $set_once: {} },
properties: { foo: 123, $set: {}, $set_once: {}, $sent_at: '2020-02-23T02:15:00Z' },
timestamp: '2020-02-24T02:15:00Z',
offset: 0,
$set: {},