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): share an observation starting at a timestamp (#93765)

Kim Svatos Duganf1c2cdfdac53
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index d6722860a13d..b46150a8f76b 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -8341,13 +8341,13 @@ snapshots:
scenes-app-project-homepage--project-homepage--light:
hash: v1.k794b7964.45567c13e93e1def5dabfea7b6a4a5a47253482e6dd5c587be257ae5b9374639.IC346vxEHrTKcFor0vVTajrOk8lCGCu3C5pdFW2iTOQ
scenes-app-replay-vision--observation-detail--dark:
- hash: v1.k794b7964.2fe170e544ea302e2e752a2b742f8dcf49710909f54cdc6c911b245fa9403391.POKP1RHFnlV8cfwSDsAsUOY76QdhwKfc4Xryvh1TPkI
+ hash: v1.k794b7964.5c1e4dc71fab8dd16212232b0a6483e7b96f884bd6c9761f276e9d6d788192a3.EyeOt5zd-9ySXBJcK-nvwOcO-Q1umL8pWldTB9PWh9s
scenes-app-replay-vision--observation-detail--light:
- hash: v1.k794b7964.01a04970108058e482ffcd15e54a31480ce5c0a482c49e1912db97789a3c17e9.sPodqRrSOKwjS2bMBlK3yBQ79AY1Yh-WlJsY9Fqcu1M
+ hash: v1.k794b7964.d1585db51286bdddac28280c4285203c786279225e77694079f94c172dee4fc8.hXxdPRDiseuUCTAafU1no8DEGo0wRGTJ_wTRbrL-eS0
scenes-app-replay-vision--observation-detail-monitor--dark:
- hash: v1.k794b7964.d0fe843ea3b571a31f28472efd9f9908125c37dfca94a21b5603772e2acd5fc6.BmM6sQy3vpqNYC2sO29dYAeJ3vwDwE-moorC1s5tphE
+ hash: v1.k794b7964.55b81d9639474eba1f729479fac38f935641f164712a7f1e1ed7f5d595a9b40f.eonn1G6FtkOAzQ1GkpW7q_FtXrzYhkty8Zuxe1LCyMI
scenes-app-replay-vision--observation-detail-monitor--light:
- hash: v1.k794b7964.6c00a099a90ab21e583a36e214a6d68acd60f68e11bd489d9a0d4bb168effc3b.mS3DZfdS79PxSY9iLuXrAGW8EAYg00UptZg1_AQS9mo
+ hash: v1.k794b7964.c5243eda52db803aa1ebe8b08aafb31657c3e4bb087dec468a6e9108576a3a66.ZDaQ5Hu-nxVYAP_w41BkXf-IjyT-nl-Skp_jbIwftb8
scenes-app-replay-vision--scanner-alerts--dark:
hash: v1.k794b7964.c416988b5908944127a58d491bf68dceb3f1f9caf728b69185f372f11f2ab68c.aHRUHVbQvkxQzLEFJmWx1YUCfAPgMVcTyiAeuvNfUS4
scenes-app-replay-vision--scanner-alerts--light:
diff --git a/products/replay_vision/README.md b/products/replay_vision/README.md
index 02cc2d075192..81132b8b1b4e 100644
--- a/products/replay_vision/README.md
+++ b/products/replay_vision/README.md
@@ -51,6 +51,7 @@ A scanner can also carry its own optional `credit_limit` for the same period, so
**Scanner editor** (`/replay-vision/<scanner-id>/<step>`) is a stepper rather than tabs: Template, Configure, Scan conditions (`triggers`), Self-driving.
Observations have their own scene under `/replay-vision/observations/…`.
+An observation link carries the player's `?t=<seconds>` param, so a shared observation opens with its recording expanded and playing from the shared moment.
Outside these scenes, the product also renders inside the session replay player: `ObservationsDock` shows what the team's scanners found about the recording being watched (standard players only — embedded, shared, and chromeless players skip every vision surface).
diff --git a/products/replay_vision/frontend/observations/ObservationShareButton.tsx b/products/replay_vision/frontend/observations/ObservationShareButton.tsx
new file mode 100644
index 000000000000..aba9fe122eb7
--- /dev/null
+++ b/products/replay_vision/frontend/observations/ObservationShareButton.tsx
@@ -0,0 +1,102 @@
+import { useActions, useValues } from 'kea'
+
+import { IconCopy, IconShare } from '@posthog/icons'
+import { LemonButton, LemonCheckbox, LemonInput } from '@posthog/lemon-ui'
+
+import { LemonDialog } from 'lib/lemon-ui/LemonDialog'
+import posthog from 'lib/posthog-typed'
+import { copyToClipboard } from 'lib/utils/copyToClipboard'
+import { getCurrentPlayerTime } from 'scenes/session-recordings/player/sessionRecordingPlayerLogic'
+
+import { ObservationShareLogicProps, observationShareLogic } from './observationShareLogic'
+
+function ObservationShareDialogContent(props: ObservationShareLogicProps): JSX.Element {
+ const { shareUrl, includeTime, time, timeError } = useValues(observationShareLogic(props))
+ const { setIncludeTime, setTime } = useActions(observationShareLogic(props))
+
+ return (
+ <div className="flex flex-col gap-4">
+ <div className="flex flex-col gap-1">
+ <div>
+ <b>Click the button below</b> to copy a link to this observation.
+ </div>
+ <div>Make sure the person you share it with has access to this PostHog project.</div>
+ </div>
+ <LemonButton
+ type="secondary"
+ fullWidth
+ center
+ sideIcon={<IconCopy />}
+ onClick={() => {
+ posthog.capture('replay_vision_observation_link_copied', { with_timestamp: includeTime })
+ void copyToClipboard(shareUrl, 'observation link').catch((e) => posthog.captureException(e))
+ }}
+ title={shareUrl}
+ disabledReason={timeError ?? undefined}
+ data-attr="vision-observation-share-copy"
+ >
+ <span className="break-all">{shareUrl}</span>
+ </LemonButton>
+ <div className="flex gap-2 items-center">
+ <LemonCheckbox
+ label="Start recording at"
+ checked={includeTime}
+ onChange={setIncludeTime}
+ data-attr="vision-observation-share-include-time"
+ />
+ <LemonInput
+ className="w-20"
+ placeholder="00:00"
+ value={time ?? ''}
+ onChange={setTime}
+ onFocus={() => setIncludeTime(true)}
+ fullWidth={false}
+ size="small"
+ status={timeError ? 'danger' : undefined}
+ data-attr="vision-observation-share-time"
+ />
+ </div>
+ {timeError && <p className="text-danger text-xs m-0">{timeError}</p>}
+ </div>
+ )
+}
+
+/**
+ * Shares the observation page itself, not only the recording — the reader lands on the model's verdict with
+ * the recording already open at the moment being discussed.
+ */
+export function ObservationShareButton({
+ observationId,
+ sessionRecordingId,
+ playerKey,
+}: {
+ observationId: string
+ sessionRecordingId: string
+ playerKey: string
+}): JSX.Element {
+ return (
+ <LemonButton
+ icon={<IconShare />}
+ type="secondary"
+ size="small"
+ tooltip="Copy a link to this observation, starting the recording where you are"
+ data-attr="vision-observation-share"
+ onClick={() =>
+ LemonDialog.open({
+ title: 'Share observation',
+ // Read at click time: the player keeps moving, and reading it earlier would re-render the page.
+ content: () => (
+ <ObservationShareDialogContent
+ observationId={observationId}
+ seconds={getCurrentPlayerTime({ playerKey, sessionRecordingId })}
+ />
+ ),
+ maxWidth: '30rem',
+ primaryButton: null,
+ })
+ }
+ >
+ Share
+ </LemonButton>
+ )
+}
diff --git a/products/replay_vision/frontend/observations/ReplayObservation.tsx b/products/replay_vision/frontend/observations/ReplayObservation.tsx
index f99a5bbf9485..935fae29ef98 100644
--- a/products/replay_vision/frontend/observations/ReplayObservation.tsx
+++ b/products/replay_vision/frontend/observations/ReplayObservation.tsx
@@ -11,6 +11,7 @@ import {
IconExpand,
IconGear,
IconInfo,
+ IconPlayFilled,
IconSparkles,
IconThoughtBubble,
IconVideoCamera,
@@ -67,8 +68,10 @@ import {
SUCCEEDED_OUTPUT_LABEL,
} from '../replay_scanners/types'
import { scannerLabel } from '../utils/observation'
+import { parseNumericParam } from '../utils/urlParams'
import { ObservationLabelControl } from './ObservationLabelControl'
import { ObservationPinnedProperties } from './ObservationPinnedProperties'
+import { ObservationShareButton } from './ObservationShareButton'
import {
neighborFilterParams,
observationDetailUrl,
@@ -145,11 +148,19 @@ export function ReplayObservationSceneComponent(): JSX.Element {
const namingVariant = modelNamingVariant(featureFlags[FEATURE_FLAGS.REPLAY_VISION_MODEL_TIER_NAMING_EXPERIMENT])
const [recordingExpanded, setRecordingExpanded] = useState(false)
const [pendingSeek, setPendingSeek] = useState<{ ms: number; trigger: number } | null>(null)
+ // A shared link carries the moment the sharer was watching, in seconds, the same way a recording link does.
+ const sharedStartSeconds = parseNumericParam(searchParams.t)
- // A citation seek belongs to one observation — never replay it on a sibling after prev/next navigation.
+ // Open a shared link where its sender left off. A seek belongs to one observation, so both the shared
+ // start and any citation seek are dropped once prev/next moves to a sibling.
useEffect(() => {
- setPendingSeek(null)
- }, [observationId])
+ if (sharedStartSeconds !== null && sharedStartSeconds >= 0) {
+ setRecordingExpanded(true)
+ setPendingSeek({ ms: sharedStartSeconds * 1000, trigger: Date.now() })
+ } else {
+ setPendingSeek(null)
+ }
+ }, [observationId, sharedStartSeconds])
const observationLogic = replayObservationLogic({ id: observationId })
useAttachedLogic(observationLogic, replayObservationSceneLogic)
@@ -177,6 +188,7 @@ export function ReplayObservationSceneComponent(): JSX.Element {
)
}
+ const playerKey = `vision-observation-${observation.id}`
const snapshot = observation.scanner_snapshot
const result = readResult(observation)
const reasoning = result && typeof result.reasoning === 'string' ? result.reasoning : null
@@ -300,34 +312,60 @@ export function ReplayObservationSceneComponent(): JSX.Element {
>
Next
</LemonButton>
+ <ObservationShareButton
+ observationId={observation.id}
+ sessionRecordingId={observation.session_id}
+ playerKey={playerKey}
+ />
<ReplayVisionFeedbackButton />
</>
}
/>
<LemonCard className="overflow-hidden p-0" hoverEffect={false}>
- <div
- className="flex items-center gap-2 bg-surface-primary p-3 cursor-pointer hover:bg-surface-secondary"
- onClick={toggleRecordingExpanded}
- >
- <LemonButton
- icon={recordingExpanded ? <IconCollapse /> : <IconExpand />}
- size="small"
- tooltip={recordingExpanded ? 'Collapse recording' : 'Expand recording'}
- onClick={(e) => {
- e.stopPropagation()
- toggleRecordingExpanded()
- }}
+ {recordingExpanded ? (
+ <div
+ className="flex items-center gap-2 bg-surface-primary p-3 cursor-pointer hover:bg-surface-secondary"
+ onClick={toggleRecordingExpanded}
+ >
+ <LemonButton
+ icon={<IconCollapse />}
+ size="small"
+ tooltip="Collapse recording"
+ onClick={(e) => {
+ e.stopPropagation()
+ toggleRecordingExpanded()
+ }}
+ data-attr="vision-observation-recording-toggle"
+ />
+ <IconVideoCamera className="text-muted-alt" />
+ <h3 className="text-lg font-semibold m-0">Recording</h3>
+ </div>
+ ) : (
+ // Collapsed, this row is the only sign the page holds a video, so it leads with a
+ // thumbnail of the player it opens: a dark screen carrying one play target.
+ <button
+ type="button"
+ className="w-full flex items-center gap-3 p-3 text-left bg-surface-primary hover:bg-surface-secondary"
+ onClick={toggleRecordingExpanded}
+ aria-expanded={false}
data-attr="vision-observation-recording-toggle"
- />
- <IconVideoCamera className="text-muted-alt" />
- <h3 className="text-lg font-semibold m-0">Recording</h3>
- </div>
+ >
+ <span className="flex items-center justify-center w-20 h-12 rounded bg-black shrink-0">
+ <IconPlayFilled className="text-xl text-brand-red" />
+ </span>
+ <span className="flex-1 min-w-0">
+ <h3 className="text-lg font-semibold m-0">Watch the recording</h3>
+ <span className="text-sm text-muted">Play the session this observation was made from</span>
+ </span>
+ <IconExpand className="text-lg text-muted-alt shrink-0" />
+ </button>
+ )}
{recordingExpanded && (
<div className="border-t border-border h-[calc(100vh-16rem)] min-h-[480px]">
<SessionRecordingPlayer
sessionRecordingId={observation.session_id}
- playerKey={`vision-observation-${observation.id}`}
+ playerKey={playerKey}
mode={SessionRecordingPlayerMode.Standard}
autoPlay={false}
noBorder
@@ -336,7 +374,7 @@ export function ReplayObservationSceneComponent(): JSX.Element {
/>
{pendingSeek && (
<AutoSeekToTime
- playerKey={`vision-observation-${observation.id}`}
+ playerKey={playerKey}
sessionRecordingId={observation.session_id}
ms={pendingSeek.ms}
trigger={pendingSeek.trigger}
diff --git a/products/replay_vision/frontend/observations/observationShareLogic.test.ts b/products/replay_vision/frontend/observations/observationShareLogic.test.ts
new file mode 100644
index 000000000000..127e620d41cd
--- /dev/null
+++ b/products/replay_vision/frontend/observations/observationShareLogic.test.ts
@@ -0,0 +1,52 @@
+import { expectLogic } from 'kea-test-utils'
+
+import { initKeaTests } from '~/test/init'
+
+import { observationShareLogic } from './observationShareLogic'
+
+describe('observationShareLogic', () => {
+ let logic: ReturnType<typeof observationShareLogic.build>
+
+ beforeEach(() => {
+ initKeaTests()
+ logic = observationShareLogic({ observationId: 'obs-1', seconds: 95 })
+ logic.mount()
+ })
+
+ afterEach(() => {
+ logic?.unmount()
+ })
+
+ // The point of the feature: the link opens the observation page, not the bare recording, and the
+ // recording inside it starts where the sharer was watching.
+ it('links to the observation page at the current player time', () => {
+ expect(logic.values.time).toBe('01:35')
+ expect(logic.values.shareUrl).toContain('/replay-vision/observations/obs-1?t=95')
+ })
+
+ it('drops the timestamp when the sharer opts out', async () => {
+ await expectLogic(logic, () => logic.actions.setIncludeTime(false)).toMatchValues({
+ shareUrl: expect.not.stringContaining('t='),
+ })
+ })
+
+ // `t=0` is not "no timestamp": it force-expands the recording on the reader's page and seeks to the
+ // start, so an emptied field has to drop the param rather than fall back to zero.
+ it('drops the timestamp when the time field is emptied', async () => {
+ await expectLogic(logic, () => logic.actions.setTime('')).toMatchValues({
+ shareUrl: expect.not.stringContaining('t='),
+ })
+ })
+
+ it('keeps a deliberate 00:00 as a shared start', async () => {
+ await expectLogic(logic, () => logic.actions.setTime('00:00')).toMatchValues({
+ shareUrl: expect.stringContaining('?t=0'),
+ })
+ })
+
+ it('rejects a time it cannot turn into seconds', async () => {
+ await expectLogic(logic, () => logic.actions.setTime('halfway')).toMatchValues({
+ timeError: expect.stringContaining('valid time'),
+ })
+ })
+})
diff --git a/products/replay_vision/frontend/observations/observationShareLogic.ts b/products/replay_vision/frontend/observations/observationShareLogic.ts
new file mode 100644
index 000000000000..9ee6f0743331
--- /dev/null
+++ b/products/replay_vision/frontend/observations/observationShareLogic.ts
@@ -0,0 +1,107 @@
+import { MakeLogicType, actions, kea, key, path, props, reducers, selectors } from 'kea'
+import { combineUrl } from 'kea-router'
+
+import { colonDelimitedDuration, reverseColonDelimitedDuration } from 'lib/utils/durations'
+import { urls } from 'scenes/urls'
+
+export interface ObservationShareLogicProps {
+ observationId: string
+ /** Where the recording is paused when the dialog opens, in whole seconds. */
+ seconds: number
+}
+
+export interface ObservationShareForm {
+ includeTime: boolean
+ time: string | null
+}
+
+/**
+ * Absolute link to an observation page. `t` is the same seconds param the player already reads, so the
+ * embedded recording starts where the sharer was watching instead of at the beginning.
+ */
+export function observationShareUrl(observationId: string, form: ObservationShareForm): string {
+ // A cleared or unreadable field names no moment, so the param is dropped rather than sent as `t=0`,
+ // which would force the recording open at the very start on the reader's page. A typed `00:00` parses
+ // to 0 rather than null, so sharing the first second still works.
+ const seconds = form.includeTime ? reverseColonDelimitedDuration(form.time) : null
+ return combineUrl(urls.absolute(urls.currentProject(urls.replayVisionObservation(observationId))), {
+ t: seconds === null ? undefined : `${seconds}`,
+ }).url
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface observationShareLogicValues {
+ includeTime: boolean
+ shareUrl: string
+ time: string | null
+ timeError: string | null
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface observationShareLogicActions {
+ setIncludeTime: (includeTime: boolean) => {
+ includeTime: boolean
+ }
+ setTime: (time: string | null) => {
+ time: string | null
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface observationShareLogicMeta {
+ key: string
+ __keaTypeGenInternalSelectorTypes: {
+ timeError: (includeTime: boolean, time: string | null) => string | null
+ shareUrl: (includeTime: boolean, time: string | null) => string
+ }
+}
+
+export type observationShareLogicType = MakeLogicType<
+ observationShareLogicValues,
+ observationShareLogicActions,
+ ObservationShareLogicProps,
+ observationShareLogicMeta
+>
+
+export const observationShareLogic = kea<observationShareLogicType>([
+ path(['products', 'replay_vision', 'frontend', 'observations', 'observationShareLogic']),
+ props({} as ObservationShareLogicProps),
+ key((props: ObservationShareLogicProps) => `${props.observationId}-${props.seconds}`),
+
+ actions({
+ setIncludeTime: (includeTime: boolean) => ({ includeTime }),
+ setTime: (time: string | null) => ({ time }),
+ }),
+
+ reducers(({ props }) => ({
+ includeTime: [
+ true,
+ {
+ setIncludeTime: (_, { includeTime }: { includeTime: boolean }) => includeTime,
+ // Typing a time means you want it, so tick the box rather than making people click twice.
+ setTime: () => true,
+ },
+ ],
+ time: [
+ colonDelimitedDuration(props.seconds, null) as string | null,
+ {
+ setTime: (_, { time }: { time: string | null }) => time,
+ },
+ ],
+ })),
+
+ selectors(({ props }) => ({
+ timeError: [
+ (s) => [s.includeTime, s.time],
+ (includeTime: boolean, time: string | null): string | null =>
+ includeTime && time && reverseColonDelimitedDuration(time) === null
+ ? 'Set a valid time like 02:30 (minutes:seconds)'
+ : null,
+ ],
+ shareUrl: [
+ (s) => [s.includeTime, s.time],
+ (includeTime: boolean, time: string | null): string =>
+ observationShareUrl(props.observationId, { includeTime, time }),
+ ],
+ })),
+])