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.

feat(cdp): add configurable distinct_id_strategy to vercel log drain (#57678)

Lucas Ricoyce4b250c5bf5
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.snap
index 3da93bb9f85b..f25700e25007 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
@@ -1,12 +1,13 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
-exports[`vercel log drain template should capture all Vercel log properties with snake_case naming 1`] = `
+exports[`vercel log drain template snapshot: default config (forward_ip_and_user_agent on) emits PII fields 1`] = `
[
{
- "distinct_id": "vercel_3d16a3830c1eece2670ab5457bd3839a4bedcba3f438cb5e776f791ec047d716",
+ "distinct_id": "http_log_osdG3FHU0lqpXNai67Ma8f",
"event": "$http_log",
"properties": {
"$current_url": "https://my-app.vercel.app/api/users?page=1",
+ "$distinct_id_strategy": "rotating_salt",
"$hog_function_execution_count": 1,
"$host": "my-app.vercel.app",
"$ip": "120.75.16.101",
@@ -72,3 +73,71 @@ exports[`vercel log drain template should capture all Vercel log properties with
},
]
`;
+
+exports[`vercel log drain template snapshot: forward_ip_and_user_agent disabled drops PII fields 1`] = `
+[
+ {
+ "distinct_id": "http_log_osdG3FHU0lqpXNai67Ma8f",
+ "event": "$http_log",
+ "properties": {
+ "$current_url": "https://my-app.vercel.app/api/users?page=1",
+ "$distinct_id_strategy": "rotating_salt",
+ "$hog_function_execution_count": 1,
+ "$host": "my-app.vercel.app",
+ "$pathname": "/api/users",
+ "$referrer": "https://my-app.vercel.app",
+ "branch": null,
+ "build_id": null,
+ "deployment_id": "dpl_233NRGRjVZX1caZrXWtz5g1TAksD",
+ "destination": null,
+ "edge_type": null,
+ "entrypoint": "api/index.js",
+ "environment": "production",
+ "execution_region": "sfo1",
+ "host": "my-app-abc123.vercel.app",
+ "instance_id": "1GQNa0uAPkg0",
+ "invocation_id": "01KPVBPVC87N00DCM26QSNN140",
+ "ja3_digest": null,
+ "ja4_digest": null,
+ "level": "info",
+ "message": "API request processed successfully",
+ "message_truncated": false,
+ "path": "/api/users",
+ "project_id": "gdufoJxB6b9b1fEqr1jUtFkyavUU",
+ "project_name": "my-app",
+ "proxy_cache_id": null,
+ "proxy_host": "my-app.vercel.app",
+ "proxy_lambda_region": null,
+ "proxy_method": "GET",
+ "proxy_path": "/api/users?page=1",
+ "proxy_path_type": null,
+ "proxy_path_type_variant": null,
+ "proxy_referer": "https://my-app.vercel.app",
+ "proxy_region": "sfo1",
+ "proxy_response_byte_size": null,
+ "proxy_scheme": "https",
+ "proxy_status_code": 200,
+ "proxy_timestamp_ms": 1573817250172,
+ "proxy_vercel_cache": "MISS",
+ "proxy_vercel_id": null,
+ "proxy_waf_action": null,
+ "proxy_waf_rule_id": null,
+ "request_id": "643af4e3-975a-4cc7-9e7a-1eda11539d90",
+ "source": "lambda",
+ "span_id": "f24e8631bd11faa7",
+ "status_code": 200,
+ "trace_id": "1b02cd14bb8642fd092bc23f54c7ffcd",
+ "type": null,
+ "utm_campaign": null,
+ "utm_content": null,
+ "utm_medium": null,
+ "utm_source": null,
+ "utm_term": null,
+ "vercel_log_id": "1573817250283254651097202070",
+ "vercel_timestamp_ms": 1573817250283,
+ },
+ "team_id": 1,
+ "timestamp": "2025-01-01T00:00:00.000Z",
+ },
+]
+`;
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.ts
index 3727c98b5543..1cad27f68646 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
@@ -25,7 +25,7 @@ describe('vercel log drain template', () => {
expect(response.finished).toEqual(true)
expect(response.capturedPostHogEvents).toHaveLength(1)
expect(response.capturedPostHogEvents[0].event).toEqual('$http_log')
- expect(response.capturedPostHogEvents[0].distinct_id).toMatch(/^vercel_[a-f0-9]{64}$/)
+ expect(response.capturedPostHogEvents[0].distinct_id).toMatch(/^http_log_[A-Za-z0-9+/]{22}$/)
expect(response.capturedPostHogEvents[0].properties).toMatchObject({
source: 'lambda',
level: 'info',
@@ -218,10 +218,10 @@ describe('vercel log drain template', () => {
)
expect(response.error).toBeUndefined()
- expect(response.capturedPostHogEvents[0].distinct_id).toMatch(/^vercel_[a-f0-9]{64}$/)
+ expect(response.capturedPostHogEvents[0].distinct_id).toMatch(/^http_log_[A-Za-z0-9+/]{22}$/)
})
- it('should capture all Vercel log properties with snake_case naming', async () => {
+ it('snapshot: default config (forward_ip_and_user_agent on) emits PII fields', async () => {
const response = await tester.invoke(
{},
{
@@ -232,7 +232,18 @@ describe('vercel log drain template', () => {
expect(response.capturedPostHogEvents).toMatchSnapshot()
})
- it('should flatten proxy properties', async () => {
+ it('snapshot: forward_ip_and_user_agent disabled drops PII fields', async () => {
+ const response = await tester.invoke(
+ { forward_ip_and_user_agent: false },
+ {
+ request: createVercelRequest(vercelLogDrain),
+ }
+ )
+
+ expect(response.capturedPostHogEvents).toMatchSnapshot()
+ })
+
+ it('should flatten all proxy properties (including PII) by default', async () => {
const response = await tester.invoke(
{},
{
@@ -249,7 +260,7 @@ describe('vercel log drain template', () => {
expect(props.proxy_vercel_cache).toBe('MISS')
})
- it('should set PostHog standard properties from proxy data', async () => {
+ it('should emit $ip, $raw_user_agent, and proxy_* PII by default and set $current_url from proxy data', async () => {
const response = await tester.invoke(
{},
{
@@ -261,9 +272,25 @@ describe('vercel log drain template', () => {
const props = response.capturedPostHogEvents[0].properties
expect(props.$ip).toBe('120.75.16.101')
expect(props.$raw_user_agent).toBe('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36')
+ expect(props.proxy_client_ip).toBe('120.75.16.101')
+ expect(props.proxy_user_agent).toEqual(['Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36'])
expect(props.$current_url).toBe('https://my-app.vercel.app/api/users?page=1')
})
+ it('should drop $ip, $raw_user_agent, and proxy_* PII when forward_ip_and_user_agent is disabled', async () => {
+ const response = await tester.invoke(
+ { forward_ip_and_user_agent: false },
+ { request: createVercelRequest(vercelLogDrain) }
+ )
+
+ expect(response.error).toBeUndefined()
+ const props = response.capturedPostHogEvents[0].properties
+ expect(props.$ip).toBeUndefined()
+ expect(props.$raw_user_agent).toBeUndefined()
+ expect(props.proxy_client_ip).toBeUndefined()
+ expect(props.proxy_user_agent).toBeUndefined()
+ })
+
it('should handle logs with null message without crashing', async () => {
const { message, ...logWithoutMessage } = vercelLogDrain
const log = { ...logWithoutMessage, message: null }
@@ -294,7 +321,7 @@ describe('vercel log drain template', () => {
expect(response.error).toBeUndefined()
expect(response.capturedPostHogEvents).toHaveLength(1)
- expect(response.capturedPostHogEvents[0].distinct_id).toMatch(/^vercel_[a-f0-9]{64}$/)
+ expect(response.capturedPostHogEvents[0].distinct_id).toMatch(/^http_log_[A-Za-z0-9+/]{22}$/)
// Proxy fields should be null when proxy is missing
expect(response.capturedPostHogEvents[0].properties.proxy_method).toBeNull()
})
@@ -501,6 +528,197 @@ describe('vercel log drain template', () => {
// Valid encoding still works
expect(props.utm_source).toBe('google')
})
+
+ describe('distinct_id_strategy', () => {
+ const setMockedDay = (iso: string): void => {
+ jest.spyOn(Date, 'now').mockReturnValue(DateTime.fromISO(iso, { zone: 'utc' }).toMillis())
+ }
+
+ const otherUaProxy = {
+ ...vercelLogDrain.proxy,
+ userAgent: ['curl/8.0'],
+ }
+
+ const otherIpProxy = {
+ ...vercelLogDrain.proxy,
+ clientIp: '203.0.113.7',
+ }
+
+ it('rotating_salt: same inputs same day → same id; different day → different id', async () => {
+ setMockedDay('2025-01-01T00:00:00Z')
+ const day1 = await tester.invoke(
+ { salt_secret: 'test-salt', distinct_id_strategy: 'rotating_salt' },
+ { request: createVercelRequest(vercelLogDrain) }
+ )
+ const day1Repeat = await tester.invoke(
+ { salt_secret: 'test-salt', distinct_id_strategy: 'rotating_salt' },
+ { request: createVercelRequest(vercelLogDrain) }
+ )
+ setMockedDay('2025-01-02T00:00:00Z')
+ const day2 = await tester.invoke(
+ { salt_secret: 'test-salt', distinct_id_strategy: 'rotating_salt' },
+ { request: createVercelRequest(vercelLogDrain) }
+ )
+
+ const id1 = day1.capturedPostHogEvents[0].distinct_id
+ const id1Repeat = day1Repeat.capturedPostHogEvents[0].distinct_id
+ const id2 = day2.capturedPostHogEvents[0].distinct_id
+
+ expect(id1).toMatch(/^http_log_[A-Za-z0-9+/]{22}$/)
+ expect(id1Repeat).toBe(id1)
+ expect(id2).not.toBe(id1)
+ expect(day1.capturedPostHogEvents[0].properties.$distinct_id_strategy).toBe('rotating_salt')
+ })
+
+ it('rotating_salt: different UA on the same IP/day → different id', async () => {
+ setMockedDay('2025-01-01T00:00:00Z')
+ const baseline = await tester.invoke(
+ { salt_secret: 'test-salt', distinct_id_strategy: 'rotating_salt' },
+ { request: createVercelRequest(vercelLogDrain) }
+ )
+ const otherUa = await tester.invoke(
+ { salt_secret: 'test-salt', distinct_id_strategy: 'rotating_salt' },
+ { request: createVercelRequest({ ...vercelLogDrain, proxy: otherUaProxy }) }
+ )
+
+ expect(otherUa.capturedPostHogEvents[0].distinct_id).not.toBe(baseline.capturedPostHogEvents[0].distinct_id)
+ })
+
+ it('fixed_salt: same inputs different days → same id; rotating salt → different id', async () => {
+ setMockedDay('2025-01-01T00:00:00Z')
+ const day1 = await tester.invoke(
+ { salt_secret: 'salt-v1', distinct_id_strategy: 'fixed_salt' },
+ { request: createVercelRequest(vercelLogDrain) }
+ )
+ setMockedDay('2025-02-15T00:00:00Z')
+ const day2 = await tester.invoke(
+ { salt_secret: 'salt-v1', distinct_id_strategy: 'fixed_salt' },
+ { request: createVercelRequest(vercelLogDrain) }
+ )
+ const rotated = await tester.invoke(
+ { salt_secret: 'salt-v2', distinct_id_strategy: 'fixed_salt' },
+ { request: createVercelRequest(vercelLogDrain) }
+ )
+
+ expect(day1.capturedPostHogEvents[0].distinct_id).toMatch(/^http_log_[A-Za-z0-9+/]{22}$/)
+ expect(day2.capturedPostHogEvents[0].distinct_id).toBe(day1.capturedPostHogEvents[0].distinct_id)
+ expect(rotated.capturedPostHogEvents[0].distinct_id).not.toBe(day1.capturedPostHogEvents[0].distinct_id)
+ expect(day1.capturedPostHogEvents[0].properties.$distinct_id_strategy).toBe('fixed_salt')
+ })
+
+ it('ip: literal client IP after the prefix; stable across days', async () => {
+ setMockedDay('2025-01-01T00:00:00Z')
+ const day1 = await tester.invoke(
+ { salt_secret: 'unused', distinct_id_strategy: 'ip' },
+ { request: createVercelRequest(vercelLogDrain) }
+ )
+ setMockedDay('2025-03-01T00:00:00Z')
+ const day2 = await tester.invoke(
+ { salt_secret: 'unused', distinct_id_strategy: 'ip' },
+ { request: createVercelRequest(vercelLogDrain) }
+ )
+ const otherIp = await tester.invoke(
+ { salt_secret: 'unused', distinct_id_strategy: 'ip' },
+ { request: createVercelRequest({ ...vercelLogDrain, proxy: otherIpProxy }) }
+ )
+
+ expect(day1.capturedPostHogEvents[0].distinct_id).toBe('http_log_120.75.16.101')
+ expect(day2.capturedPostHogEvents[0].distinct_id).toBe('http_log_120.75.16.101')
+ expect(otherIp.capturedPostHogEvents[0].distinct_id).toBe('http_log_203.0.113.7')
+ expect(day1.capturedPostHogEvents[0].properties.$distinct_id_strategy).toBe('ip')
+ })
+
+ it('custom: substitutes placeholders into the template', async () => {
+ const response = await tester.invoke(
+ {
+ salt_secret: 'unused',
+ distinct_id_strategy: 'custom',
+ custom_template: 'tenant_{host}_{ip}',
+ },
+ { request: createVercelRequest(vercelLogDrain) }
+ )
+
+ expect(response.error).toBeUndefined()
+ expect(response.capturedPostHogEvents[0].distinct_id).toBe(
+ 'http_log_tenant_my-app.vercel.app_120.75.16.101'
+ )
+ expect(response.capturedPostHogEvents[0].properties.$distinct_id_strategy).toBe('custom')
+ })
+
+ it('custom: substituted-to-empty template falls back to rotating_salt', async () => {
+ const logWithoutUa = {
+ ...vercelLogDrain,
+ proxy: { ...vercelLogDrain.proxy, userAgent: [] },
+ }
+ const response = await tester.invoke(
+ {
+ salt_secret: 'test-salt',
+ distinct_id_strategy: 'custom',
+ custom_template: '{ua}',
+ },
+ { request: createVercelRequest(logWithoutUa) }
+ )
+
+ expect(response.error).toBeUndefined()
+ expect(response.capturedPostHogEvents[0].distinct_id).toMatch(/^http_log_[A-Za-z0-9+/]{22}$/)
+ expect(response.capturedPostHogEvents[0].properties.$distinct_id_strategy).toBe('rotating_salt_fallback')
+ expect(response.logs.map((l) => l.message)).toContainEqual(expect.stringContaining('substituted to empty'))
+ })
+
+ it('custom: {salt} placeholder is not interpreted (secret never reaches distinct_id)', async () => {
+ const response = await tester.invoke(
+ {
+ salt_secret: 'super-secret-salt',
+ distinct_id_strategy: 'custom',
+ custom_template: 'leak_{salt}_check',
+ },
+ { request: createVercelRequest(vercelLogDrain) }
+ )
+
+ expect(response.error).toBeUndefined()
+ const distinctId = response.capturedPostHogEvents[0].distinct_id
+ expect(distinctId).toBe('http_log_leak_{salt}_check')
+ expect(distinctId).not.toContain('super-secret-salt')
+ })
+
+ it('custom: empty template falls back to rotating_salt and warns', async () => {
+ const response = await tester.invoke(
+ {
+ salt_secret: 'test-salt',
+ distinct_id_strategy: 'custom',
+ custom_template: '',
+ },
+ { request: createVercelRequest(vercelLogDrain) }
+ )
+
+ expect(response.error).toBeUndefined()
+ expect(response.capturedPostHogEvents[0].distinct_id).toMatch(/^http_log_[A-Za-z0-9+/]{22}$/)
+ expect(response.capturedPostHogEvents[0].properties.$distinct_id_strategy).toBe('rotating_salt_fallback')
+ expect(response.logs.map((l) => l.message)).toContainEqual(
+ expect.stringContaining('custom_template empty, falling back')
+ )
+ })
+
+ it.each(['rotating_salt', 'fixed_salt', 'ip', 'custom'])(
+ 'strategy %s: omits $ip and $raw_user_agent when forward toggle is explicitly false',
+ async (strategy) => {
+ const response = await tester.invoke(
+ {
+ salt_secret: 'test-salt',
+ distinct_id_strategy: strategy,
+ custom_template: strategy === 'custom' ? 'k_{ip}' : undefined,
+ forward_ip_and_user_agent: false,
+ },
+ { request: createVercelRequest(vercelLogDrain) }
+ )
+
+ expect(response.error).toBeUndefined()
+ const props = response.capturedPostHogEvents[0].properties
+ expect(props.$ip).toBeUndefined()
+ expect(props.$raw_user_agent).toBeUndefined()
+ }
+ )
+ })
})
const createVercelRequest = (body: Record<string, any> | Record<string, any>[]) => {
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.ts
index d277b4a9b02e..fb8a390444d3 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,22 +155,76 @@ fun extractPathname(url) {
return url
}
-// Distinct ID: user-level grouping based on project, host, client IP, and user agent
+// Distinct ID: configurable strategy. Default is a daily-rotating salted hash
+// of (ip, host, ua). 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 ?? ''
let userAgent := proxy.userAgent[1] ?? ''
let scheme := proxy.scheme ?? 'https'
let path := proxy.path ?? log.path ?? ''
-let distinctId := f'vercel_{sha256Hex(f'{log.projectId}:{host}:{clientIp}:{userAgent}')}'
+
+let day := formatDateTime(now(), '%Y-%m-%d')
+let salt := inputs.salt_secret ?? ''
+let strategy := inputs.distinct_id_strategy ?? 'rotating_salt'
+let activeStrategy := strategy
+let distinctId := ''
+
+// Hashed strategies emit a 22-char unpadded base64 prefix of sha256, matching
+// the visual format of PostHog cookieless distinct IDs (132 bits of entropy —
+// far more than needed for collision resistance, and short enough to be readable).
+fun shortHash(input) {
+ return substring(sha256(input, 'base64'), 1, 22)
+}
+
+if (strategy == 'rotating_salt') {
+ distinctId := f'http_log_{shortHash(f'{salt}:{day}:{clientIp}:{host}:{userAgent}')}'
+} else if (strategy == 'fixed_salt') {
+ distinctId := f'http_log_{shortHash(f'{salt}:{clientIp}:{host}:{userAgent}')}'
+} else if (strategy == 'ip') {
+ distinctId := f'http_log_{clientIp}'
+} else if (strategy == 'custom') {
+ let customTemplate := inputs.custom_template ?? ''
+ if (empty(customTemplate)) {
+ print('vercel log drain: custom_template empty, falling back to rotating_salt')
+ distinctId := f'http_log_{shortHash(f'{salt}:{day}:{clientIp}:{host}:{userAgent}')}'
+ activeStrategy := 'rotating_salt_fallback'
+ } else {
+ let result := customTemplate
+ // Note: {salt} is intentionally NOT a placeholder — exposing the secret
+ // in distinct_ids would defeat its purpose (events are stored in plain text).
+ result := replaceAll(result, '{day}', day)
+ result := replaceAll(result, '{ip}', clientIp)
+ result := replaceAll(result, '{host}', host)
+ result := replaceAll(result, '{ua}', userAgent)
+ result := replaceAll(result, '{path}', path)
+ result := replaceAll(result, '{project_id}', toString(log.projectId))
+ // Guard: if every placeholder resolved to empty, fall back to rotating_salt
+ // so we don't collapse all such requests onto a single 'http_log_' id.
+ if (empty(result)) {
+ print('vercel log drain: custom_template substituted to empty, falling back to rotating_salt')
+ distinctId := f'http_log_{shortHash(f'{salt}:{day}:{clientIp}:{host}:{userAgent}')}'
+ activeStrategy := 'rotating_salt_fallback'
+ } else {
+ distinctId := f'http_log_{result}'
+ }
+ }
+} else {
+ // Unknown strategy value — treat as rotating_salt
+ distinctId := f'http_log_{shortHash(f'{salt}:{day}:{clientIp}:{host}:{userAgent}')}'
+ activeStrategy := 'rotating_salt'
+}
// Parse URL for pathname and UTM parameters
let queryParams := parseQueryParams(path)
let pathname := extractPathname(path)
let props := {
- // PostHog standard properties
- '$ip': clientIp,
- '$raw_user_agent': userAgent,
+ // 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
+ // off to keep raw client identifiers off the emitted event.
+ '$distinct_id_strategy': activeStrategy,
'$current_url': f'{scheme}://{host}{path}',
'$host': host,
'$pathname': pathname,
@@ -227,11 +281,10 @@ let props := {
'proxy_method': proxy.method,
'proxy_host': proxy.host,
'proxy_path': proxy.path,
- 'proxy_user_agent': proxy.userAgent,
+ // proxy_user_agent and proxy_client_ip are gated on forward_ip_and_user_agent below.
'proxy_region': proxy.region,
'proxy_referer': proxy.referer,
'proxy_status_code': proxy.statusCode,
- 'proxy_client_ip': proxy.clientIp,
'proxy_scheme': proxy.scheme,
'proxy_response_byte_size': proxy.responseByteSize,
'proxy_cache_id': proxy.cacheId,
@@ -244,6 +297,13 @@ let props := {
'proxy_waf_rule_id': proxy.wafRuleId
}
+if (inputs.forward_ip_and_user_agent) {
+ props['$ip'] := clientIp
+ props['$raw_user_agent'] := userAgent
+ props['proxy_client_ip'] := proxy.clientIp
+ props['proxy_user_agent'] := proxy.userAgent
+}
+
postHogCapture({
'event': '$http_log',
'distinct_id': distinctId,
@@ -286,5 +346,64 @@ return {
required: false,
default: false,
},
+ {
+ key: 'salt_secret',
+ type: 'string',
+ label: 'Distinct ID salt',
+ description:
+ 'High-entropy random secret (e.g. base64) mixed into hashed distinct IDs. Rotate to invalidate prior IDs. Used by rotating_salt, fixed_salt, and the rotating_salt_fallback path of custom; ignored by the ip strategy. If left blank, hashed strategies still produce stable IDs but lose the unguessability the salt provides — set one in production.',
+ secret: true,
+ required: false,
+ },
+ {
+ key: 'distinct_id_strategy',
+ 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.',
+ 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)) — stable until salt rotates',
+ },
+ {
+ value: 'ip',
+ label: 'Raw IP — stores client IPs unhashed as queryable distinct IDs',
+ },
+ {
+ value: 'custom',
+ label: 'Custom template — placeholder substitution (see template field)',
+ },
+ ],
+ default: 'rotating_salt',
+ secret: false,
+ required: true,
+ },
+ {
+ key: 'forward_ip_and_user_agent',
+ type: 'boolean',
+ label: 'Forward client IP and user agent',
+ description:
+ 'When enabled (default), $ip, $raw_user_agent, proxy_client_ip, and proxy_user_agent are emitted on each event so PostHog can run GeoIP and user-agent enrichment. Disable if you want raw client identifiers stripped — distinct_id derivation still uses them as inputs, but they will not appear on the emitted event.',
+ secret: false,
+ required: false,
+ default: true,
+ },
+ {
+ key: 'custom_template',
+ type: 'string',
+ label: 'Custom distinct ID template',
+ description:
+ 'Used only when strategy is "custom". Supports placeholders {day}, {ip}, {host}, {ua}, {path}, {project_id} (literal string substitution, not Hog evaluation; unknown placeholders are left as-is). The salt secret is intentionally not exposed as a placeholder. The result is prefixed with "http_log_". Empty value or all-empty substitutions fall back to rotating_salt.',
+ secret: false,
+ required: false,
+ // Templating disabled so {placeholder} braces are not interpreted as Hog
+ // expressions at the input layer. Substitution happens inside the Hog code.
+ templating: false,
+ },
],
}