: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(taxonomy): show the Expo logo and expo.dev links on eas properties (#93026)
Rafael Audiberte8de356ac7c6
diff --git a/frontend/public/expo-icon.svg b/frontend/public/expo-icon.svgnew file mode 100644index 000000000000..d7aa0e8a6c6b--- /dev/null+++ b/frontend/public/expo-icon.svg@@ -0,0 +1 @@+<svg width="26" height="22" viewBox="0 0 26 22" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="m13.7431 0h-2.1422c-.9888 0-1.8954.528587-2.35103 1.37085l-9.079617 16.78415c-.2108052.3897-.2266421.8499-.043082 1.2521l.751794 1.6472c.467825 1.025 1.940765 1.1283 2.558855.1794l8.60688-13.21307c.1352-.20753.3723-.3336.6273-.3336s.4921.12607.6273.3336l8.6069 13.21307c.6181.9489 2.091.8456 2.5588-.1794l.7518-1.6472c.1836-.4022.1678-.8624-.0431-1.2521l-9.0796-16.78415c-.4556-.842263-1.3622-1.37085-2.351-1.37085z" fill="currentColor"/></svg>diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 761e07aca8c8..76677efba39a 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -1936,6 +1936,10 @@ snapshots:hash: v1.k794b7964.12a981fa531307f5626ec3f9d7d9046edd11d79dd22d8dbb370595d657cc9a79.uJAzNRT5kzK3ub5FJx9e9YHQ2HIVORKVKTd1mdYV4q4components-properties-table--dollar-properties-on-person-searchable--light:hash: v1.k794b7964.a0c006b3eda56bc41f468204d4b77048a867852cb6a790ee4de0116889acbc30.KIIpihbQAEELr_6HuzqELYKoj2E_mNjMx-yI83moUrI+ components-properties-table--external-source-properties--dark:+ hash: v1.k794b7964.d9499993dfe2442c1b68f965da058fad6de7787bf7541096b385415daae37e1e.5kYRRgshEBGgJvR3hLfKEvoYMIYdxKbUNyV2bYNmda8+ components-properties-table--external-source-properties--light:+ hash: v1.k794b7964.e534b6bef4cbc0e8e9907d16c7ec963140855393d6f559cbf079c3b0ca9f055c.CuckCNYfBxiWnbwmRoXUGGYklzhJ6sMW-bhAAK0PTJ4components-properties-timeline--multiple-points-for-one-person-property--dark:hash: v1.k794b7964.9d87655c5b097922a0e0d73bee5f973b55e419ea8f32ca0063487374e3fc327c._MYFJiI6LQqHpK0cjRYLLqi8MUPbIQXy5QaT8EKdIrEcomponents-properties-timeline--multiple-points-for-one-person-property--light:@@ -1949,9 +1953,9 @@ snapshots:components-properties-timeline--one-point-for-one-person-property--light:hash: v1.k794b7964.a29477c3a6b99e56dbcf85920941dccc1e356a9489bce4edf980b206aaeddbdc.yizWd9jqicjEo909JeMNAYOpwwZGVsnhUvIrmNV01LAcomponents-property-key-info--property-key-info--dark:- hash: v1.k794b7964.86233b37a6cc52075154629e5928f1275aee531631d9b24361eae0baa0b5b410.Q9aiFd3--I5oh5C9ZT0J5z4nUm4Odk93VqtpXWUYzRc+ hash: v1.k794b7964.82f943daab78e0ab3d3a6d838bbe9c49011cc48ea91495d890e2367a7f2fc6da.h4kJWFStw0iwpB8bcoJkUDjYgf2u1UHMYDbyuHQT5BIcomponents-property-key-info--property-key-info--light:- hash: v1.k794b7964.2f0245e1b92aba6695884bdf695034bf1efd85caca619940965a08338f15e41c.5Z7YHy2M9ko_15_blb0NaI7WmQeXytUWAntBAs03Qr0+ hash: v1.k794b7964.b2a63bf01a88350dc39810f9e5551723cf32b776f5a4787610273d403556bf60._sNqayX-2Yu2CR8xceX1RiePws_Jj5INB05XzWoyjsEcomponents-quill-date-filter--date-filter--dark:hash: v1.k794b7964.d2f042b099df421da94056b983d5566d502ac18a0d0e7c7002278ee7af9357a8.o4RyqSP9P5diOgMObTJW1Bf9lcVyxZhnzGqeNuuYE0Icomponents-quill-date-filter--date-filter--light:diff --git a/frontend/src/lib/components/PropertiesTable/PropertiesTable.stories.tsx b/frontend/src/lib/components/PropertiesTable/PropertiesTable.stories.tsxindex 69d651be71ab..1dc0bc119a3e 100644--- a/frontend/src/lib/components/PropertiesTable/PropertiesTable.stories.tsx+++ b/frontend/src/lib/components/PropertiesTable/PropertiesTable.stories.tsx@@ -34,6 +34,21 @@ export const Basic: Story = {},}+export const ExternalSourceProperties: Story = {+ render: () => {+ const properties = {+ 'eas/account': 'pineapple-labs',+ 'eas/build_id': '2f9a1c74-6f0b-4a4e-9a1e-8c2b7d5f0a31',+ 'eas/channel': 'production',+ 'eas/project_id': 'c81b3d02-77e4-4b6a-9f3e-1d0a5c8b2467',+ 'eas/runtime_version': '1.4.0',+ 'eas/update_id': '7d4e9b18-3c52-4f8a-b0d6-9e1f2a7c4b85',+ 'eas/workflow_id': 'a3c6f291-58d7-4e0b-8c4a-6b2d9f13e057',+ }+ return <PropertiesTableComponent type={PropertyDefinitionType.Event} properties={properties} />+ },+}+export const DollarPropertiesOnEvent: Story = {render: () => {const properties = {diff --git a/frontend/src/lib/components/PropertiesTable/PropertiesTable.test.tsx b/frontend/src/lib/components/PropertiesTable/PropertiesTable.test.tsxindex dda2469ed404..4478cdd8b005 100644--- a/frontend/src/lib/components/PropertiesTable/PropertiesTable.test.tsx+++ b/frontend/src/lib/components/PropertiesTable/PropertiesTable.test.tsx@@ -204,6 +204,35 @@ describe('PropertiesTable inline editor', () => {})})+ describe('values that link out', () => {+ const renderEditable = (key: string, value: string): HTMLElement =>+ render(+ <Provider>+ <PropertiesTable+ type={PropertyDefinitionType.Person}+ properties={{ [key]: value }}+ rootKey="$set"+ onEdit={jest.fn()}+ />+ </Provider>+ ).container++ it.each<[string, string, string | null]>([+ ['eas/build_id', 'a-build', 'https://expo.dev/builds/a-build'],+ ['eas/channel', 'production', null],+ ['homepage', 'https://example.com/x', 'https://example.com/x'],+ ])('%s = %s links to %s', (key, value, expected) => {+ const link = renderEditable(key, value).querySelector('a.value-link')+ expect(link?.getAttribute('href') ?? null).toBe(expected)+ })++ it('following the link does not start inline editing', () => {+ const container = renderEditable('eas/build_id', 'a-build')+ fireEvent.click(container.querySelector('a.value-link') as HTMLElement)+ expect(screen.queryByRole('textbox')).not.toBeInTheDocument()+ })+ })+describe('collapsible complex values', () => {const renderWith = (collapsible: boolean): ReturnType<typeof render> => {return render(diff --git a/frontend/src/lib/components/PropertiesTable/PropertiesTable.tsx b/frontend/src/lib/components/PropertiesTable/PropertiesTable.tsxindex f2ec22c0e4cb..5b67ab7790e0 100644--- a/frontend/src/lib/components/PropertiesTable/PropertiesTable.tsx+++ b/frontend/src/lib/components/PropertiesTable/PropertiesTable.tsx@@ -19,6 +19,7 @@ import { urls } from 'scenes/urls'import { propertyDefinitionsModel } from '~/models/propertyDefinitionsModel'import { getCoreFilterDefinition } from '~/taxonomy/helpers'+import { getPropertyValueUrl } from '~/taxonomy/propertySources'import {KNOWN_PROMOTED_PROPERTY_PARENTS,POSTHOG_EVENT_PROMOTED_PROPERTIES,@@ -109,6 +110,8 @@ function ValueDisplay({const valueString: string = value === null ? 'null' : String(value) // typeof null returns 'object' ¯\_(ツ)_/¯+ const externalUrl = getPropertyValueUrl(rootKey, value) ?? (isURL(value) ? String(value) : null)+const handleValueChange = (newValue: any): void => {setEditing(false)if (rootKey !== undefined && onEdit && newValue != value) {@@ -124,10 +127,17 @@ function ValueDisplay({)}onClick={() => canEdit && textBasedTypes.includes(valueType) && setEditing(true)}>- {!isURL(value) ? (+ {!externalUrl ? (<span>{valueString}</span>) : (- <Link to={value} target="_blank" className="value-link" targetBlankIcon>+ <Link+ to={externalUrl}+ target="_blank"+ className="value-link"+ targetBlankIcon+ // The cell around the value starts inline editing on click, so keep the two apart+ onClick={(e) => e.stopPropagation()}+ >{valueString}</Link>)}diff --git a/frontend/src/lib/components/Property.tsx b/frontend/src/lib/components/Property.tsxindex e379d22efe34..88ad238de2bd 100644--- a/frontend/src/lib/components/Property.tsx+++ b/frontend/src/lib/components/Property.tsx@@ -3,17 +3,27 @@ import { Link } from '@posthog/lemon-ui'import stringWithWBR from 'lib/utils/stringWithWBR'import { isExternalLink } from 'lib/utils/url'-export function Property({ value }: { value: any }): JSX.Element {+import { getPropertyValueUrl } from '~/taxonomy/propertySources'++export function Property({ value, propertyKey }: { value: any; propertyKey?: string }): JSX.Element {let valueString: stringlet valueComponent: JSX.Element | stringif (typeof value === 'object') {valueString = valueComponent = JSON.stringify(value)} else {- if (isExternalLink(value)) {- valueString = value+ const externalUrl = getPropertyValueUrl(propertyKey, value) ?? (isExternalLink(value) ? String(value) : null)+ if (externalUrl) {+ valueString = String(value)valueComponent = (<span className="line-clamp-3 whitespace-normal">- <Link to={valueString} target="_blank" className="value-link font-medium">+ <Link+ to={externalUrl}+ target="_blank"+ className="value-link font-medium"+ // The events table wraps the cell in a link that toggles a property filter,+ // and that link cancels the click. Keep the two apart.+ onClick={(e) => e.stopPropagation()}+ >{stringWithWBR(valueString, 20)}</Link></span>diff --git a/frontend/src/lib/components/PropertyKeyInfo.scss b/frontend/src/lib/components/PropertyKeyInfo.scssindex fa443c491e12..1b9c42bb48fd 100644--- a/frontend/src/lib/components/PropertyKeyInfo.scss+++ b/frontend/src/lib/components/PropertyKeyInfo.scss@@ -38,6 +38,19 @@background-size: cover;}+// Expo ship their mark as a single monochrome shape, so mask it with the current text color+// rather than shipping one asset per theme+.PropertyKeyInfo__logo--expo {+ display: inline-block;+ width: 1rem;+ height: 1rem;+ background-color: currentColor;+ mask-image: url('../../../public/expo-icon.svg');+ mask-repeat: no-repeat;+ mask-position: center;+ mask-size: contain;+}+.PropertyKeyInfo__overlay {padding: 0.25rem;color: var(--text-3000);diff --git a/frontend/src/lib/components/PropertyKeyInfo.stories.tsx b/frontend/src/lib/components/PropertyKeyInfo.stories.tsxindex 880fb5a54b7d..5e24a3de53c8 100644--- a/frontend/src/lib/components/PropertyKeyInfo.stories.tsx+++ b/frontend/src/lib/components/PropertyKeyInfo.stories.tsx@@ -21,6 +21,9 @@ const meta: Meta<PropertyKeyInfoProps> = {<div><PropertyKeyInfo {...args} value="langfuse trace" /></div>+ <div>+ <PropertyKeyInfo {...args} value="eas/build_id" />+ </div><div><PropertyKeyInfo {...args} value="$country" /></div>diff --git a/frontend/src/lib/components/PropertyKeyInfo.tsx b/frontend/src/lib/components/PropertyKeyInfo.tsxindex f18411fdc49e..381b842ecf0e 100644--- a/frontend/src/lib/components/PropertyKeyInfo.tsx+++ b/frontend/src/lib/components/PropertyKeyInfo.tsx@@ -12,17 +12,18 @@ import { pluralize } from 'lib/utils/strings'import { surveyQuestionLabelsLogic } from 'scenes/surveys/surveyQuestionLabelsLogic'import { PropertyKey, getCoreFilterDefinition } from '~/taxonomy/helpers'+import { PropertySourceId, getExternalPropertySource } from '~/taxonomy/propertySources'import { TaxonomicFilterGroupType } from './TaxonomicFilter/types'const SURVEY_RESPONSE_PREFIX = '$survey_response_'-function SourceLogo({ source }: { source: 'posthog' | 'langfuse' }): JSX.Element {+function SourceLogo({ source }: { source: PropertySourceId }): JSX.Element {if (source === 'posthog') {// The brand logomark handles light/dark itself (gradient mark in light, white mono in dark)return <Logomark className="PropertyKeyInfo__logo PropertyKeyInfo__logo--posthog" />}- return <span className="PropertyKeyInfo__logo PropertyKeyInfo__logo--langfuse" />+ return <span className={clsx('PropertyKeyInfo__logo', `PropertyKeyInfo__logo--${source}`)} />}export interface PropertyKeyInfoProps {@@ -57,8 +58,8 @@ const PropertyKeyInfoBase = React.forwardRef<HTMLSpanElement, PropertyKeyInfoProconst valueDisplayText = displayText || ((coreDefinition ? coreDefinition.label : value)?.trim() ?? '')const valueDisplayElement = valueDisplayText === '' ? <i>(empty string)</i> : valueDisplayText- const recognizedSource: 'posthog' | 'langfuse' | null =- coreDefinition || value.startsWith('$') ? 'posthog' : value.startsWith('langfuse ') ? 'langfuse' : null+ const recognizedSource: PropertySourceId | null =+ getExternalPropertySource(value)?.id ?? (coreDefinition || value.startsWith('$') ? 'posthog' : null)const innerContent = (<spandiff --git a/frontend/src/queries/nodes/DataTable/renderColumn.tsx b/frontend/src/queries/nodes/DataTable/renderColumn.tsxindex b80ac6ecd418..164c4988dd7f 100644--- a/frontend/src/queries/nodes/DataTable/renderColumn.tsx+++ b/frontend/src/queries/nodes/DataTable/renderColumn.tsx@@ -274,11 +274,11 @@ export function renderColumn(})}}>- <Property value={record.properties[propertyKey]} />+ <Property value={record.properties[propertyKey]} propertyKey={propertyKey} /></Link>)}- return <Property value={record.properties[propertyKey]} />+ return <Property value={record.properties[propertyKey]} propertyKey={propertyKey} />} else if (!Array.isArray(record) && key.startsWith('person.properties.')) {// TODO: remove after removing the old events tableconst eventRecord = record as EventType@@ -320,11 +320,11 @@ export function renderColumn(})}}>- <Property value={eventRecord.person?.properties?.[propertyKey]} />+ <Property value={eventRecord.person?.properties?.[propertyKey]} propertyKey={propertyKey} /></Link>)}- return <Property value={eventRecord.person?.properties?.[propertyKey]} />+ return <Property value={eventRecord.person?.properties?.[propertyKey]} propertyKey={propertyKey} />} else if (key === 'person') {const personRecord = record as PersonTypeconst displayProps: PersonDisplayProps = {diff --git a/frontend/src/taxonomy/propertySources.test.ts b/frontend/src/taxonomy/propertySources.test.tsnew file mode 100644index 000000000000..eed68e4987cf--- /dev/null+++ b/frontend/src/taxonomy/propertySources.test.ts@@ -0,0 +1,47 @@+import { getExternalPropertySource, getPropertyValueUrl } from './propertySources'++describe('propertySources', () => {+ test.each([+ ['eas/account', 'acme', 'https://expo.dev/accounts/acme'],+ ['eas/build_id', 'b1', 'https://expo.dev/builds/b1'],+ ['eas/project_id', 'p1', 'https://expo.dev/projects/p1'],+ ['eas/update_id', 'u1', 'https://expo.dev/updates/u1'],+ ['eas/workflow_id', 'w1', 'https://expo.dev/workflows/w1'],+ ])('links %s to its page on expo.dev', (key, value, expected) => {+ expect(getPropertyValueUrl(key, value)).toEqual(expected)+ })++ test.each([+ ['eas/channel', 'production'],+ ['eas/runtime_version', '1.0.0'],+ ['$current_url', 'https://example.com'],+ ['easy_mode', 'on'],+ ])('does not link %s', (key, value) => {+ expect(getPropertyValueUrl(key, value)).toBeNull()+ })++ test.each([+ ['a non-string value', 42],+ ['a blank value', ' '],+ ['a missing value', undefined],+ ])('does not link an Expo property with %s', (_, value) => {+ expect(getPropertyValueUrl('eas/build_id', value)).toBeNull()+ })++ it('escapes the value into the path', () => {+ expect(getPropertyValueUrl('eas/account', 'acme/../evil?x=1')).toEqual(+ 'https://expo.dev/accounts/acme%2F..%2Fevil%3Fx%3D1'+ )+ })++ test.each([+ ['eas/build_id', 'expo'],+ ['langfuse trace', 'langfuse'],+ ])('recognizes %s as coming from %s', (key, expected) => {+ expect(getExternalPropertySource(key)?.id).toEqual(expected)+ })++ test.each([['$current_url'], ['plan'], [null]])('recognizes no source for %s', (key) => {+ expect(getExternalPropertySource(key)).toBeNull()+ })+})diff --git a/frontend/src/taxonomy/propertySources.ts b/frontend/src/taxonomy/propertySources.tsnew file mode 100644index 000000000000..6577fcf1387c--- /dev/null+++ b/frontend/src/taxonomy/propertySources.ts@@ -0,0 +1,47 @@+import { PropertyKey } from './helpers'++export type ExternalPropertySourceId = 'langfuse' | 'expo'+export type PropertySourceId = 'posthog' | ExternalPropertySourceId++interface ExternalPropertySource {+ id: ExternalPropertySourceId+ /** Property keys starting with this were sent by this product. */+ prefix: string+ /** The page in the product's own app that the value points at, for the keys that identify something there. */+ valueUrl?: (key: string, value: string) => string | null+}++const EXPO_PAGE_BY_PROPERTY: Record<string, string> = {+ 'eas/account': 'accounts',+ 'eas/build_id': 'builds',+ 'eas/project_id': 'projects',+ 'eas/update_id': 'updates',+ 'eas/workflow_id': 'workflows',+}++const EXTERNAL_PROPERTY_SOURCES: ExternalPropertySource[] = [+ { id: 'langfuse', prefix: 'langfuse ' },+ {+ id: 'expo',+ prefix: 'eas/',+ valueUrl: (key, value) => {+ const page = EXPO_PAGE_BY_PROPERTY[key]+ return page ? `https://expo.dev/${page}/${encodeURIComponent(value)}` : null+ },+ },+]++/** The product that sent a property, for keys that carry a recognized namespace. */+export function getExternalPropertySource(key: PropertyKey): ExternalPropertySource | null {+ const name = key?.toString() ?? ''+ return EXTERNAL_PROPERTY_SOURCES.find(({ prefix }) => name.startsWith(prefix)) ?? null+}++/** Where a property value opens in the product that sent it, so people can jump straight to it. */+export function getPropertyValueUrl(key: PropertyKey, value: unknown): string | null {+ if (typeof value !== 'string' || !value.trim()) {+ return null+ }+ const name = key?.toString() ?? ''+ return getExternalPropertySource(name)?.valueUrl?.(name, value.trim()) ?? null+}