@@ -21,12 +21,11 @@ export default async function processSnapshot(snapshot: Snapshot, ctx: Context):
2121 url : "" ,
2222 timestamp : "" ,
2323 snapshotUUID : "" ,
24- browsers : {
25- chrome : { }
26- }
24+ browsers : { }
2725 } ;
2826
2927 let globalViewport = ""
28+ let globalBrowser = constants . CHROME
3029 let launchOptions : Record < string , any > = {
3130 headless : isHeadless ,
3231 args : constants . LAUNCH_ARGS
@@ -160,13 +159,19 @@ export default async function processSnapshot(snapshot: Snapshot, ctx: Context):
160159 url : requestUrl ,
161160 resourceType : request . resourceType ( ) ,
162161 }
163- if ( ! discoveryErrors . browsers . chrome ) {
164- discoveryErrors . browsers . chrome = { } ;
162+
163+ if ( ! discoveryErrors . browsers [ globalBrowser ] ) {
164+ discoveryErrors . browsers [ globalBrowser ] = { } ; }
165+
166+ // Check if the discoveryErrors.browsers[globalBrowser] exists, and if not, initialize it
167+ if ( discoveryErrors . browsers [ globalBrowser ] && ! discoveryErrors . browsers [ globalBrowser ] [ globalViewport ] ) {
168+ discoveryErrors . browsers [ globalBrowser ] [ globalViewport ] = [ ] ;
165169 }
166- if ( ! discoveryErrors . browsers . chrome [ globalViewport ] ) {
167- discoveryErrors . browsers . chrome [ globalViewport ] = [ ] ;
170+
171+ // Dynamically push the data into the correct browser and viewport
172+ if ( discoveryErrors . browsers [ globalBrowser ] ) {
173+ discoveryErrors . browsers [ globalBrowser ] [ globalViewport ] ?. push ( data ) ;
168174 }
169- discoveryErrors . browsers . chrome [ globalViewport ] ?. push ( data ) ;
170175
171176 } else {
172177 ctx . log . debug ( `Handling request ${ requestUrl } \n - content-type ${ response . headers ( ) [ 'content-type' ] } ` ) ;
@@ -329,6 +334,11 @@ export default async function processSnapshot(snapshot: Snapshot, ctx: Context):
329334 ctx . log . debug ( `Page resized to ${ viewport . width } x${ viewport . height || MIN_VIEWPORT_HEIGHT } ` ) ;
330335 globalViewport = viewportString ;
331336 ctx . log . debug ( `globalViewport : ${ globalViewport } ` ) ;
337+ if ( globalViewport . toLowerCase ( ) . includes ( "iphone" ) || globalViewport . toLowerCase ( ) . includes ( "ipad" ) ) {
338+ globalBrowser = constants . WEBKIT ;
339+ } else {
340+ globalBrowser = constants . CHROME ;
341+ }
332342
333343 // navigate to snapshot url once
334344 if ( ! navigated ) {
@@ -427,7 +437,7 @@ export default async function processSnapshot(snapshot: Snapshot, ctx: Context):
427437 }
428438
429439 discoveryErrors . timestamp = new Date ( ) . toISOString ( ) ;
430-
440+ ctx . log . error ( discoveryErrors ) ;
431441 return {
432442 processedSnapshot : {
433443 name : snapshot . name ,
0 commit comments