11import { isMobile } from "./GleapHelper" ;
2- import { rrwebRecord } from "./RRWebRecorder.js " ;
2+ import { record } from "@rrweb/record " ;
33
44export default class GleapReplayRecorder {
55 startDate = undefined ;
@@ -19,15 +19,15 @@ export default class GleapReplayRecorder {
1919 }
2020 }
2121
22- constructor ( ) { }
22+ constructor ( ) { }
2323
2424 setOptions ( options ) {
2525 this . customOptions = options ;
2626 }
2727
2828 /**
2929 * Start replays
30- * @returns
30+ * @returns
3131 */
3232 start ( ) {
3333 this . stop ( ) ;
@@ -63,7 +63,7 @@ export default class GleapReplayRecorder {
6363 } ;
6464
6565 try {
66- this . stopFunction = rrwebRecord ( {
66+ this . stopFunction = record ( {
6767 ...options ,
6868 ...this . customOptions ,
6969 emit ( rrwebEvent ) {
@@ -78,7 +78,7 @@ export default class GleapReplayRecorder {
7878
7979 /**
8080 * Stop replays
81- * @returns
81+ * @returns
8282 */
8383 stop ( ) {
8484 if ( this . stopFunction ) {
@@ -102,7 +102,7 @@ export default class GleapReplayRecorder {
102102 width : window . innerWidth ,
103103 height : window . innerHeight ,
104104 isMobile : isMobile ( ) ,
105- type : ' rrweb' ,
105+ type : " rrweb" ,
106106 } ;
107107
108108 return replayResult ;
@@ -112,15 +112,18 @@ export default class GleapReplayRecorder {
112112export function ensureMaxMessageSize ( data ) {
113113 let stringifiedData = JSON . stringify ( data ) ;
114114 if ( stringifiedData . length > 4000000 ) {
115- const dataURIRegex = / d a t a : ( [ \w \/ \- \. ] + ) ; ( \w + ) , ( [ ^ ) " ] * ) / gim
116- const matches = stringifiedData . matchAll ( dataURIRegex )
115+ const dataURIRegex = / d a t a : ( [ \w \/ \- \. ] + ) ; ( \w + ) , ( [ ^ ) " ] * ) / gim;
116+ const matches = stringifiedData . matchAll ( dataURIRegex ) ;
117117 for ( const match of matches ) {
118- if ( match [ 1 ] . toLocaleLowerCase ( ) . slice ( 0 , 6 ) === 'image/' ) {
119- stringifiedData = stringifiedData . replace ( match [ 0 ] , 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAQSURBVHgBAQUA+v8ABRg5/wHSAVZN1mnaAAAAAElFTkSuQmCC' )
118+ if ( match [ 1 ] . toLocaleLowerCase ( ) . slice ( 0 , 6 ) === "image/" ) {
119+ stringifiedData = stringifiedData . replace (
120+ match [ 0 ] ,
121+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAQSURBVHgBAQUA+v8ABRg5/wHSAVZN1mnaAAAAAElFTkSuQmCC"
122+ ) ;
120123 } else {
121- stringifiedData = stringifiedData . replace ( match [ 0 ] , '' )
124+ stringifiedData = stringifiedData . replace ( match [ 0 ] , "" ) ;
122125 }
123126 }
124127 }
125- return { event : JSON . parse ( stringifiedData ) , size : stringifiedData . length }
126- }
128+ return { event : JSON . parse ( stringifiedData ) , size : stringifiedData . length } ;
129+ }
0 commit comments