Skip to content

Commit afaec55

Browse files
authored
feat(trace): show dialogs, navigations and misc events (#5025)
1 parent e67d563 commit afaec55

File tree

13 files changed

+289
-101
lines changed

13 files changed

+289
-101
lines changed

src/cli/traceViewer/traceModel.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
import * as trace from '../../trace/traceTypes';
18+
export * as trace from '../../trace/traceTypes';
1819

1920
export type TraceModel = {
2021
contexts: ContextEntry[];
@@ -36,11 +37,14 @@ export type VideoEntry = {
3637
videoId: string;
3738
};
3839

40+
export type InterestingPageEvent = trace.DialogOpenedEvent | trace.DialogClosedEvent | trace.NavigationEvent | trace.LoadEvent;
41+
3942
export type PageEntry = {
4043
created: trace.PageCreatedTraceEvent;
4144
destroyed: trace.PageDestroyedTraceEvent;
4245
video?: VideoEntry;
4346
actions: ActionEntry[];
47+
interestingEvents: InterestingPageEvent[];
4448
resources: trace.NetworkResourceTraceEvent[];
4549
}
4650

@@ -88,6 +92,7 @@ export function readTraceFile(events: trace.TraceEvent[], traceModel: TraceModel
8892
destroyed: undefined as any,
8993
actions: [],
9094
resources: [],
95+
interestingEvents: [],
9196
};
9297
pageEntries.set(event.pageId, pageEntry);
9398
contextEntries.get(event.contextId)!.pages.push(pageEntry);
@@ -129,11 +134,19 @@ export function readTraceFile(events: trace.TraceEvent[], traceModel: TraceModel
129134
responseEvents.push(event);
130135
break;
131136
}
137+
case 'dialog-opened':
138+
case 'dialog-closed':
139+
case 'navigation':
140+
case 'load': {
141+
const pageEntry = pageEntries.get(event.pageId)!;
142+
pageEntry.interestingEvents.push(event);
143+
break;
144+
}
132145
}
133146

134147
const contextEntry = contextEntries.get(event.contextId)!;
135-
contextEntry.startTime = Math.min(contextEntry.startTime, (event as any).timestamp);
136-
contextEntry.endTime = Math.max(contextEntry.endTime, (event as any).timestamp);
148+
contextEntry.startTime = Math.min(contextEntry.startTime, event.timestamp);
149+
contextEntry.endTime = Math.max(contextEntry.endTime, event.timestamp);
137150
}
138151
traceModel.contexts.push(...contextEntries.values());
139152
}

src/cli/traceViewer/videoTileGenerator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function parseMetaInfo(text: string, video: PageVideoTraceEvent): VideoMetaInfo
8181
width: parseInt(resolutionMatch![1], 10),
8282
height: parseInt(resolutionMatch![2], 10),
8383
fps: parseInt(fpsMatch![1], 10),
84-
startTime: (video as any).timestamp,
85-
endTime: (video as any).timestamp + duration
84+
startTime: video.timestamp,
85+
endTime: video.timestamp + duration
8686
};
8787
}

src/cli/traceViewer/web/common.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
--purple: #9C27B0;
2525
--yellow: #FFC107;
2626
--blue: #2196F3;
27+
--transparent-blue: #2196F355;
2728
--orange: #d24726;
2829
--black: #1E1E1E;
2930
--gray: #888888;

src/cli/traceViewer/web/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,19 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { TraceModel, VideoMetaInfo } from '../traceModel';
17+
import { TraceModel, VideoMetaInfo, trace } from '../traceModel';
1818
import './common.css';
1919
import './third_party/vscode/codicon.css';
2020
import { Workbench } from './ui/workbench';
2121
import * as React from 'react';
2222
import * as ReactDOM from 'react-dom';
23-
import { ActionTraceEvent } from '../../../trace/traceTypes';
2423

2524
declare global {
2625
interface Window {
2726
getTraceModel(): Promise<TraceModel>;
2827
getVideoMetaInfo(videoId: string): Promise<VideoMetaInfo | undefined>;
2928
readFile(filePath: string): Promise<string>;
30-
renderSnapshot(action: ActionTraceEvent): void;
29+
renderSnapshot(action: trace.ActionTraceEvent): void;
3130
}
3231
}
3332

src/cli/traceViewer/web/ui/timeline.css

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
background-color: rgb(0 0 0 / 10%);
3434
}
3535

36-
.timeline-label {
36+
.timeline-time {
3737
position: absolute;
3838
top: 4px;
3939
right: 3px;
@@ -58,16 +58,16 @@
5858
left: 0;
5959
}
6060

61-
.timeline-lane.timeline-action-labels {
61+
.timeline-lane.timeline-labels {
6262
margin-top: 10px;
6363
}
6464

65-
.timeline-lane.timeline-actions {
65+
.timeline-lane.timeline-bars {
6666
margin-bottom: 10px;
6767
overflow: visible;
6868
}
6969

70-
.timeline-action {
70+
.timeline-bar {
7171
position: absolute;
7272
top: 0;
7373
bottom: 0;
@@ -77,39 +77,52 @@
7777
background-color: var(--action-color);
7878
}
7979

80-
.timeline-action.selected {
80+
.timeline-bar.selected {
8181
filter: brightness(70%);
8282
box-shadow: 0 0 0 1px var(--action-color);
8383
}
8484

85-
.timeline-action.click {
85+
.timeline-bar.click {
8686
--action-color: var(--green);
8787
}
8888

89-
.timeline-action.fill,
90-
.timeline-action.press {
89+
.timeline-bar.fill,
90+
.timeline-bar.press {
9191
--action-color: var(--orange);
9292
}
9393

94-
.timeline-action.goto {
94+
.timeline-bar.goto {
9595
--action-color: var(--blue);
9696
}
9797

98-
.timeline-action-label {
98+
.timeline-bar.dialog {
99+
--action-color: var(--transparent-blue);
100+
}
101+
102+
.timeline-bar.navigation {
103+
--action-color: var(--purple);
104+
}
105+
106+
.timeline-bar.load {
107+
--action-color: var(--yellow);
108+
}
109+
110+
.timeline-label {
99111
position: absolute;
100112
top: 0;
101113
bottom: 0;
102114
margin-left: 2px;
103115
background-color: #fffffff0;
104116
justify-content: center;
105117
display: none;
118+
white-space: nowrap;
106119
}
107120

108-
.timeline-action-label.selected {
121+
.timeline-label.selected {
109122
display: flex;
110123
}
111124

112-
.timeline-time-bar {
125+
.timeline-marker {
113126
display: none;
114127
position: absolute;
115128
top: 0;
@@ -119,6 +132,6 @@
119132
pointer-events: none;
120133
}
121134

122-
.timeline-time-bar.timeline-time-bar-hover {
135+
.timeline-marker.timeline-marker-hover {
123136
background-color: var(--light-pink);
124137
}

0 commit comments

Comments
 (0)