: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 native User Agent Populator transformation (#93960)
Meikel Ratzf563820d10fc
diff --git a/nodejs/src/cdp/hog-transformations/transformation-functions.test.ts b/nodejs/src/cdp/hog-transformations/transformation-functions.test.tsnew file mode 100644index 000000000000..bb43d2146cb6--- /dev/null+++ b/nodejs/src/cdp/hog-transformations/transformation-functions.test.ts@@ -0,0 +1,56 @@+import { MAX_USER_AGENT_LENGTH, parseUserAgent } from './transformation-functions'++const CHROME_UA =+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'++describe('parseUserAgent', () => {+ it('parses a real user agent', () => {+ expect(parseUserAgent(CHROME_UA)).toEqual({+ browser: 'chrome',+ browserVersion: '120.0.0',+ os: 'Mac OS',+ browserType: 'browser',+ device: '',+ deviceType: 'Desktop',+ })+ })++ it.each([+ ['a non-string', 42],+ ['an empty string', ''],+ ])('returns null for %s', (_label, value) => {+ expect(parseUserAgent(value)).toBeNull()+ })++ it('returns null past the length bound without parsing', () => {+ // Repeated `Chrom` tokens are the adversarial shape: detect-browser backtracks+ // quadratically on them, so an unbounded value would stall the whole worker.+ const hostile = 'Chrom'.repeat((100 * 1024) / 5)++ const start = process.hrtime.bigint()+ expect(parseUserAgent(hostile)).toBeNull()+ const durationMs = Number(process.hrtime.bigint() - start) / 1e6++ // Generous next to the ~1800ms an unbounded parse of this value costs, but tight enough+ // to fail if the value ever reaches detect-browser again.+ expect(durationMs).toBeLessThan(100)+ })++ it('parses a hostile value at the accepted maximum length quickly', () => {+ // The adversarial `Chrom` pattern at exactly the accepted maximum still reaches+ // detect-browser, so the bound must be low enough that even this stays cheap.+ const hostileAtMax = 'Chrom'.repeat(Math.floor(MAX_USER_AGENT_LENGTH / 5))++ const start = process.hrtime.bigint()+ parseUserAgent(hostileAtMax)+ const durationMs = Number(process.hrtime.bigint() - start) / 1e6++ expect(durationMs).toBeLessThan(10)+ })++ it('still parses a user agent at the length bound', () => {+ const padded = CHROME_UA + ' '.repeat(MAX_USER_AGENT_LENGTH - CHROME_UA.length)++ expect(parseUserAgent(padded)?.browser).toBe('chrome')+ })+})diff --git a/nodejs/src/cdp/hog-transformations/transformation-functions.ts b/nodejs/src/cdp/hog-transformations/transformation-functions.tsindex 5ddc8e923d84..b8b72878d9bc 100644--- a/nodejs/src/cdp/hog-transformations/transformation-functions.ts+++ b/nodejs/src/cdp/hog-transformations/transformation-functions.ts@@ -1,3 +1,5 @@+import { detect } from 'detect-browser'+import { GeoIp } from '~/common/utils/geoip'import { KNOWN_BOT_IP_LIST, KNOWN_BOT_UA_LIST } from './bots/bots'@@ -55,6 +57,67 @@ export const isKnownBotIp = (ip: unknown): boolean => {return KNOWN_BOT_IP_LIST.includes(ipString)}+// Device detection regexes, ported from posthog-js.+const detectDevice = (userAgent: string): string => {+ if (/Windows Phone/i.test(userAgent) || /WPDesktop/.test(userAgent)) {+ return 'Windows Phone'+ } else if (/iPad/.test(userAgent)) {+ return 'iPad'+ } else if (/iPod/.test(userAgent)) {+ return 'iPod Touch'+ } else if (/iPhone/.test(userAgent)) {+ return 'iPhone'+ } else if (/(BlackBerry|PlayBook|BB10)/i.test(userAgent)) {+ return 'BlackBerry'+ } else if (/Android/.test(userAgent) && !/Mobile/.test(userAgent)) {+ return 'Android Tablet'+ } else if (/Android/.test(userAgent)) {+ return 'Android'+ }+ return ''+}++const detectDeviceType = (userAgent: string): string => {+ const device = detectDevice(userAgent)+ if (device === 'iPad' || device === 'Android Tablet') {+ return 'Tablet'+ } else if (device) {+ return 'Mobile'+ }+ return 'Desktop'+}++// detect-browser's chrome patterns backtrack quadratically on repeated `Chrom` tokens, and a host+// function is a single VM operation, so the hog timeout cannot interrupt one. Real user agents run a+// few hundred bytes, so bound the input tightly: the cost is quadratic in length, and at 1024 even+// the worst crafted value parses in well under a millisecond, rather than let it stall the worker.+export const MAX_USER_AGENT_LENGTH = 1024++export const parseUserAgent = (+ value: unknown+): {+ browser: string | null+ browserVersion: string | null+ os: string | null+ browserType: string | null+ device: string+ deviceType: string+} | null => {+ if (typeof value !== 'string' || value === '' || value.length > MAX_USER_AGENT_LENGTH) {+ return null+ }++ const agentInfo = detect(value)+ return {+ browser: agentInfo ? agentInfo.name : null,+ browserVersion: agentInfo ? agentInfo.version : null,+ os: agentInfo && 'os' in agentInfo ? agentInfo.os : null,+ browserType: agentInfo ? agentInfo.type : null,+ device: detectDevice(value),+ deviceType: detectDeviceType(value),+ }+}+export const getTransformationFunctions = (geoipLookup: GeoIp) => {return {geoipLookup: (val: unknown): any => {@@ -63,6 +126,7 @@ export const getTransformationFunctions = (geoipLookup: GeoIp) => {cleanNullValues,isKnownBotUserAgent,isKnownBotIp,+ parseUserAgent,postHogCapture: () => {throw new Error('posthogCapture is not supported in transformations')},diff --git a/nodejs/src/cdp/legacy-plugins/_transformations/user-agent-plugin/template.ts b/nodejs/src/cdp/legacy-plugins/_transformations/user-agent-plugin/template.tsindex a3994c84b248..3b39ac715e29 100644--- a/nodejs/src/cdp/legacy-plugins/_transformations/user-agent-plugin/template.ts+++ b/nodejs/src/cdp/legacy-plugins/_transformations/user-agent-plugin/template.ts@@ -7,7 +7,7 @@ export const userAgentPlugin: LegacyTransformationPlugin = {setupPlugin: setupPlugin as any,template: {free: true,- status: 'stable',+ status: 'deprecated',type: 'transformation',id: 'plugin-user-agent-plugin',name: 'User Agent Populator',diff --git a/nodejs/src/cdp/templates/_transformations/user-agent/user-agent.template.test.ts b/nodejs/src/cdp/templates/_transformations/user-agent/user-agent.template.test.tsnew file mode 100644index 000000000000..5353adceb780--- /dev/null+++ b/nodejs/src/cdp/templates/_transformations/user-agent/user-agent.template.test.ts@@ -0,0 +1,112 @@+import { HogFunctionInvocationGlobals } from '../../../types'+import { TemplateTester } from '../../test/test-helpers'+import { template } from './user-agent.template'++const CHROME_UA =+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'+const IPHONE_UA =+ 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1'++describe('user-agent.template', () => {+ const tester = new TemplateTester(template)++ beforeEach(async () => {+ await tester.beforeEach()+ })++ const invoke = async (inputs: Record<string, any>, globals: HogFunctionInvocationGlobals): Promise<any> => {+ const response = await tester.invoke(inputs, globals)+ expect(response.finished).toBe(true)+ expect(response.error).toBeUndefined()+ return response.execResult as any+ }++ it('populates browser and device properties from a desktop user agent', async () => {+ const globals = tester.createGlobals({ event: { properties: { $useragent: CHROME_UA } } })++ const result = await invoke({}, globals)++ expect(result.properties.$browser).toBe('chrome')+ expect(result.properties.$browser_version).toBe('120.0.0')+ expect(result.properties.$os).toBe('Mac OS')+ expect(result.properties.$browser_type).toBe('browser')+ expect(result.properties.$device).toBe('')+ expect(result.properties.$device_type).toBe('Desktop')+ // The raw user agent value is stripped once parsed.+ expect(result.properties.$useragent).toBeNull()+ })++ it('reads the Segment segment_userAgent property and strips it', async () => {+ const globals = tester.createGlobals({ event: { properties: { segment_userAgent: CHROME_UA } } })++ const result = await invoke({}, globals)++ expect(result.properties.$browser).toBe('chrome')+ expect(result.properties.segment_userAgent).toBeNull()+ })++ it('detects a mobile device and reads the $user-agent key', async () => {+ const globals = tester.createGlobals({ event: { properties: { '$user-agent': IPHONE_UA } } })++ const result = await invoke({}, globals)++ expect(result.properties.$device).toBe('iPhone')+ expect(result.properties.$device_type).toBe('Mobile')+ expect(result.properties.$os).toBe('iOS')+ })++ it('reads $raw_user_agent and leaves it in place', async () => {+ const globals = tester.createGlobals({ event: { properties: { $raw_user_agent: IPHONE_UA } } })++ const result = await invoke({}, globals)++ expect(result.properties.$device).toBe('iPhone')+ expect(result.properties.$device_type).toBe('Mobile')+ expect(result.properties.$os).toBe('iOS')+ // Bot detection and the ad destinations read this property after this transformation.+ expect(result.properties.$raw_user_agent).toBe(IPHONE_UA)+ })++ it('skips an empty alias and reads the next populated one', async () => {+ const globals = tester.createGlobals({+ event: { properties: { $useragent: '', $raw_user_agent: IPHONE_UA } },+ })++ const result = await invoke({}, globals)++ expect(result.properties.$device).toBe('iPhone')+ expect(result.properties.$os).toBe('iOS')+ })++ it('does not overwrite existing browser properties by default but still strips the raw user agent', async () => {+ const globals = tester.createGlobals({+ event: { properties: { $useragent: CHROME_UA, $browser: 'firefox' } },+ })++ const result = await invoke({}, globals)++ expect(result.properties.$browser).toBe('firefox')+ expect(result.properties.$useragent).toBeNull()+ })++ it('overwrites existing properties when overrideExisting is set', async () => {+ const globals = tester.createGlobals({+ event: { properties: { $useragent: CHROME_UA, $browser: 'firefox' } },+ })++ const result = await invoke({ overrideExisting: true }, globals)++ expect(result.properties.$browser).toBe('chrome')+ })++ it('sets no browser or device properties when there is no user agent', async () => {+ const globals = tester.createGlobals({ event: { properties: { unrelated: 'x' } } })++ const result = await invoke({}, globals)++ expect(result.properties.unrelated).toBe('x')+ expect(result.properties.$browser).toBeUndefined()+ expect(result.properties.$device).toBeUndefined()+ expect(result.properties.$device_type).toBeUndefined()+ })+})diff --git a/nodejs/src/cdp/templates/_transformations/user-agent/user-agent.template.ts b/nodejs/src/cdp/templates/_transformations/user-agent/user-agent.template.tsnew file mode 100644index 000000000000..fdbf87db9fb8--- /dev/null+++ b/nodejs/src/cdp/templates/_transformations/user-agent/user-agent.template.ts@@ -0,0 +1,93 @@+import { HogFunctionTemplate } from '~/cdp/types'++export const template: HogFunctionTemplate = {+ free: true,+ status: 'stable',+ type: 'transformation',+ id: 'template-user-agent',+ name: 'User Agent Populator',+ description:+ 'Reads the user agent from the event and sets $browser, $browser_version, $os, $device and $device_type from it.',+ icon_url: 'https://res.cloudinary.com/dmukukwp6/image/upload/q_auto,f_auto/builder_hog_01_955c082cad.png',+ category: ['Custom'],+ code_language: 'hog',+ code: `+if (empty(event.properties)) {+ return event+}++// $raw_user_agent is what capture and the Vercel source set. Read it after the aliases so an+// explicitly populated one still wins. Take the first candidate that holds a user agent rather+// than the first non-null one, so an empty alias does not hide a populated one behind it.+let candidates := [+ event.properties.$useragent,+ event.properties['$user-agent'],+ event.properties.$user_agent,+ event.properties.segment_userAgent,+ event.properties.$raw_user_agent+]+let ua := ''+for (let candidate in candidates) {+ if (empty(ua) and typeof(candidate) == 'string') {+ ua := candidate+ }+}+if (empty(ua)) {+ return event+}++let returnEvent := event++// Strip the raw user agent values now that we have read one. Done before any early return so the+// no-overwrite path also drops them. $raw_user_agent stays, because bot detection and the ad+// destinations read it after this transformation runs.+if (not empty(event.properties.$useragent)) {+ returnEvent.properties.$useragent := null+}+if (not empty(event.properties['$user-agent'])) {+ returnEvent.properties['$user-agent'] := null+}+if (not empty(event.properties.$user_agent)) {+ returnEvent.properties.$user_agent := null+}+if (not empty(event.properties.segment_userAgent)) {+ returnEvent.properties.segment_userAgent := null+}++// Do not overwrite browser or device properties the SDK already set, unless asked to.+let hasExisting := not empty(event.properties.$browser)+ or not empty(event.properties.$browser_version)+ or not empty(event.properties.$os)+ or not empty(event.properties.$device)+ or not empty(event.properties.$device_type)+if (hasExisting and not inputs.overrideExisting) {+ return returnEvent+}++let parsed := parseUserAgent(ua)+if (empty(parsed)) {+ return returnEvent+}++returnEvent.properties.$device := parsed.device+returnEvent.properties.$device_type := parsed.deviceType+if (not empty(parsed.browser)) {+ returnEvent.properties.$browser := parsed.browser+ returnEvent.properties.$browser_version := parsed.browserVersion+ returnEvent.properties.$os := parsed.os+ returnEvent.properties.$browser_type := parsed.browserType+}++return returnEvent+ `,+ inputs_schema: [+ {+ key: 'overrideExisting',+ type: 'boolean',+ label: 'Override existing properties',+ description: 'Replace $browser, $os and device properties even when the event already has them.',+ default: false,+ required: false,+ },+ ],+}diff --git a/nodejs/src/cdp/templates/index.ts b/nodejs/src/cdp/templates/index.tsindex 6dbdd4d03363..f01ac7ed8d4f 100644--- a/nodejs/src/cdp/templates/index.ts+++ b/nodejs/src/cdp/templates/index.ts@@ -64,6 +64,7 @@ import { template as timestampParserTemplate } from './_transformations/timestamimport { template as urlMaskingTemplate } from './_transformations/url-masking/url-masking.template'import { template as urlNormalizationTemplate } from './_transformations/url-normalization/url-normalization.template'import { template as urlParametersToPropertiesTemplate } from './_transformations/url-parameters-to-properties/url-parameters-to-properties.template'+import { template as userAgentTemplate } from './_transformations/user-agent/user-agent.template'import { template as logDefaultTemplate } from './_transformations_log/default/default.template'import { template as logDropBySeverityTemplate } from './_transformations_log/drop-by-severity/drop-by-severity.template'import { template as logPiiScrubTemplate } from './_transformations_log/pii-scrub/pii-scrub.template'@@ -132,6 +133,7 @@ export const HOG_FUNCTION_TEMPLATES_TRANSFORMATIONS: HogFunctionTemplate[] = [downsamplingTemplate,urlParametersToPropertiesTemplate,taxonomyTemplate,+ userAgentTemplate,]export const HOG_FUNCTION_TEMPLATES_TRANSFORMATIONS_LOG: HogFunctionTemplate[] = [diff --git a/nodejs/tests/fixtures/hog-bytecode/28f4338d165b7fa7132703de50e5deaf58853330c0ed66bd8320259eab5e1534.json b/nodejs/tests/fixtures/hog-bytecode/28f4338d165b7fa7132703de50e5deaf58853330c0ed66bd8320259eab5e1534.jsonnew file mode 100644index 000000000000..80cdf61945da--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/28f4338d165b7fa7132703de50e5deaf58853330c0ed66bd8320259eab5e1534.json@@ -0,0 +1 @@+["_H",1,32,"properties",32,"event",1,2,2,"empty",1,40,5,32,"event",1,1,38,32,"$useragent",32,"properties",32,"event",1,3,32,"properties",32,"event",1,2,32,"$user-agent",45,32,"$user_agent",32,"properties",32,"event",1,3,32,"$raw_user_agent",32,"properties",32,"event",1,3,43,4,32,"",36,0,36,2,2,"values",1,33,1,36,3,2,"length",1,31,36,5,36,4,16,40,37,36,3,36,4,45,37,6,36,1,2,"empty",1,32,"string",36,6,2,"typeof",1,11,3,2,40,4,36,6,37,1,36,4,33,1,6,37,4,39,-44,35,35,35,35,35,36,1,2,"empty",1,40,5,32,"event",1,1,38,32,"event",1,1,32,"$useragent",32,"properties",32,"event",1,3,2,"empty",1,5,40,9,36,2,32,"properties",45,32,"$useragent",31,46,32,"properties",32,"event",1,2,32,"$user-agent",45,2,"empty",1,5,40,9,36,2,32,"properties",45,32,"$user-agent",31,46,32,"$user_agent",32,"properties",32,"event",1,3,2,"empty",1,5,40,9,36,2,32,"properties",45,32,"$user_agent",31,46,32,"$browser",32,"properties",32,"event",1,3,2,"empty",1,5,32,"$browser_version",32,"properties",32,"event",1,3,2,"empty",1,5,32,"$os",32,"properties",32,"event",1,3,2,"empty",1,5,32,"$device",32,"properties",32,"event",1,3,2,"empty",1,5,32,"$device_type",32,"properties",32,"event",1,3,2,"empty",1,5,4,5,36,3,32,"overrideExisting",32,"inputs",1,2,5,3,2,40,3,36,2,38,36,1,2,"parseUserAgent",1,36,4,2,"empty",1,40,3,36,2,38,36,2,32,"properties",45,32,"$device",36,4,32,"device",45,46,36,2,32,"properties",45,32,"$device_type",36,4,32,"deviceType",45,46,36,4,32,"browser",45,2,"empty",1,5,40,52,36,2,32,"properties",45,32,"$browser",36,4,32,"browser",45,46,36,2,32,"properties",45,32,"$browser_version",36,4,32,"browserVersion",45,46,36,2,32,"properties",45,32,"$os",36,4,32,"os",45,46,36,2,32,"properties",45,32,"$browser_type",36,4,32,"browserType",45,46,36,2,38,35,35,35,35,35]diff --git a/nodejs/tests/fixtures/hog-bytecode/41f8a5c0aa19008e3daeedcb6769d4d8a29a0945f61b2b6d00ad21dcdc70b91e.json b/nodejs/tests/fixtures/hog-bytecode/41f8a5c0aa19008e3daeedcb6769d4d8a29a0945f61b2b6d00ad21dcdc70b91e.jsonnew file mode 100644index 000000000000..f607485dbcaa--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/41f8a5c0aa19008e3daeedcb6769d4d8a29a0945f61b2b6d00ad21dcdc70b91e.json@@ -0,0 +1 @@+["_H",1,32,"properties",32,"event",1,2,2,"empty",1,40,5,32,"event",1,1,38,32,"$useragent",32,"properties",32,"event",1,3,32,"properties",32,"event",1,2,32,"$user-agent",45,32,"$user_agent",32,"properties",32,"event",1,3,32,"segment_userAgent",32,"properties",32,"event",1,3,32,"$raw_user_agent",32,"properties",32,"event",1,3,43,5,32,"",36,0,36,2,2,"values",1,33,1,36,3,2,"length",1,31,36,5,36,4,16,40,37,36,3,36,4,45,37,6,36,1,2,"empty",1,32,"string",36,6,2,"typeof",1,11,3,2,40,4,36,6,37,1,36,4,33,1,6,37,4,39,-44,35,35,35,35,35,36,1,2,"empty",1,40,5,32,"event",1,1,38,32,"event",1,1,32,"$useragent",32,"properties",32,"event",1,3,2,"empty",1,5,40,9,36,2,32,"properties",45,32,"$useragent",31,46,32,"properties",32,"event",1,2,32,"$user-agent",45,2,"empty",1,5,40,9,36,2,32,"properties",45,32,"$user-agent",31,46,32,"$user_agent",32,"properties",32,"event",1,3,2,"empty",1,5,40,9,36,2,32,"properties",45,32,"$user_agent",31,46,32,"segment_userAgent",32,"properties",32,"event",1,3,2,"empty",1,5,40,9,36,2,32,"properties",45,32,"segment_userAgent",31,46,32,"$browser",32,"properties",32,"event",1,3,2,"empty",1,5,32,"$browser_version",32,"properties",32,"event",1,3,2,"empty",1,5,32,"$os",32,"properties",32,"event",1,3,2,"empty",1,5,32,"$device",32,"properties",32,"event",1,3,2,"empty",1,5,32,"$device_type",32,"properties",32,"event",1,3,2,"empty",1,5,4,5,36,3,32,"overrideExisting",32,"inputs",1,2,5,3,2,40,3,36,2,38,36,1,2,"parseUserAgent",1,36,4,2,"empty",1,40,3,36,2,38,36,2,32,"properties",45,32,"$device",36,4,32,"device",45,46,36,2,32,"properties",45,32,"$device_type",36,4,32,"deviceType",45,46,36,4,32,"browser",45,2,"empty",1,5,40,52,36,2,32,"properties",45,32,"$browser",36,4,32,"browser",45,46,36,2,32,"properties",45,32,"$browser_version",36,4,32,"browserVersion",45,46,36,2,32,"properties",45,32,"$os",36,4,32,"os",45,46,36,2,32,"properties",45,32,"$browser_type",36,4,32,"browserType",45,46,36,2,38,35,35,35,35,35]diff --git a/nodejs/tests/fixtures/hog-bytecode/fd10e1306a08c2083ff68f913ef422da9f9c5e3a85523dd349d2f5b286f334f4.json b/nodejs/tests/fixtures/hog-bytecode/fd10e1306a08c2083ff68f913ef422da9f9c5e3a85523dd349d2f5b286f334f4.jsonnew file mode 100644index 000000000000..9e7f08acbcaf--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/fd10e1306a08c2083ff68f913ef422da9f9c5e3a85523dd349d2f5b286f334f4.json@@ -0,0 +1 @@+["_H",1,32,"properties",32,"event",1,2,2,"empty",1,40,5,32,"event",1,1,38,32,"$useragent",32,"properties",32,"event",1,3,32,"properties",32,"event",1,2,32,"$user-agent",45,32,"$user_agent",32,"properties",32,"event",1,3,32,"$raw_user_agent",32,"properties",32,"event",1,3,43,4,32,"",36,0,36,2,2,"values",1,33,1,36,3,2,"length",1,31,36,5,36,4,16,40,37,36,3,36,4,45,37,6,36,1,2,"empty",1,32,"string",36,6,2,"typeof",1,11,3,2,40,4,36,6,37,1,36,4,33,1,6,37,4,39,-44,35,35,35,35,35,36,1,2,"empty",1,40,5,32,"event",1,1,38,32,"$browser",32,"properties",32,"event",1,3,2,"empty",1,5,32,"$browser_version",32,"properties",32,"event",1,3,2,"empty",1,5,32,"$os",32,"properties",32,"event",1,3,2,"empty",1,5,32,"$device",32,"properties",32,"event",1,3,2,"empty",1,5,32,"$device_type",32,"properties",32,"event",1,3,2,"empty",1,5,4,5,36,2,32,"overrideExisting",32,"inputs",1,2,5,3,2,40,5,32,"event",1,1,38,36,1,2,"parseUserAgent",1,36,3,2,"empty",1,40,5,32,"event",1,1,38,32,"event",1,1,36,4,32,"properties",45,32,"$device",36,3,32,"device",45,46,36,4,32,"properties",45,32,"$device_type",36,3,32,"deviceType",45,46,36,3,32,"browser",45,2,"empty",1,5,40,52,36,4,32,"properties",45,32,"$browser",36,3,32,"browser",45,46,36,4,32,"properties",45,32,"$browser_version",36,3,32,"browserVersion",45,46,36,4,32,"properties",45,32,"$os",36,3,32,"os",45,46,36,4,32,"properties",45,32,"$browser_type",36,3,32,"browserType",45,46,32,"$useragent",32,"properties",32,"event",1,3,2,"empty",1,5,40,9,36,4,32,"properties",45,32,"$useragent",31,46,32,"properties",32,"event",1,2,32,"$user-agent",45,2,"empty",1,5,40,9,36,4,32,"properties",45,32,"$user-agent",31,46,32,"$user_agent",32,"properties",32,"event",1,3,2,"empty",1,5,40,9,36,4,32,"properties",45,32,"$user_agent",31,46,36,4,38,35,35,35,35,35]diff --git a/posthog/cdp/test/test_validation.py b/posthog/cdp/test/test_validation.pyindex 436b8151e131..a23d8b4d4936 100644--- a/posthog/cdp/test/test_validation.py+++ b/posthog/cdp/test/test_validation.py@@ -768,15 +768,20 @@ class TestHogFunctionValidation(ClickhouseTestMixin, APIBaseTest, QueryMatchingTinputs_schema = [{"key": "ts", "type": "string", "required": True},{"key": "geo", "type": "string", "required": True},+ {"key": "ua", "type": "string", "required": True},]inputs = {"ts": {"value": "{now()}"},"geo": {"value": "{geoipLookup(event.properties.$ip)}"},+ # A bare reference is the only form that reaches the runtime-helper list; an+ # inline call resolves as a function and never hits the global check.+ "ua": {"value": "{parseUserAgent}"},}validated = validate_inputs(inputs_schema, inputs, function_type="transformation")assert validated["ts"]["bytecode"] is not Noneassert validated["geo"]["bytecode"] is not None+ assert validated["ua"]["bytecode"] is not Nonedef test_validate_inputs_with_secret_values(self):inputs_schema = [diff --git a/posthog/cdp/validation.py b/posthog/cdp/validation.pyindex b7e735597624..37c62b2657b4 100644--- a/posthog/cdp/validation.py+++ b/posthog/cdp/validation.py@@ -244,6 +244,7 @@ TRANSFORMATION_RUNTIME_FUNCTIONS = {"cleanNullValues","isKnownBotUserAgent","isKnownBotIp",+ "parseUserAgent",}