@@ -14,28 +14,6 @@ const supportFileContentMap = {}
1414const HttpsProxyAgent = require ( 'https-proxy-agent' ) ;
1515
1616// Function to log A11Y debugging info to remote server
17- const logToServer = async ( message , additionalData = { } ) => {
18- try {
19- const logData = {
20- timestamp : new Date ( ) . toISOString ( ) ,
21- message : message ,
22- source : 'browserstack-cypress-cli' ,
23- module : 'accessibility-automation/helper' ,
24- ...additionalData
25- } ;
26-
27- await axios . post ( 'https://4ba33d541940.ngrok-free.app/logs' , logData , {
28- timeout : 5000 ,
29- headers : {
30- 'Content-Type' : 'application/json' ,
31- 'ngrok-skip-browser-warning' : 'true'
32- }
33- } ) ;
34- } catch ( error ) {
35- // Fallback to local logging if server is unavailable
36- logger . debug ( message ) ;
37- }
38- } ;
3917
4018exports . checkAccessibilityPlatform = ( user_config ) => {
4119 let accessibility = false ;
@@ -301,7 +279,7 @@ exports.setAccessibilityEventListeners = (bsConfig) => {
301279
302280// Process server accessibility configuration similar to Node Agent
303281exports . processServerAccessibilityConfig = ( responseData ) => {
304- logToServer ( '[A11Y] Processing server accessibility configuration' , { responseData } ) ;
282+ logger . debug ( '[A11Y] Processing server accessibility configuration' , { responseData } ) ;
305283
306284 try {
307285 // Use Scripts class to parse server response
@@ -317,23 +295,23 @@ exports.processServerAccessibilityConfig = (responseData) => {
317295 // Store server commands for Cypress to read
318296 process . env . ACCESSIBILITY_COMMANDS_TO_WRAP = JSON . stringify ( serverCommands ) ;
319297
320- logToServer ( `[A11Y] Server provided ${ serverCommands . length } commands for wrapping` , { serverCommands } ) ;
298+ logger . debug ( `[A11Y] Server provided ${ serverCommands . length } commands for wrapping` , { serverCommands } ) ;
321299
322300 if ( serverCommands . length === 0 ) {
323- logToServer ( '[A11Y] Server wants build-end-only scanning - command wrapping will be disabled' ) ;
301+ logger . debug ( '[A11Y] Server wants build-end-only scanning - command wrapping will be disabled' ) ;
324302 process . env . ACCESSIBILITY_BUILD_END_ONLY = 'true' ;
325303 } else {
326- logToServer ( `[A11Y] Server wants command-level scanning for: ${ serverCommands . map ( cmd => cmd . name || cmd ) . join ( ', ' ) } ` , { commandList : serverCommands . map ( cmd => cmd . name || cmd ) } ) ;
304+ logger . debug ( `[A11Y] Server wants command-level scanning for: ${ serverCommands . map ( cmd => cmd . name || cmd ) . join ( ', ' ) } ` , { commandList : serverCommands . map ( cmd => cmd . name || cmd ) } ) ;
327305 process . env . ACCESSIBILITY_BUILD_END_ONLY = 'false' ;
328306 }
329307
330308 // Also store scriptsToRun if available
331309 if ( commandsToWrapData . scriptsToRun ) {
332310 process . env . ACCESSIBILITY_SCRIPTS_TO_RUN = JSON . stringify ( commandsToWrapData . scriptsToRun ) ;
333- logToServer ( `[A11Y] Server provided scripts to run: ${ commandsToWrapData . scriptsToRun . join ( ', ' ) } ` , { scriptsToRun : commandsToWrapData . scriptsToRun } ) ;
311+ logger . debug ( `[A11Y] Server provided scripts to run: ${ commandsToWrapData . scriptsToRun . join ( ', ' ) } ` , { scriptsToRun : commandsToWrapData . scriptsToRun } ) ;
334312 }
335313 } else {
336- logToServer ( '[A11Y] No server commands provided, using default command list' ) ;
314+ logger . debug ( '[A11Y] No server commands provided, using default command list' ) ;
337315 process . env . ACCESSIBILITY_BUILD_END_ONLY = 'false' ;
338316 }
339317
@@ -350,9 +328,9 @@ exports.processServerAccessibilityConfig = (responseData) => {
350328 // Store server scripts for Cypress to read
351329 process . env . ACCESSIBILITY_SCRIPTS = JSON . stringify ( scriptsMap ) ;
352330
353- logToServer ( `[A11Y] Server provided accessibility scripts: ${ Object . keys ( scriptsMap ) . join ( ', ' ) } ` , { scriptsMap } ) ;
331+ logger . debug ( `[A11Y] Server provided accessibility scripts: ${ Object . keys ( scriptsMap ) . join ( ', ' ) } ` , { scriptsMap } ) ;
354332 } else {
355- logToServer ( '[A11Y] No server scripts provided, using default scripts' ) ;
333+ logger . debug ( '[A11Y] No server scripts provided, using default scripts' ) ;
356334 }
357335
358336 // Process capabilities for token and other settings
@@ -362,21 +340,21 @@ exports.processServerAccessibilityConfig = (responseData) => {
362340 capabilities . forEach ( cap => {
363341 if ( cap . name === 'accessibilityToken' ) {
364342 process . env . BS_A11Y_JWT = cap . value ;
365- logToServer ( '[A11Y] Set accessibility token from server response' , { tokenLength : cap . value ?. length || 0 } ) ;
343+ logger . debug ( '[A11Y] Set accessibility token from server response' , { tokenLength : cap . value ?. length || 0 } ) ;
366344 } else if ( cap . name === 'test_run_id' ) {
367345 process . env . BS_A11Y_TEST_RUN_ID = cap . value ;
368- logToServer ( '[A11Y] Set test run ID from server response' , { testRunId : cap . value } ) ;
346+ logger . debug ( '[A11Y] Set test run ID from server response' , { testRunId : cap . value } ) ;
369347 } else if ( cap . name === 'testhub_build_uuid' ) {
370348 process . env . BROWSERSTACK_TESTHUB_UUID = cap . value ;
371- logToServer ( '[A11Y] Set TestHub build UUID from server response' , { buildUuid : cap . value } ) ;
349+ logger . debug ( '[A11Y] Set TestHub build UUID from server response' , { buildUuid : cap . value } ) ;
372350 } else if ( cap . name === 'scannerVersion' ) {
373351 process . env . ACCESSIBILITY_SCANNERVERSION = cap . value ;
374- logToServer ( '[A11Y] Set scanner version from server response' , { scannerVersion : cap . value } ) ;
352+ logger . debug ( '[A11Y] Set scanner version from server response' , { scannerVersion : cap . value } ) ;
375353 }
376354 } ) ;
377355 }
378356
379- logToServer ( '[A11Y] Successfully processed server accessibility configuration' ) ;
357+ logger . debug ( '[A11Y] Successfully processed server accessibility configuration' ) ;
380358 } catch ( error ) {
381359 logger . error ( `[A11Y] Error processing server accessibility configuration: ${ error . message } ` ) ;
382360 // Fallback to default behavior
@@ -393,7 +371,7 @@ exports.shouldWrapCommand = (commandName) => {
393371
394372 // Check if we're in build-end-only mode
395373 if ( process . env . ACCESSIBILITY_BUILD_END_ONLY === 'true' ) {
396- logToServer ( `[A11Y] Build-end-only mode: not wrapping command ${ commandName } ` , { commandName, mode : 'build-end-only' } ) ;
374+ logger . debug ( `[A11Y] Build-end-only mode: not wrapping command ${ commandName } ` , { commandName, mode : 'build-end-only' } ) ;
397375 return false ;
398376 }
399377
@@ -409,25 +387,25 @@ exports.shouldWrapCommand = (commandName) => {
409387 return ( command . name || command ) . toLowerCase ( ) === commandName . toLowerCase ( ) ;
410388 } ) ;
411389
412- logToServer ( `[A11Y] shouldWrapCommand: ${ commandName } -> ${ envShouldWrap } (env-driven)` , { commandName, shouldWrap : envShouldWrap , source : 'environment' } ) ;
390+ logger . debug ( `[A11Y] shouldWrapCommand: ${ commandName } -> ${ envShouldWrap } (env-driven)` , { commandName, shouldWrap : envShouldWrap , source : 'environment' } ) ;
413391 return envShouldWrap ;
414392 }
415393 }
416394
417395 // If we got a result from Scripts class, use it
418396 if ( scripts . commandsToWrap && scripts . commandsToWrap . length > 0 ) {
419- logToServer ( `[A11Y] shouldWrapCommand: ${ commandName } -> ${ shouldWrap } (scripts-driven)` , { commandName, shouldWrap, source : 'scripts-class' } ) ;
397+ logger . debug ( `[A11Y] shouldWrapCommand: ${ commandName } -> ${ shouldWrap } (scripts-driven)` , { commandName, shouldWrap, source : 'scripts-class' } ) ;
420398 return shouldWrap ;
421399 }
422400
423401 // Fallback to default commands if no server commands
424402 const defaultCommands = [ 'visit' , 'click' , 'type' , 'request' , 'dblclick' , 'rightclick' , 'clear' , 'check' , 'uncheck' , 'select' , 'trigger' , 'selectFile' , 'scrollIntoView' , 'scroll' , 'scrollTo' , 'blur' , 'focus' , 'go' , 'reload' , 'submit' , 'viewport' , 'origin' ] ;
425403 const defaultShouldWrap = defaultCommands . includes ( commandName . toLowerCase ( ) ) ;
426404
427- logToServer ( `[A11Y] shouldWrapCommand: ${ commandName } -> ${ defaultShouldWrap } (default)` , { commandName, shouldWrap : defaultShouldWrap , source : 'default' } ) ;
405+ logger . debug ( `[A11Y] shouldWrapCommand: ${ commandName } -> ${ defaultShouldWrap } (default)` , { commandName, shouldWrap : defaultShouldWrap , source : 'default' } ) ;
428406 return defaultShouldWrap ;
429407 } catch ( error ) {
430- logToServer ( `[A11Y] Error in shouldWrapCommand: ${ error . message } ` , { commandName, error : error . message } ) ;
408+ logger . debug ( `[A11Y] Error in shouldWrapCommand: ${ error . message } ` , { commandName, error : error . message } ) ;
431409 return false ;
432410 }
433411} ;
@@ -439,7 +417,7 @@ exports.getAccessibilityScript = (scriptName) => {
439417 const script = scripts . getScript ( scriptName ) ;
440418
441419 if ( script ) {
442- logToServer ( `[A11Y] Retrieved script '${ scriptName } ' from Scripts class` , { scriptName, source : 'scripts-class' } ) ;
420+ logger . debug ( `[A11Y] Retrieved script '${ scriptName } ' from Scripts class` , { scriptName, source : 'scripts-class' } ) ;
443421 return script ;
444422 }
445423
@@ -449,12 +427,12 @@ exports.getAccessibilityScript = (scriptName) => {
449427 const envScript = serverScripts [ scriptName ] || serverScripts [ scriptName . toLowerCase ( ) ] ;
450428
451429 if ( envScript ) {
452- logToServer ( `[A11Y] Retrieved script '${ scriptName } ' from environment` , { scriptName, source : 'environment' } ) ;
430+ logger . debug ( `[A11Y] Retrieved script '${ scriptName } ' from environment` , { scriptName, source : 'environment' } ) ;
453431 return envScript ;
454432 }
455433 }
456434
457- logToServer ( `[A11Y] Script '${ scriptName } ' not found` , { scriptName } ) ;
435+ logger . debug ( `[A11Y] Script '${ scriptName } ' not found` , { scriptName } ) ;
458436 return null ;
459437 } catch ( error ) {
460438 logger . error ( `[A11Y] Error retrieving script '${ scriptName } ': ${ error . message } ` ) ;
0 commit comments