@@ -9,46 +9,47 @@ import type {ClipWindow, VideoEvent} from 'sentry/utils/replays/types';
99
1010type RootElem = HTMLDivElement | null ;
1111
12- interface WrapperReplayerOptions {
12+ interface VideoReplayerWithInteractionsOptions {
1313 durationMs : number ;
14+ events : eventWithTime [ ] ;
1415 onBuffer : ( isBuffering : boolean ) => void ;
1516 onFinished : ( ) => void ;
1617 onLoaded : ( event : any ) => void ;
1718 root : RootElem ;
1819 start : number ;
1920 theme : Theme ;
2021 videoApiPrefix : string ;
22+ videoEvents : VideoEvent [ ] ;
2123 clipWindow ?: ClipWindow ;
2224}
2325
2426/**
2527 * A wrapper replayer that wraps both VideoReplayer and the rrweb Replayer.
2628 * We need both instances in order to render the video playback alongside gestures.
2729 */
28- export class WrapperReplayer {
30+ export class VideoReplayerWithInteractions {
2931 public config : VideoReplayerConfig = {
3032 skipInactive : false ,
3133 speed : 1.0 ,
3234 } ;
3335 public iframe = { } ;
34- public videoInst : VideoReplayer ;
35- public rrwebInst : Replayer ;
36+ public videoReplayer : VideoReplayer ;
37+ public replayer : Replayer ;
3638
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 , {
5253 videoApiPrefix,
5354 root,
5455 start,
@@ -61,9 +62,9 @@ export class WrapperReplayer {
6162
6263 root ?. classList . add ( 'video-replayer' ) ;
6364
64- const modifiedEvents : eventWithTime [ ] = [ ] ;
65+ const eventsWithSnapshots : eventWithTime [ ] = [ ] ;
6566 events . forEach ( ( e , idx ) => {
66- modifiedEvents . push ( e ) ;
67+ eventsWithSnapshots . push ( e ) ;
6768 if ( e . type === 4 ) {
6869 // Create a mock full snapshot event, in order to render rrweb gestures properly
6970 // Need to add one for every meta event we see
@@ -80,7 +81,6 @@ export class WrapperReplayer {
8081 name : 'html' ,
8182 publicId : '' ,
8283 systemId : '' ,
83- id : 0 ,
8484 } ,
8585 {
8686 type : 2 ,
@@ -89,23 +89,18 @@ export class WrapperReplayer {
8989 lang : 'en' ,
9090 } ,
9191 childNodes : [ ] ,
92- id : 0 ,
9392 } ,
9493 ] ,
9594 id : 0 ,
9695 } ,
97- initialOffset : {
98- left : 0 ,
99- top : 0 ,
100- } ,
10196 } ,
10297 timestamp : events [ idx ] . timestamp ,
10398 } ;
104- modifiedEvents . push ( fullSnapshotEvent ) ;
99+ eventsWithSnapshots . push ( fullSnapshotEvent ) ;
105100 }
106101 } ) ;
107102
108- this . rrwebInst = new Replayer ( modifiedEvents , {
103+ this . replayer = new Replayer ( eventsWithSnapshots , {
109104 root : root as Element ,
110105 blockClass : 'sentry-block' ,
111106 mouseTail : {
@@ -121,38 +116,38 @@ export class WrapperReplayer {
121116 }
122117
123118 public destroy ( ) {
124- this . videoInst . destroy ( ) ;
125- this . rrwebInst . destroy ( ) ;
119+ this . videoReplayer . destroy ( ) ;
120+ this . replayer . destroy ( ) ;
126121 }
127122
128123 /**
129124 * Returns the current video time, using the video's external timer.
130125 */
131126 public getCurrentTime ( ) {
132- return this . videoInst . getCurrentTime ( ) ;
127+ return this . videoReplayer . getCurrentTime ( ) ;
133128 }
134129
135130 /**
136131 * Play both the rrweb and video player.
137132 */
138133 public play ( videoOffsetMs : number ) {
139- this . videoInst . play ( videoOffsetMs ) ;
140- this . rrwebInst . play ( videoOffsetMs ) ;
134+ this . videoReplayer . play ( videoOffsetMs ) ;
135+ this . replayer . play ( videoOffsetMs ) ;
141136 }
142137
143138 /**
144139 * Pause both the rrweb and video player.
145140 */
146141 public pause ( videoOffsetMs : number ) {
147- this . videoInst . pause ( videoOffsetMs ) ;
148- this . rrwebInst . pause ( videoOffsetMs ) ;
142+ this . videoReplayer . pause ( videoOffsetMs ) ;
143+ this . replayer . pause ( videoOffsetMs ) ;
149144 }
150145
151146 /**
152147 * Equivalent to rrweb's `setConfig()`, but here we only support the `speed` configuration.
153148 */
154149 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 ) ;
157152 }
158153}
0 commit comments