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(replay-vision): pin session properties on the observation page (#91181)

Kim Svatos Dugan3185a591b2bb
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index dccf4b17b355..c208c4080f93 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -8181,9 +8181,13 @@ snapshots:
scenes-app-project-homepage--project-homepage--light:
hash: v1.k794b7964.7c3fdb6ce7a31af8bd8ace431cfaadd663f8ffe276f49bf223e8bc638ecfa450.8_eynLhjWE_werwIrum7FChveeSzc4NQvUjA_X43guQ
scenes-app-replay-vision--observation-detail--dark:
- hash: v1.k794b7964.d3fbcea617e7a146ed9e9bac43c3dc05e6a4dceff23ae43777f2d3c3e6a1d8d6.li21N7hWkm5OeaU6HoRR0TXOUFynF6dJWT1kQwsLCpc
+ hash: v1.k794b7964.2fe170e544ea302e2e752a2b742f8dcf49710909f54cdc6c911b245fa9403391.POKP1RHFnlV8cfwSDsAsUOY76QdhwKfc4Xryvh1TPkI
scenes-app-replay-vision--observation-detail--light:
- hash: v1.k794b7964.6fa71e0981942176d54c6c3ae7a408f89a874ffe9f5bd9ebaa5eff0555109b74.Gl2gvSnNMXaaiSoqu5RJIQwa-fe5An65LGg_uh-7R-I
+ hash: v1.k794b7964.01a04970108058e482ffcd15e54a31480ce5c0a482c49e1912db97789a3c17e9.sPodqRrSOKwjS2bMBlK3yBQ79AY1Yh-WlJsY9Fqcu1M
+ scenes-app-replay-vision--observation-detail-monitor--dark:
+ hash: v1.k794b7964.d0fe843ea3b571a31f28472efd9f9908125c37dfca94a21b5603772e2acd5fc6.BmM6sQy3vpqNYC2sO29dYAeJ3vwDwE-moorC1s5tphE
+ scenes-app-replay-vision--observation-detail-monitor--light:
+ hash: v1.k794b7964.6c00a099a90ab21e583a36e214a6d68acd60f68e11bd489d9a0d4bb168effc3b.mS3DZfdS79PxSY9iLuXrAGW8EAYg00UptZg1_AQS9mo
scenes-app-replay-vision--scanner-alerts--dark:
hash: v1.k794b7964.c416988b5908944127a58d491bf68dceb3f1f9caf728b69185f372f11f2ab68c.aHRUHVbQvkxQzLEFJmWx1YUCfAPgMVcTyiAeuvNfUS4
scenes-app-replay-vision--scanner-alerts--light:
diff --git a/frontend/src/scenes/sessions/sessionProfileLogic.ts b/frontend/src/scenes/sessions/sessionProfileLogic.ts
index 1c1634249e5e..a685f9e139da 100644
--- a/frontend/src/scenes/sessions/sessionProfileLogic.ts
+++ b/frontend/src/scenes/sessions/sessionProfileLogic.ts
@@ -17,7 +17,7 @@ import { teamLogic } from '../teamLogic'
* We apply buffers in both directions to handle clock skew between the client
* (which generates the UUIDv7) and the server (which records event timestamps).
*/
-function getTimestampFromUUIDv7(sessionId: string): { startDate: Date; endDate: Date } {
+export function getTimestampFromUUIDv7(sessionId: string): { startDate: Date; endDate: Date } {
const uuidHex = sessionId.replace(/-/g, '')
const timestampMs = parseInt(uuidHex.substring(0, 12), 16)
// Generous buffers for partition pruning while we wait for sessions v3
diff --git a/products/replay_vision/frontend/components/CardHeader.tsx b/products/replay_vision/frontend/components/CardHeader.tsx
index 1fa1ad4c6207..8b687f906620 100644
--- a/products/replay_vision/frontend/components/CardHeader.tsx
+++ b/products/replay_vision/frontend/components/CardHeader.tsx
@@ -1,9 +1,18 @@
/** Card header — a muted icon plus title, shared across Replay vision config and observation cards. */
-export function CardHeader({ icon, title }: { icon: JSX.Element; title: string }): JSX.Element {
+export function CardHeader({
+ icon,
+ title,
+ actions,
+}: {
+ icon: JSX.Element
+ title: string
+ actions?: React.ReactNode
+}): JSX.Element {
return (
<div className="flex items-center gap-2 mb-3">
<span className="text-muted text-base flex">{icon}</span>
<span className="text-sm font-medium">{title}</span>
+ {actions && <div className="ml-auto flex items-center gap-1">{actions}</div>}
</div>
)
}
diff --git a/products/replay_vision/frontend/observations/ObservationPinnedProperties.tsx b/products/replay_vision/frontend/observations/ObservationPinnedProperties.tsx
new file mode 100644
index 000000000000..0f40ddf57ddc
--- /dev/null
+++ b/products/replay_vision/frontend/observations/ObservationPinnedProperties.tsx
@@ -0,0 +1,118 @@
+import { useActions, useValues } from 'kea'
+import { useState } from 'react'
+
+import { IconPin } from '@posthog/icons'
+import { LemonButton, LemonCard, LemonSkeleton, Link, Tooltip } from '@posthog/lemon-ui'
+
+import { CopyToClipboardInline } from 'lib/components/CopyToClipboard'
+import { PropertyIcon } from 'lib/components/PropertyIcon/PropertyIcon'
+import { Popover } from 'lib/lemon-ui/Popover'
+
+import { getCoreFilterDefinition } from '~/taxonomy/helpers'
+
+import { CardHeader } from '../components/CardHeader'
+import { LabeledRow } from '../components/LabeledRow'
+import {
+ PINNED_PROPERTY_GROUPS,
+ PinnedProperty,
+ observationPinnedPropertiesLogic,
+} from './observationPinnedPropertiesLogic'
+import { ObservationPinnedPropertiesPicker } from './ObservationPinnedPropertiesPicker'
+import { observationSessionPropertiesLogic, pinnedPropertyId } from './observationSessionPropertiesLogic'
+
+function propertyLabel(property: PinnedProperty): string {
+ return getCoreFilterDefinition(property.key, PINNED_PROPERTY_GROUPS[property.type])?.label ?? property.key
+}
+
+function PinnedPropertyValue({ property, value }: { property: PinnedProperty; value: string | null }): JSX.Element {
+ if (!value) {
+ return <span className="text-muted">—</span>
+ }
+ const isUrl = value.startsWith('http://') || value.startsWith('https://')
+ return (
+ <Tooltip title={value}>
+ <span className="flex items-center gap-1 min-w-0">
+ <PropertyIcon property={property.key} value={value} />
+ {isUrl ? (
+ <Link to={value} target="_blank" className="truncate">
+ {value}
+ </Link>
+ ) : (
+ <CopyToClipboardInline
+ explicitValue={value}
+ description={propertyLabel(property)}
+ iconSize="xsmall"
+ className="min-w-0"
+ >
+ <span className="truncate">{value}</span>
+ </CopyToClipboardInline>
+ )}
+ </span>
+ </Tooltip>
+ )
+}
+
+/**
+ * A fixed strip of properties for the observed session. It sits in the same place on every
+ * observation so paging through a scanner's results with prev/next reads as a comparison.
+ */
+export function ObservationPinnedProperties({ sessionId }: { sessionId: string }): JSX.Element {
+ const [pickerOpen, setPickerOpen] = useState(false)
+ const { pinnedProperties, queryablePinnedProperties } = useValues(observationPinnedPropertiesLogic)
+ const { resetPinnedProperties } = useActions(observationPinnedPropertiesLogic)
+ const { sessionProperties, sessionPropertiesLoading } = useValues(observationSessionPropertiesLogic({ sessionId }))
+
+ return (
+ <LemonCard className="p-4" hoverEffect={false}>
+ <CardHeader
+ icon={<IconPin />}
+ title="Pinned properties"
+ actions={
+ <Popover
+ visible={pickerOpen}
+ onClickOutside={() => setPickerOpen(false)}
+ overlay={<ObservationPinnedPropertiesPicker />}
+ placement="bottom-end"
+ >
+ <LemonButton
+ size="xsmall"
+ type="secondary"
+ onClick={() => setPickerOpen(!pickerOpen)}
+ data-attr="vision-observation-pin-properties"
+ >
+ Edit pinned properties
+ </LemonButton>
+ </Popover>
+ }
+ />
+ {pinnedProperties.length === 0 ? (
+ <p className="text-sm text-muted m-0">
+ Pin the properties you compare across results, like the referring domain, the campaign source, or
+ the person's plan.
+ </p>
+ ) : queryablePinnedProperties.length === 0 ? (
+ <p className="text-sm text-muted m-0">
+ None of the pinned session properties exist in this project.{' '}
+ <Link onClick={resetPinnedProperties}>Reset to the defaults</Link>.
+ </p>
+ ) : sessionPropertiesLoading ? (
+ <LemonSkeleton.Row repeat={2} className="h-5" />
+ ) : (
+ <div className="@container/pinned">
+ <div className="grid grid-cols-1 gap-x-6 gap-y-3 @md/pinned:grid-cols-2 @3xl/pinned:grid-cols-4">
+ {queryablePinnedProperties.map((property) => (
+ <div key={pinnedPropertyId(property)} className="min-w-0">
+ <LabeledRow label={propertyLabel(property)}>
+ <PinnedPropertyValue
+ property={property}
+ value={sessionProperties?.[pinnedPropertyId(property)] ?? null}
+ />
+ </LabeledRow>
+ </div>
+ ))}
+ </div>
+ </div>
+ )}
+ </LemonCard>
+ )
+}
diff --git a/products/replay_vision/frontend/observations/ObservationPinnedPropertiesPicker.tsx b/products/replay_vision/frontend/observations/ObservationPinnedPropertiesPicker.tsx
new file mode 100644
index 000000000000..91bee8b7f124
--- /dev/null
+++ b/products/replay_vision/frontend/observations/ObservationPinnedPropertiesPicker.tsx
@@ -0,0 +1,69 @@
+import { useActions, useValues } from 'kea'
+
+import { IconPinFilled } from '@posthog/icons'
+import { LemonButton } from '@posthog/lemon-ui'
+
+import { TaxonomicFilter } from 'lib/components/TaxonomicFilter/TaxonomicFilter'
+import { SelectedProperties, TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
+
+import {
+ MAX_PINNED_PROPERTIES,
+ PINNED_PROPERTY_GROUPS,
+ observationPinnedPropertiesLogic,
+ pinnedPropertyTypeForGroup,
+} from './observationPinnedPropertiesLogic'
+
+const PICKER_GROUPS = [
+ TaxonomicFilterGroupType.SessionProperties,
+ TaxonomicFilterGroupType.EventProperties,
+ TaxonomicFilterGroupType.PersonProperties,
+]
+
+/** The popover contents behind the pinned-properties gear on the observation page. */
+export function ObservationPinnedPropertiesPicker(): JSX.Element {
+ const { pinnedProperties } = useValues(observationPinnedPropertiesLogic)
+ const { togglePropertyPin, resetPinnedProperties } = useActions(observationPinnedPropertiesLogic)
+ const atLimit = pinnedProperties.length >= MAX_PINNED_PROPERTIES
+
+ // Each group only marks its own pins, so the same key pinned as an event property doesn't
+ // read as pinned under person properties too.
+ const selectedProperties = Object.fromEntries(
+ Object.entries(PINNED_PROPERTY_GROUPS).map(([type, group]) => [
+ group,
+ pinnedProperties.filter((property) => property.type === type).map((property) => property.key),
+ ])
+ ) as SelectedProperties
+
+ return (
+ <div>
+ <div className="flex items-center gap-2 px-3 py-2 border-b">
+ <IconPinFilled className="text-muted" />
+ <span className="text-sm font-semibold">Pinned properties</span>
+ <LemonButton size="xsmall" type="tertiary" className="ml-auto" onClick={resetPinnedProperties}>
+ Reset
+ </LemonButton>
+ </div>
+ {atLimit && (
+ <p className="text-xs text-muted m-0 px-3 py-2">
+ Unpin one to add another. {MAX_PINNED_PROPERTIES} is the most that stays scannable.
+ </p>
+ )}
+ <TaxonomicFilter
+ taxonomicFilterLogicKey="replay-vision-pinned-properties"
+ taxonomicGroupTypes={PICKER_GROUPS}
+ selectedProperties={selectedProperties}
+ onChange={(group, propertyKey) => {
+ const type = pinnedPropertyTypeForGroup(group.type)
+ if (!type) {
+ return
+ }
+ const key = String(propertyKey)
+ const isPinned = pinnedProperties.some((property) => property.key === key && property.type === type)
+ if (!atLimit || isPinned) {
+ togglePropertyPin(key, type)
+ }
+ }}
+ />
+ </div>
+ )
+}
diff --git a/products/replay_vision/frontend/observations/ReplayObservation.tsx b/products/replay_vision/frontend/observations/ReplayObservation.tsx
index 3cb7d4fde4e9..d88ffaf088ee 100644
--- a/products/replay_vision/frontend/observations/ReplayObservation.tsx
+++ b/products/replay_vision/frontend/observations/ReplayObservation.tsx
@@ -68,6 +68,7 @@ import {
} from '../replay_scanners/types'
import { scannerLabel } from '../utils/observation'
import { ObservationLabelControl } from './ObservationLabelControl'
+import { ObservationPinnedProperties } from './ObservationPinnedProperties'
import { neighborFilterParams, observationDetailUrl, replayObservationLogic } from './replayObservationLogic'
import { replayObservationSceneLogic } from './replayObservationSceneLogic'
@@ -465,6 +466,8 @@ export function ReplayObservationSceneComponent(): JSX.Element {
)}
</div>
+ <ObservationPinnedProperties sessionId={observation.session_id} />
+
<div className="grid grid-cols-1 lg:grid-cols-3 gap-4">
<LemonCard className="p-4" hoverEffect={false}>
<CardHeader icon={<IconInfo />} title="Observation details" />
diff --git a/products/replay_vision/frontend/observations/observationPinnedPropertiesLogic.test.ts b/products/replay_vision/frontend/observations/observationPinnedPropertiesLogic.test.ts
new file mode 100644
index 000000000000..e677dca0fcea
--- /dev/null
+++ b/products/replay_vision/frontend/observations/observationPinnedPropertiesLogic.test.ts
@@ -0,0 +1,73 @@
+import { initKeaTests } from '~/test/init'
+
+import {
+ DEFAULT_PINNED_PROPERTIES,
+ MAX_PINNED_PROPERTIES,
+ PinnedProperty,
+ observationPinnedPropertiesLogic,
+} from './observationPinnedPropertiesLogic'
+
+describe('observationPinnedPropertiesLogic', () => {
+ let logic: ReturnType<typeof observationPinnedPropertiesLogic.build>
+
+ beforeEach(() => {
+ initKeaTests()
+ logic = observationPinnedPropertiesLogic()
+ logic.mount()
+ logic.actions.setPinnedProperties(DEFAULT_PINNED_PROPERTIES)
+ })
+
+ afterEach(() => {
+ logic?.unmount()
+ })
+
+ it('drops session pins the sessions table has no column for', () => {
+ // The sessions table has a fixed schema, so one bad column fails the query and blanks every
+ // other pinned value. Event and person bags read back null instead, so they stay.
+ logic.actions.setPinnedProperties([
+ { key: '$entry_utm_source', type: 'session' },
+ { key: 'made_up_property', type: 'session' },
+ { key: 'made_up_property', type: 'event' },
+ { key: 'plan', type: 'person' },
+ ])
+
+ expect(logic.values.queryablePinnedProperties).toEqual([
+ { key: '$entry_utm_source', type: 'session' },
+ { key: 'made_up_property', type: 'event' },
+ { key: 'plan', type: 'person' },
+ ])
+ })
+
+ it('treats the same key in two namespaces as two separate pins', () => {
+ // $browser exists as both an event property and a person property, so unpinning one must
+ // not silently remove the other.
+ logic.actions.setPinnedProperties([])
+ logic.actions.togglePropertyPin('$browser', 'event')
+ logic.actions.togglePropertyPin('$browser', 'person')
+ expect(logic.values.pinnedProperties).toHaveLength(2)
+
+ logic.actions.togglePropertyPin('$browser', 'event')
+ expect(logic.values.pinnedProperties).toEqual([{ key: '$browser', type: 'person' }])
+ })
+
+ it('toggles a pin on and back off', () => {
+ logic.actions.setPinnedProperties([])
+
+ logic.actions.togglePropertyPin('$entry_utm_medium', 'session')
+ expect(logic.values.pinnedProperties).toEqual([{ key: '$entry_utm_medium', type: 'session' }])
+
+ logic.actions.togglePropertyPin('$entry_utm_medium', 'session')
+ expect(logic.values.pinnedProperties).toEqual([])
+ })
+
+ it('caps how many properties can be pinned', () => {
+ const tooMany: PinnedProperty[] = Array.from({ length: MAX_PINNED_PROPERTIES + 3 }, (_, index) => ({
+ key: `property_${index}`,
+ type: 'event',
+ }))
+
+ logic.actions.setPinnedProperties(tooMany)
+
+ expect(logic.values.pinnedProperties).toEqual(tooMany.slice(0, MAX_PINNED_PROPERTIES))
+ })
+})
diff --git a/products/replay_vision/frontend/observations/observationPinnedPropertiesLogic.ts b/products/replay_vision/frontend/observations/observationPinnedPropertiesLogic.ts
new file mode 100644
index 000000000000..2f742cd1c79e
--- /dev/null
+++ b/products/replay_vision/frontend/observations/observationPinnedPropertiesLogic.ts
@@ -0,0 +1,121 @@
+import { MakeLogicType, actions, kea, listeners, path, reducers, selectors } from 'kea'
+
+import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
+
+import { CORE_FILTER_DEFINITIONS_BY_GROUP } from '~/taxonomy/taxonomy'
+
+/** Which namespace a pin is read from. The three the observed session can answer. */
+export type PinnedPropertyType = 'session' | 'event' | 'person'
+
+export interface PinnedProperty {
+ key: string
+ type: PinnedPropertyType
+}
+
+export const PINNED_PROPERTY_GROUPS: Record<PinnedPropertyType, TaxonomicFilterGroupType> = {
+ session: TaxonomicFilterGroupType.SessionProperties,
+ event: TaxonomicFilterGroupType.EventProperties,
+ person: TaxonomicFilterGroupType.PersonProperties,
+}
+
+export function pinnedPropertyTypeForGroup(group: TaxonomicFilterGroupType): PinnedPropertyType | null {
+ const entry = Object.entries(PINNED_PROPERTY_GROUPS).find(([, groupType]) => groupType === group)
+ return entry ? (entry[0] as PinnedPropertyType) : null
+}
+
+/** Where the session came from leads, then who it was. That is the order these get compared in. */
+export const DEFAULT_PINNED_PROPERTIES: PinnedProperty[] = [
+ { key: '$entry_referring_domain', type: 'session' },
+ { key: '$channel_type', type: 'session' },
+ { key: '$entry_utm_source', type: 'session' },
+ { key: '$geoip_country_code', type: 'event' },
+]
+
+/** Past this the strip stops being scannable, which is the only thing it is for. */
+export const MAX_PINNED_PROPERTIES = 8
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface observationPinnedPropertiesLogicValues {
+ pinnedProperties: PinnedProperty[]
+ queryablePinnedProperties: PinnedProperty[]
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface observationPinnedPropertiesLogicActions {
+ resetPinnedProperties: () => {}
+ setPinnedProperties: (properties: PinnedProperty[]) => {
+ properties: PinnedProperty[]
+ }
+ togglePropertyPin: (
+ key: string,
+ type: PinnedPropertyType
+ ) => {
+ key: string
+ type: PinnedPropertyType
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface observationPinnedPropertiesLogicMeta {
+ __keaTypeGenInternalSelectorTypes: {
+ queryablePinnedProperties: (pinnedProperties: PinnedProperty[]) => PinnedProperty[]
+ }
+}
+
+export type observationPinnedPropertiesLogicType = MakeLogicType<
+ observationPinnedPropertiesLogicValues,
+ observationPinnedPropertiesLogicActions,
+ Record<string, any>,
+ observationPinnedPropertiesLogicMeta
+>
+
+/**
+ * Which properties the observation page shows in its pinned strip. Browser-local, so the picks
+ * follow one person across scanners rather than being scoped to a scanner or shared with the team.
+ */
+export const observationPinnedPropertiesLogic = kea<observationPinnedPropertiesLogicType>([
+ path(['products', 'replay_vision', 'frontend', 'observations', 'observationPinnedPropertiesLogic']),
+
+ actions({
+ setPinnedProperties: (properties: PinnedProperty[]) => ({ properties }),
+ togglePropertyPin: (key: string, type: PinnedPropertyType) => ({ key, type }),
+ resetPinnedProperties: () => ({}),
+ }),
+
+ reducers({
+ pinnedProperties: [
+ DEFAULT_PINNED_PROPERTIES,
+ { persist: true },
+ {
+ setPinnedProperties: (_, { properties }) => properties.slice(0, MAX_PINNED_PROPERTIES),
+ resetPinnedProperties: () => DEFAULT_PINNED_PROPERTIES,
+ },
+ ],
+ }),
+
+ selectors({
+ queryablePinnedProperties: [
+ (s) => [s.pinnedProperties],
+ (pinnedProperties: PinnedProperty[]): PinnedProperty[] =>
+ // The sessions table has a fixed schema, so an unknown column fails the whole query and
+ // blanks every other pin with it. Event and person bags just read back null.
+ pinnedProperties.filter(
+ (property) =>
+ property.type !== 'session' ||
+ Object.hasOwn(CORE_FILTER_DEFINITIONS_BY_GROUP.session_properties, property.key)
+ ),
+ ],
+ }),
+
+ listeners(({ actions, values }) => ({
+ togglePropertyPin: ({ key, type }) => {
+ const pinned = values.pinnedProperties
+ const isPinned = pinned.some((property) => property.key === key && property.type === type)
+ actions.setPinnedProperties(
+ isPinned
+ ? pinned.filter((property) => !(property.key === key && property.type === type))
+ : [...pinned, { key, type }]
+ )
+ },
+ })),
+])
diff --git a/products/replay_vision/frontend/observations/observationSessionPropertiesLogic.ts b/products/replay_vision/frontend/observations/observationSessionPropertiesLogic.ts
new file mode 100644
index 000000000000..6e574de30051
--- /dev/null
+++ b/products/replay_vision/frontend/observations/observationSessionPropertiesLogic.ts
@@ -0,0 +1,150 @@
+import { MakeLogicType, afterMount, connect, kea, key, listeners, path, props } from 'kea'
+import { loaders } from 'kea-loaders'
+import posthog from 'posthog-js'
+
+import api from 'lib/api'
+import { getTimestampFromUUIDv7 } from 'scenes/sessions/sessionProfileLogic'
+
+import { QueryLogTags } from '~/queries/schema/schema-general'
+import { HogQLQueryString, escapePropertyAsHogQLIdentifier, hogql } from '~/queries/utils'
+
+import { PinnedProperty, observationPinnedPropertiesLogic } from './observationPinnedPropertiesLogic'
+
+const QUERY_TAGS: QueryLogTags = { scene: 'ReplayVisionObservation', productKey: 'replay_vision' }
+
+export interface ObservationSessionPropertiesLogicProps {
+ sessionId: string
+}
+
+/** Identifies a pin in the response map, since the same key can be pinned from two namespaces. */
+export function pinnedPropertyId(property: PinnedProperty): string {
+ return `${property.type}:${property.key}`
+}
+
+function selectExpression(property: PinnedProperty): string {
+ const identifier = escapePropertyAsHogQLIdentifier(property.key)
+ if (property.type === 'session') {
+ return `session.${identifier}`
+ }
+ if (property.type === 'person') {
+ return `person.properties.${identifier}`
+ }
+ return `properties.${identifier}`
+}
+
+function buildQuery(sessionId: string, properties: PinnedProperty[]): HogQLQueryString {
+ // Positional aliases, because the same key can be pinned from two namespaces and would collide.
+ const selects = properties
+ .map((property, index) => `any(${selectExpression(property)}) as pinned_${index}`)
+ .join(', ')
+ const { startDate, endDate } = getTimestampFromUUIDv7(sessionId)
+ return hogql`
+ SELECT ${hogql.raw(selects)}
+ FROM events
+ WHERE $session_id = ${sessionId}
+ AND timestamp >= toDateTime(${startDate.toISOString()})
+ AND timestamp <= toDateTime(${endDate.toISOString()})`
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface observationSessionPropertiesLogicValues {
+ queryablePinnedProperties: PinnedProperty[] // observationPinnedPropertiesLogic
+ sessionProperties: Record<string, string | null> | null
+ sessionPropertiesLoading: boolean
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface observationSessionPropertiesLogicActions {
+ setPinnedProperties: (properties: PinnedProperty[]) => {
+ properties: PinnedProperty[]
+ } // observationPinnedPropertiesLogic
+ loadSessionProperties: (_: any) => any
+ loadSessionPropertiesFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadSessionPropertiesSuccess: (
+ sessionProperties: {
+ [k: string]: any
+ } | null,
+ payload?: any
+ ) => {
+ sessionProperties: {
+ [k: string]: any
+ } | null
+ payload?: any
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface observationSessionPropertiesLogicMeta {
+ key: string
+}
+
+export type observationSessionPropertiesLogicType = MakeLogicType<
+ observationSessionPropertiesLogicValues,
+ observationSessionPropertiesLogicActions,
+ ObservationSessionPropertiesLogicProps,
+ observationSessionPropertiesLogicMeta
+>
+
+/**
+ * Reads the pinned properties for one observed session. One pass over the session's events serves
+ * all three namespaces: session columns, event property bags, and the person behind the session.
+ */
+export const observationSessionPropertiesLogic = kea<observationSessionPropertiesLogicType>([
+ path(['products', 'replay_vision', 'frontend', 'observations', 'observationSessionPropertiesLogic']),
+ props({} as ObservationSessionPropertiesLogicProps),
+ key((props) => props.sessionId),
+
+ connect(() => ({
+ values: [observationPinnedPropertiesLogic, ['queryablePinnedProperties']],
+ actions: [observationPinnedPropertiesLogic, ['setPinnedProperties']],
+ })),
+
+ loaders(({ props, values }) => ({
+ sessionProperties: [
+ null as Record<string, string | null> | null,
+ {
+ loadSessionProperties: async (_, breakpoint) => {
+ const properties = values.queryablePinnedProperties
+ if (!props.sessionId || !properties.length) {
+ return null
+ }
+ await breakpoint(100)
+
+ let response
+ try {
+ response = await api.queryHogQL(buildQuery(props.sessionId, properties), QUERY_TAGS)
+ } catch (e) {
+ // This strip is supplementary context. A failed read should leave it empty, not toast over the result.
+ posthog.captureException(e)
+ return null
+ }
+ breakpoint()
+
+ const row = response.results?.[0]
+ if (!row) {
+ return null
+ }
+ return Object.fromEntries(
+ // An event carrying the key with an empty value reads the same as never carrying it.
+ properties.map((property, index) => [pinnedPropertyId(property), row[index] || null])
+ )
+ },
+ },
+ ],
+ })),
+
+ listeners(({ actions }) => ({
+ // A newly pinned property isn't in the last response, so the row has to be read again.
+ setPinnedProperties: () => actions.loadSessionProperties(null),
+ })),
+
+ afterMount(({ actions }) => {
+ actions.loadSessionProperties(null)
+ }),
+])
diff --git a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx
index bcc25ce6a5cb..a4f353dcd3ec 100644
--- a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx
+++ b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx
@@ -298,6 +298,43 @@ const observationDetail = observation({
},
})
+// A monitor observation, so the detail page renders the prompt row and the reasoning card that a
+// summarizer hides. The prompt is long on purpose: it is what the collapsed row has to clamp.
+const monitorObservationDetail = observation({
+ id: '00000000-0000-0000-0000-0000000000d2',
+ session_id: '01966b3f-70a1-7c52-a4d5-3f9b2e8c1d11',
+ recording_subject_email: '[email protected]',
+ distinct_id: 'user_2m1x9d',
+ previous_observation_id: '00000000-0000-0000-0000-0000000000b1',
+ next_observation_id: '00000000-0000-0000-0000-0000000000b4',
+ scanner_snapshot: {
+ name: 'Confused checkout',
+ scanner_type: 'monitor',
+ scanner_version: 3,
+ model: 'gemini-3.7-flash',
+ provider: 'google',
+ emits_signals: true,
+ scanner_config: {
+ prompt: 'Did the user struggle at checkout? Count it as struggling if they retried a coupon code more than once, resubmitted the payment form after an error, or moved back and forth between the cart and the payment step without completing the order. Ignore sessions that never reached the checkout page at all.',
+ allow_inconclusive: true,
+ },
+ },
+ scanner_result: {
+ model_output: {
+ scanner_type: 'monitor',
+ confidence: 0.82,
+ verdict: 'yes',
+ reasoning:
+ 'The user entered a coupon code three times, each time getting a validation error, then switched to the payment form and submitted it twice before leaving the page. That is a retry loop at checkout rather than ordinary browsing.',
+ },
+ signals_count: 1,
+ },
+})
+
+// The pinned strip's default pins, in order: three session columns then a geo event property.
+// The values are invented.
+const sessionPropertiesRow = ['google.com', 'Paid Search', 'google', 'US']
+
const promptSuggestion: ReplayScannerPromptSuggestionApi = {
id: '00000000-0000-0000-0000-0000000000e1',
status: 'pending',
@@ -379,6 +416,13 @@ const observationsTrend = {
],
}
+const paginated = (names: string[]): Record<string, any> => ({
+ count: names.length,
+ next: null,
+ previous: null,
+ results: names.map((name) => ({ id: name, name, property_type: 'String' })),
+})
+
const meta: Meta = {
component: App,
title: 'Scenes-App/Replay Vision',
@@ -420,9 +464,28 @@ const meta: Meta = {
'/api/projects/:team_id/signals/scout/metadata/current/': {},
'/api/projects/:team_id/vision/scanners/:scannerId/scout_reports/': [],
'/api/projects/:team_id/vision/alerts/': { count: 0, next: null, previous: null, results: [] },
+ // The three namespaces the pinned-properties picker offers.
+ '/api/environments/:team_id/sessions/property_definitions/': paginated([
+ '$entry_referring_domain',
+ '$channel_type',
+ '$entry_utm_source',
+ '$entry_current_url',
+ ]),
+ '/api/projects/:team_id/property_definitions/': ({ request }) => {
+ const type = new URL(request.url).searchParams.get('type')
+ return type === 'person'
+ ? paginated(['email', 'plan', 'company_size'])
+ : paginated(['$geoip_country_code', '$browser', '$device_type', '$os'])
+ },
},
post: {
- '/api/environments/:team_id/query/:query_kind/': observationsTrend,
+ '/api/environments/:team_id/query/:query_kind/': async ({ request }) => {
+ const body = (await request.json()) as { query?: { query?: string } } | null
+ // The observation page's pinned strip is the only query aliasing its columns this way.
+ return body?.query?.query?.includes('as pinned_0')
+ ? { results: [sessionPropertiesRow] }
+ : observationsTrend
+ },
'/api/projects/:team_id/vision/scanners/estimate/': estimate,
},
}),
@@ -699,6 +762,18 @@ export const ObservationDetail: StoryObj = {
parameters: { pageUrl: urls.replayVisionObservation(observationDetail.id) },
}
+// The only story covering the collapsed prompt row and the pinned session properties card.
+export const ObservationDetailMonitor: StoryObj = {
+ parameters: { pageUrl: urls.replayVisionObservation(monitorObservationDetail.id) },
+ decorators: [
+ mswDecorator({
+ get: {
+ '/api/projects/:team_id/vision/observations/:id/': monitorObservationDetail,
+ },
+ }),
+ ],
+}
+
// Billing hasn't clamped this org's limit yet, so the API still reports it as uncapped.
export const StartupProgramCap: StoryObj = {
decorators: [