: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(cdp): add person processing toggle to vercel log drain source (#64607)
Lucas Ricoybe04edc8f822
diff --git a/nodejs/src/cdp/templates/_sources/vercel/__snapshots__/vercel_log_drain.template.test.ts.snap b/nodejs/src/cdp/templates/_sources/vercel/__snapshots__/vercel_log_drain.template.test.ts.snapindex f25700e25007..f191e65fa5b7 100644--- a/nodejs/src/cdp/templates/_sources/vercel/__snapshots__/vercel_log_drain.template.test.ts.snap+++ b/nodejs/src/cdp/templates/_sources/vercel/__snapshots__/vercel_log_drain.template.test.ts.snap@@ -3,15 +3,16 @@exports[`vercel log drain template snapshot: default config (forward_ip_and_user_agent on) emits PII fields 1`] = `[{- "distinct_id": "http_log_osdG3FHU0lqpXNai67Ma8f",+ "distinct_id": "http_log_p0PoHX1sMcM3pjV8gQ3pNj","event": "$http_log","properties": {"$current_url": "https://my-app.vercel.app/api/users?page=1",- "$distinct_id_strategy": "rotating_salt",+ "$distinct_id_strategy": "fixed_salt","$hog_function_execution_count": 1,"$host": "my-app.vercel.app","$ip": "120.75.16.101","$pathname": "/api/users",+ "$process_person_profile": false,"$raw_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36","$referrer": "https://my-app.vercel.app","branch": null,@@ -77,14 +78,15 @@ exports[`vercel log drain template snapshot: default config (forward_ip_and_userexports[`vercel log drain template snapshot: forward_ip_and_user_agent disabled drops PII fields 1`] = `[{- "distinct_id": "http_log_osdG3FHU0lqpXNai67Ma8f",+ "distinct_id": "http_log_p0PoHX1sMcM3pjV8gQ3pNj","event": "$http_log","properties": {"$current_url": "https://my-app.vercel.app/api/users?page=1",- "$distinct_id_strategy": "rotating_salt",+ "$distinct_id_strategy": "fixed_salt","$hog_function_execution_count": 1,"$host": "my-app.vercel.app","$pathname": "/api/users",+ "$process_person_profile": false,"$referrer": "https://my-app.vercel.app","branch": null,"build_id": null,diff --git a/nodejs/src/cdp/templates/_sources/vercel/vercel_log_drain.template.test.ts b/nodejs/src/cdp/templates/_sources/vercel/vercel_log_drain.template.test.tsindex 1cad27f68646..1394ba8c8e83 100644--- a/nodejs/src/cdp/templates/_sources/vercel/vercel_log_drain.template.test.ts+++ b/nodejs/src/cdp/templates/_sources/vercel/vercel_log_drain.template.test.ts@@ -291,6 +291,17 @@ describe('vercel log drain template', () => {expect(props.proxy_user_agent).toBeUndefined()})+ it.each([+ ['default (no override)', {}, false],+ ['explicit anonymous', { person_processing: 'anonymous' }, false],+ ['identified', { person_processing: 'identified' }, true],+ ])('person_processing %s emits $process_person_profile=%s', async (_name, inputs, expected) => {+ const response = await tester.invoke(inputs, { request: createVercelRequest(vercelLogDrain) })++ expect(response.error).toBeUndefined()+ expect(response.capturedPostHogEvents[0].properties.$process_person_profile).toBe(expected)+ })+it('should handle logs with null message without crashing', async () => {const { message, ...logWithoutMessage } = vercelLogDrainconst log = { ...logWithoutMessage, message: null }diff --git a/nodejs/src/cdp/templates/_sources/vercel/vercel_log_drain.template.ts b/nodejs/src/cdp/templates/_sources/vercel/vercel_log_drain.template.tsindex fb8a390444d3..8e03361e731e 100644--- a/nodejs/src/cdp/templates/_sources/vercel/vercel_log_drain.template.ts+++ b/nodejs/src/cdp/templates/_sources/vercel/vercel_log_drain.template.ts@@ -155,8 +155,8 @@ fun extractPathname(url) {return url}-// Distinct ID: configurable strategy. Default is a daily-rotating salted hash-// of (ip, host, ua). The active strategy is recorded as $distinct_id_strategy+// Distinct ID: configurable strategy. Default is a fixed salted hash of (ip, host, ua) —+// one stable ID per client. The active strategy is recorded as $distinct_id_strategy// on the event for diagnostics — it is not an analytical breakdown dimension.let host := proxy.host ?? log.host ?? ''let clientIp := proxy.clientIp ?? ''@@ -166,7 +166,7 @@ let path := proxy.path ?? log.path ?? ''let day := formatDateTime(now(), '%Y-%m-%d')let salt := inputs.salt_secret ?? ''-let strategy := inputs.distinct_id_strategy ?? 'rotating_salt'+let strategy := inputs.distinct_id_strategy ?? 'fixed_salt'let activeStrategy := strategylet distinctId := ''@@ -220,6 +220,11 @@ let queryParams := parseQueryParams(path)let pathname := extractPathname(path)let props := {+ // Person processing. Anonymous by default ($process_person_profile = false) so high-cardinality+ // log traffic does not create a person profile per distinct ID — cheaper and faster to query.+ // Set the "Person processing" input to "identified" to create person profiles for stitching.+ '$process_person_profile': inputs.person_processing == 'identified',+// PostHog standard properties. $ip and $raw_user_agent are appended// below when forward_ip_and_user_agent is enabled (default on, since// PostHog's GeoIP and UA enrichment depend on them); flip the toggle@@ -360,15 +365,15 @@ return {type: 'choice',label: 'Distinct ID strategy',description:- 'How distinct IDs are derived. Default rotates daily so the same client gets a fresh ID each day. The active strategy is recorded on each event as $distinct_id_strategy for debugging.',+ 'How distinct IDs are derived from the request. Because events are anonymous by default (no person profiles), this affects unique-visitor counting rather than cost. The default, fixed salt, gives one stable ID per client (IP + host + user agent) for accurate uniques. Rotating salt rotates that ID daily for extra privacy, at the cost of inflated unique counts. The active strategy is recorded on each event as $distinct_id_strategy for debugging.',choices: [{- value: 'rotating_salt',- label: 'Rotating salt (sha256(salt:day:ip:host:ua)) — daily rotation, default',+ value: 'fixed_salt',+ label: 'Fixed salt (sha256(salt:ip:host:ua)) — one stable ID per client, default',},{- value: 'fixed_salt',- label: 'Fixed salt (sha256(salt:ip:host:ua)) — stable until salt rotates',+ value: 'rotating_salt',+ label: 'Rotating salt (sha256(salt:day:ip:host:ua)) — rotates daily for privacy',},{value: 'ip',@@ -379,7 +384,27 @@ return {label: 'Custom template — placeholder substitution (see template field)',},],- default: 'rotating_salt',+ default: 'fixed_salt',+ secret: false,+ required: true,+ },+ {+ key: 'person_processing',+ type: 'choice',+ label: 'Person processing',+ description:+ 'Whether each event creates a person profile. "Anonymous" (default) emits $process_person_profile=false so high-cardinality log traffic does not create a person profile per distinct ID — cheaper, faster to query, and recommended for aggregate traffic and bot analysis. "Identified" creates a person profile per distinct ID for person-level stitching (billed on the person-profiles line).',+ choices: [+ {+ value: 'anonymous',+ label: 'Anonymous — no person profiles (recommended for log traffic)',+ },+ {+ value: 'identified',+ label: 'Identified — create a person profile per distinct ID',+ },+ ],+ default: 'anonymous',secret: false,required: true,},