-
Notifications
You must be signed in to change notification settings - Fork 21
feat(browser): Action markers in timeline of session replay #1092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
allansson
wants to merge
26
commits into
main
Choose a base branch
from
feat/timeline-markers-for-actions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
f5c813a
first iteration of timeline markers for actions
allansson de93f4e
additional timeline work
allansson 1b302c1
use absolute positioning for chapters
allansson 30c2e5b
visualize actions as lanes
allansson cdf4d04
additional comments + add back thumb
allansson ecc4edd
only show hovered action in tooltip
allansson 8465bb1
set max lane height and allow hover while running
allansson 78371a1
set min-height on timeline
allansson 597216e
Merge branch 'main' into feat/timeline-markers-for-actions
allansson 822e69d
assume only two concurrent tasks by default
allansson 856a286
safety commit
allansson 5182a7a
minor style tweaks
allansson e8b9a7e
improve dragging thumb when over action
allansson 8141212
improved styles
allansson 4d17ec3
improve readability of timeline
allansson 2390ecb
more style tweaks
allansson 03f8b17
don't allocate new lanes when lanes above are free
allansson ea78eb7
use patch-package to add stopLive to rrweb
allansson 6c02d07
Merge branch 'main' into feat/timeline-markers-for-actions
allansson febdd4c
prevent actions from rendering outside timeline
allansson 4969d99
stopLive before liveMode config
allansson 35b2ad8
rewrite how the timeline works
allansson 8ea6d55
simplified the segment pos/size calculations
allansson 3dd7116
fix action-end events not being added
allansson 0edac21
remove unused export
allansson ed668e4
emit stopped event only once
allansson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| diff --git a/node_modules/rrweb/dist/rrweb.cjs b/node_modules/rrweb/dist/rrweb.cjs | ||
| index d455aa0..86e7de1 100644 | ||
| --- a/node_modules/rrweb/dist/rrweb.cjs | ||
| +++ b/node_modules/rrweb/dist/rrweb.cjs | ||
| @@ -14576,6 +14576,10 @@ function createPlayerService(context, { getCastFn, applyEventsSynchronously, emi | ||
| }, | ||
| live: { | ||
| on: { | ||
| + STOP_LIVE: { | ||
| + target: "paused", | ||
| + actions: ["pause"] | ||
| + }, | ||
| ADD_EVENT: { | ||
| target: "live", | ||
| actions: ["addEvent"] | ||
| @@ -15702,6 +15706,9 @@ class Replayer { | ||
| startLive(baselineTime) { | ||
| this.service.send({ type: "TO_LIVE", payload: { baselineTime } }); | ||
| } | ||
| + stopLive() { | ||
| + this.service.send({ type: "STOP_LIVE" }); | ||
| + } | ||
| addEvent(rawEvent) { | ||
| const event = this.config.unpackFn ? this.config.unpackFn(rawEvent) : rawEvent; | ||
| if (indicatesTouchDevice(event)) { | ||
| diff --git a/node_modules/rrweb/dist/rrweb.d.ts b/node_modules/rrweb/dist/rrweb.d.ts | ||
| index 95305d6..66540cb 100644 | ||
| --- a/node_modules/rrweb/dist/rrweb.d.ts | ||
| +++ b/node_modules/rrweb/dist/rrweb.d.ts | ||
| @@ -182,6 +182,8 @@ declare type PlayerEvent = { | ||
| }; | ||
| } | { | ||
| type: 'PAUSE'; | ||
| +} | { | ||
| + type: 'STOP_LIVE'; | ||
| } | { | ||
| type: 'TO_LIVE'; | ||
| payload: { | ||
| @@ -299,6 +301,7 @@ export declare class Replayer { | ||
| resume(timeOffset?: number): void; | ||
| destroy(): void; | ||
| startLive(baselineTime?: number): void; | ||
| + stopLive(): void; | ||
| addEvent(rawEvent: eventWithTime | string): void; | ||
| enableInteract(): void; | ||
| disableInteract(): void; | ||
| diff --git a/node_modules/rrweb/dist/rrweb.js b/node_modules/rrweb/dist/rrweb.js | ||
| index 5d38597..13a9d10 100644 | ||
| --- a/node_modules/rrweb/dist/rrweb.js | ||
| +++ b/node_modules/rrweb/dist/rrweb.js | ||
| @@ -14574,6 +14574,10 @@ function createPlayerService(context, { getCastFn, applyEventsSynchronously, emi | ||
| }, | ||
| live: { | ||
| on: { | ||
| + STOP_LIVE: { | ||
| + target: 'paused', | ||
| + actions: ["pause"] | ||
| + }, | ||
| ADD_EVENT: { | ||
| target: "live", | ||
| actions: ["addEvent"] | ||
| @@ -15700,6 +15704,9 @@ class Replayer { | ||
| startLive(baselineTime) { | ||
| this.service.send({ type: "TO_LIVE", payload: { baselineTime } }); | ||
| } | ||
| + stopLive() { | ||
| + this.service.send({ type: "STOP_LIVE" }); | ||
| + } | ||
| addEvent(rawEvent) { | ||
| const event = this.config.unpackFn ? this.config.unpackFn(rawEvent) : rawEvent; | ||
| if (indicatesTouchDevice(event)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,131 @@ | ||
| import { useCallback, useEffect, useState } from 'react' | ||
|
|
||
| import { BrowserReplayEvent } from '@/main/runner/schema' | ||
| import { createReplayEvent } from '@/main/runner/rrweb' | ||
| import { BrowserActionEvent, BrowserReplayEvent } from '@/main/runner/schema' | ||
|
|
||
| export function useBrowserReplay() { | ||
| const [browserReplay, setBrowserReplay] = useState<BrowserReplayEvent[]>([]) | ||
| interface BrowserSession { | ||
| actions: BrowserActionEvent[] | ||
| replay: BrowserReplayEvent[] | ||
| } | ||
|
|
||
| export function useBrowserSession() { | ||
| const [browserSession, setBrowserSession] = useState<BrowserSession>({ | ||
| actions: [], | ||
| replay: [], | ||
| }) | ||
|
|
||
| useEffect(() => { | ||
| return window.studio.script.onBrowserAction((event) => { | ||
| if (event.type === 'begin') { | ||
| setBrowserSession((session) => ({ | ||
| ...session, | ||
| actions: [...session.actions, event], | ||
| replay: [ | ||
| ...session.replay, | ||
| createReplayEvent({ | ||
| tag: 'action-begin', | ||
| payload: { | ||
| actionId: event.eventId, | ||
| }, | ||
| timestamp: event.timestamp.started, | ||
| }), | ||
| ], | ||
| })) | ||
|
|
||
| return | ||
| } | ||
|
|
||
| setBrowserSession((session) => ({ | ||
| ...session, | ||
| actions: session.actions.map((action) => | ||
| action.eventId === event.eventId ? event : action | ||
| ), | ||
| replay: [ | ||
| ...session.replay, | ||
| createReplayEvent({ | ||
| tag: 'action-end', | ||
| payload: { | ||
| actionId: event.eventId, | ||
| }, | ||
| timestamp: event.timestamp.ended, | ||
| }), | ||
| ], | ||
| })) | ||
| }) | ||
| }, []) | ||
|
|
||
| useEffect(() => { | ||
| return window.studio.script.onBrowserReplay((events) => { | ||
| setBrowserReplay((existing) => [...existing, ...events]) | ||
| setBrowserSession((session) => ({ | ||
| ...session, | ||
| replay: [...session.replay, ...events], | ||
| })) | ||
| }) | ||
| }, []) | ||
|
|
||
| const resetBrowserReplay = useCallback(() => { | ||
| setBrowserReplay([]) | ||
| useEffect(() => { | ||
| return window.studio.script.onScriptStopped(() => { | ||
| setBrowserSession((session) => { | ||
| const now = Date.now() | ||
|
|
||
| // Abort all actions that were running when the script stopped. | ||
| const actions: BrowserActionEvent[] = session.actions.map((action) => { | ||
| if (action.type !== 'begin') { | ||
| return action | ||
| } | ||
|
|
||
| return { | ||
| ...action, | ||
| type: 'end', | ||
| timestamp: { | ||
| ...action.timestamp, | ||
| ended: now, | ||
| }, | ||
| result: { | ||
| type: 'aborted', | ||
| }, | ||
| } | ||
| }) | ||
|
|
||
| // Insert action end events for all actions that were running when the script stopped. | ||
| const actionEnds = session.actions | ||
| .filter((action) => action.type === 'begin') | ||
| .map((action) => | ||
| createReplayEvent({ | ||
| tag: 'action-end', | ||
| payload: { | ||
| actionId: action.eventId, | ||
| }, | ||
| timestamp: now, | ||
| }) | ||
| ) | ||
|
|
||
| return { | ||
| ...session, | ||
| actions, | ||
| replay: [ | ||
| ...session.replay, | ||
| ...actionEnds, | ||
| createReplayEvent({ | ||
| tag: 'recording-end', | ||
| payload: {}, | ||
| timestamp: now, | ||
| }), | ||
| ], | ||
| } | ||
| }) | ||
| }) | ||
| }, []) | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const resetBrowserSession = useCallback(() => { | ||
| setBrowserSession({ | ||
| actions: [], | ||
| replay: [], | ||
| }) | ||
| }, []) | ||
|
|
||
| return { browserReplay, resetBrowserReplay } | ||
| return { | ||
| browserSession, | ||
| resetBrowserSession, | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.