Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(cdp): accept null linkTags on SES click events (#125042)

Harley Alexanderfabcd022f440
diff --git a/nodejs/src/cdp/services/messaging/helpers/ses.test.ts b/nodejs/src/cdp/services/messaging/helpers/ses.test.ts
index 04063ec6d980..1578818dab63 100644
--- a/nodejs/src/cdp/services/messaging/helpers/ses.test.ts
+++ b/nodejs/src/cdp/services/messaging/helpers/ses.test.ts
@@ -85,7 +85,10 @@ describe('SesWebhookHandler', () => {
})
})
- it('parses a raw Click event with link URL', async () => {
+ it.each([
+ ['without linkTags', {}],
+ ['with null linkTags', { linkTags: null }],
+ ])('parses a raw Click event with link URL %s', async (_name, linkTags) => {
const body = [
{
eventType: 'Click',
@@ -95,6 +98,7 @@ describe('SesWebhookHandler', () => {
link: 'https://example.com',
userAgent: 'UA',
timestamp: '2025-10-03T12:02:00Z',
+ ...linkTags,
},
},
]
@@ -107,6 +111,7 @@ describe('SesWebhookHandler', () => {
$link_url: 'https://example.com',
})
expect(result.metrics?.[0].timestamp).toBe('2025-10-03T12:02:00Z')
+ expect(result.metrics?.[1].instanceIdOverride).toBe('act789||https://example.com')
})
it('unwraps a legacy redirect link and surfaces the SES link tag', async () => {
diff --git a/nodejs/src/cdp/services/messaging/helpers/ses.ts b/nodejs/src/cdp/services/messaging/helpers/ses.ts
index 2d1b17f76880..952e7922912e 100644
--- a/nodejs/src/cdp/services/messaging/helpers/ses.ts
+++ b/nodejs/src/cdp/services/messaging/helpers/ses.ts
@@ -85,7 +85,8 @@ const SesClickEventSchema = SesCommonEventBase.extend({
ipAddress: z.string().optional(),
link: z.string(),
// Echoes the `ses:tags` we set on each anchor at send time, as {name: [value]}.
- linkTags: z.record(z.string(), z.array(z.string())).optional(),
+ // Some SES Click events send `null` here instead of omitting the field.
+ linkTags: z.record(z.string(), z.array(z.string())).nullish(),
userAgent: z.string().optional(),
timestamp: z.string(),
}),