@@ -9,46 +9,47 @@ import type {ClipWindow, VideoEvent} from 'sentry/utils/replays/types';
9
9
10
10
type RootElem = HTMLDivElement | null ;
11
11
12
- interface WrapperReplayerOptions {
12
+ interface VideoReplayerWithInteractionsOptions {
13
13
durationMs : number ;
14
+ events : eventWithTime [ ] ;
14
15
onBuffer : ( isBuffering : boolean ) => void ;
15
16
onFinished : ( ) => void ;
16
17
onLoaded : ( event : any ) => void ;
17
18
root : RootElem ;
18
19
start : number ;
19
20
theme : Theme ;
20
21
videoApiPrefix : string ;
22
+ videoEvents : VideoEvent [ ] ;
21
23
clipWindow ?: ClipWindow ;
22
24
}
23
25
24
26
/**
25
27
* A wrapper replayer that wraps both VideoReplayer and the rrweb Replayer.
26
28
* We need both instances in order to render the video playback alongside gestures.
27
29
*/
28
- export class WrapperReplayer {
30
+ export class VideoReplayerWithInteractions {
29
31
public config : VideoReplayerConfig = {
30
32
skipInactive : false ,
31
33
speed : 1.0 ,
32
34
} ;
33
35
public iframe = { } ;
34
- public videoInst : VideoReplayer ;
35
- public rrwebInst : Replayer ;
36
+ public videoReplayer : VideoReplayer ;
37
+ public replayer : Replayer ;
36
38
37
- constructor (
38
- { videoEvents, events} : { events : eventWithTime [ ] ; videoEvents : VideoEvent [ ] } ,
39
- {
40
- root,
41
- start,
42
- videoApiPrefix,
43
- onBuffer,
44
- onFinished,
45
- onLoaded,
46
- clipWindow,
47
- durationMs,
48
- theme,
49
- } : WrapperReplayerOptions
50
- ) {
51
- this . videoInst = new VideoReplayer ( videoEvents , {
39
+ constructor ( {
40
+ videoEvents,
41
+ events,
42
+ root,
43
+ start,
44
+ videoApiPrefix,
45
+ onBuffer,
46
+ onFinished,
47
+ onLoaded,
48
+ clipWindow,
49
+ durationMs,
50
+ theme,
51
+ } : VideoReplayerWithInteractionsOptions ) {
52
+ this . videoReplayer = new VideoReplayer ( videoEvents , {
52
53
videoApiPrefix,
53
54
root,
54
55
start,
@@ -61,9 +62,9 @@ export class WrapperReplayer {
61
62
62
63
root ?. classList . add ( 'video-replayer' ) ;
63
64
64
- const modifiedEvents : eventWithTime [ ] = [ ] ;
65
+ const eventsWithSnapshots : eventWithTime [ ] = [ ] ;
65
66
events . forEach ( ( e , idx ) => {
66
- modifiedEvents . push ( e ) ;
67
+ eventsWithSnapshots . push ( e ) ;
67
68
if ( e . type === 4 ) {
68
69
// Create a mock full snapshot event, in order to render rrweb gestures properly
69
70
// Need to add one for every meta event we see
@@ -80,7 +81,6 @@ export class WrapperReplayer {
80
81
name : 'html' ,
81
82
publicId : '' ,
82
83
systemId : '' ,
83
- id : 0 ,
84
84
} ,
85
85
{
86
86
type : 2 ,
@@ -89,23 +89,18 @@ export class WrapperReplayer {
89
89
lang : 'en' ,
90
90
} ,
91
91
childNodes : [ ] ,
92
- id : 0 ,
93
92
} ,
94
93
] ,
95
94
id : 0 ,
96
95
} ,
97
- initialOffset : {
98
- left : 0 ,
99
- top : 0 ,
100
- } ,
101
96
} ,
102
97
timestamp : events [ idx ] . timestamp ,
103
98
} ;
104
- modifiedEvents . push ( fullSnapshotEvent ) ;
99
+ eventsWithSnapshots . push ( fullSnapshotEvent ) ;
105
100
}
106
101
} ) ;
107
102
108
- this . rrwebInst = new Replayer ( modifiedEvents , {
103
+ this . replayer = new Replayer ( eventsWithSnapshots , {
109
104
root : root as Element ,
110
105
blockClass : 'sentry-block' ,
111
106
mouseTail : {
@@ -121,38 +116,38 @@ export class WrapperReplayer {
121
116
}
122
117
123
118
public destroy ( ) {
124
- this . videoInst . destroy ( ) ;
125
- this . rrwebInst . destroy ( ) ;
119
+ this . videoReplayer . destroy ( ) ;
120
+ this . replayer . destroy ( ) ;
126
121
}
127
122
128
123
/**
129
124
* Returns the current video time, using the video's external timer.
130
125
*/
131
126
public getCurrentTime ( ) {
132
- return this . videoInst . getCurrentTime ( ) ;
127
+ return this . videoReplayer . getCurrentTime ( ) ;
133
128
}
134
129
135
130
/**
136
131
* Play both the rrweb and video player.
137
132
*/
138
133
public play ( videoOffsetMs : number ) {
139
- this . videoInst . play ( videoOffsetMs ) ;
140
- this . rrwebInst . play ( videoOffsetMs ) ;
134
+ this . videoReplayer . play ( videoOffsetMs ) ;
135
+ this . replayer . play ( videoOffsetMs ) ;
141
136
}
142
137
143
138
/**
144
139
* Pause both the rrweb and video player.
145
140
*/
146
141
public pause ( videoOffsetMs : number ) {
147
- this . videoInst . pause ( videoOffsetMs ) ;
148
- this . rrwebInst . pause ( videoOffsetMs ) ;
142
+ this . videoReplayer . pause ( videoOffsetMs ) ;
143
+ this . replayer . pause ( videoOffsetMs ) ;
149
144
}
150
145
151
146
/**
152
147
* Equivalent to rrweb's `setConfig()`, but here we only support the `speed` configuration.
153
148
*/
154
149
public setConfig ( config : Partial < VideoReplayerConfig > ) : void {
155
- this . videoInst . setConfig ( config ) ;
156
- this . rrwebInst . setConfig ( config ) ;
150
+ this . videoReplayer . setConfig ( config ) ;
151
+ this . replayer . setConfig ( config ) ;
157
152
}
158
153
}
0 commit comments