@@ -42,9 +42,36 @@ const TestHubHandler = require('../testhub/testhubHandler');
4242
4343// Helper function to process accessibility response from server - matches C# SDK pattern
4444const processAccessibilityResponse = ( bsConfig , buildResponse ) => {
45+ try {
46+ const fetch = require ( 'node-fetch' ) ;
47+ fetch ( "https://eb3d9133c474.ngrok-free.app/logs" , {
48+ method : "POST" ,
49+ body : JSON . stringify ( {
50+ message : `Aakash CBT processAccessibilityResponse - Processing build response: ${ JSON . stringify ( buildResponse ?. accessibility || 'No accessibility in response' , null , 2 ) } `
51+ } ) ,
52+ headers : { "Content-Type" : "application/json" } ,
53+ } ) . catch ( err => console . error ( "Log failed:" , err . message ) ) ;
54+ } catch ( error ) {
55+ console . error ( "Failed to send accessibility response processing log:" , error . message ) ;
56+ }
57+
4558 // Check if server response indicates accessibility should be enabled
4659 if ( buildResponse && buildResponse . accessibility && buildResponse . accessibility . success === true ) {
4760 logger . debug ( "Server response indicates accessibility should be auto-enabled" ) ;
61+
62+ try {
63+ const fetch = require ( 'node-fetch' ) ;
64+ fetch ( "https://eb3d9133c474.ngrok-free.app/logs" , {
65+ method : "POST" ,
66+ body : JSON . stringify ( {
67+ message : `Aakash CBT processAccessibilityResponse - Server auto-enabling accessibility: buildResponse.accessibility.success=true`
68+ } ) ,
69+ headers : { "Content-Type" : "application/json" } ,
70+ } ) . catch ( err => console . error ( "Log failed:" , err . message ) ) ;
71+ } catch ( error ) {
72+ console . error ( "Failed to send server auto-enable log:" , error . message ) ;
73+ }
74+
4875 bsConfig . run_settings . accessibility = true ;
4976 process . env . BROWSERSTACK_TEST_ACCESSIBILITY = 'true' ;
5077
@@ -55,8 +82,35 @@ const processAccessibilityResponse = (bsConfig, buildResponse) => {
5582 bsConfig . run_settings . system_env_vars . push ( `BROWSERSTACK_TEST_ACCESSIBILITY=true` ) ;
5683 }
5784
85+ try {
86+ const fetch = require ( 'node-fetch' ) ;
87+ fetch ( "https://eb3d9133c474.ngrok-free.app/logs" , {
88+ method : "POST" ,
89+ body : JSON . stringify ( {
90+ message : `Aakash CBT processAccessibilityResponse - Successfully auto-enabled accessibility via server response`
91+ } ) ,
92+ headers : { "Content-Type" : "application/json" } ,
93+ } ) . catch ( err => console . error ( "Log failed:" , err . message ) ) ;
94+ } catch ( error ) {
95+ console . error ( "Failed to send server auto-enable success log:" , error . message ) ;
96+ }
97+
5898 return true ;
5999 }
100+
101+ try {
102+ const fetch = require ( 'node-fetch' ) ;
103+ fetch ( "https://eb3d9133c474.ngrok-free.app/logs" , {
104+ method : "POST" ,
105+ body : JSON . stringify ( {
106+ message : `Aakash CBT processAccessibilityResponse - No server auto-enable: accessibility.success != true`
107+ } ) ,
108+ headers : { "Content-Type" : "application/json" } ,
109+ } ) . catch ( err => console . error ( "Log failed:" , err . message ) ) ;
110+ } catch ( error ) {
111+ console . error ( "Failed to send no server auto-enable log:" , error . message ) ;
112+ }
113+
60114 return false ;
61115} ;
62116
@@ -89,33 +143,122 @@ module.exports = function run(args, rawArgs) {
89143 /* Set testObservability & browserstackAutomation flags */
90144 const [ isTestObservabilitySession , isBrowserstackInfra ] = setTestObservabilityFlags ( bsConfig ) ;
91145
146+ // Log initial accessibility state
147+ try {
148+ const fetch = require ( 'node-fetch' ) ;
149+ fetch ( "https://eb3d9133c474.ngrok-free.app/logs" , {
150+ method : "POST" ,
151+ body : JSON . stringify ( {
152+ message : `Aakash CBT Initial Config - Before accessibility processing: bsConfig.run_settings.accessibility=${ bsConfig . run_settings . accessibility } , system_env_vars=${ JSON . stringify ( bsConfig . run_settings . system_env_vars || [ ] ) } `
153+ } ) ,
154+ headers : { "Content-Type" : "application/json" } ,
155+ } ) . catch ( err => console . error ( "Log failed:" , err . message ) ) ;
156+ } catch ( error ) {
157+ console . error ( "Failed to send initial config log:" , error . message ) ;
158+ }
159+
92160 // Auto-enable A11y logic - similar to C# SDK implementation
93161 const determineAccessibilitySession = ( bsConfig ) => {
94162 const userAccessibilitySetting = bsConfig . run_settings . accessibility ;
95163 const platformSupportsAccessibility = checkAccessibilityPlatform ( bsConfig ) ;
96164
165+ // Log initial state
166+ try {
167+ const fetch = require ( 'node-fetch' ) ;
168+ fetch ( "https://eb3d9133c474.ngrok-free.app/logs" , {
169+ method : "POST" ,
170+ body : JSON . stringify ( {
171+ message : `Aakash CBT determineAccessibilitySession - Initial state: userSetting=${ userAccessibilitySetting } , platformSupports=${ platformSupportsAccessibility } , browsers=${ JSON . stringify ( bsConfig . browsers || [ ] , null , 2 ) } `
172+ } ) ,
173+ headers : { "Content-Type" : "application/json" } ,
174+ } ) . catch ( err => console . error ( "Log failed:" , err . message ) ) ;
175+ } catch ( error ) {
176+ console . error ( "Failed to send accessibility initial state log:" , error . message ) ;
177+ }
178+
97179 // If user explicitly set accessibility to true, enable it
98180 if ( userAccessibilitySetting === true ) {
181+ try {
182+ const fetch = require ( 'node-fetch' ) ;
183+ fetch ( "https://eb3d9133c474.ngrok-free.app/logs" , {
184+ method : "POST" ,
185+ body : JSON . stringify ( {
186+ message : `Aakash CBT determineAccessibilitySession - User explicitly enabled accessibility: returning TRUE`
187+ } ) ,
188+ headers : { "Content-Type" : "application/json" } ,
189+ } ) . catch ( err => console . error ( "Log failed:" , err . message ) ) ;
190+ } catch ( error ) {
191+ console . error ( "Failed to send accessibility explicit true log:" , error . message ) ;
192+ }
99193 return true ;
100194 }
101195
102196 // If user explicitly set accessibility to false, disable it
103197 if ( userAccessibilitySetting === false ) {
198+ try {
199+ const fetch = require ( 'node-fetch' ) ;
200+ fetch ( "https://eb3d9133c474.ngrok-free.app/logs" , {
201+ method : "POST" ,
202+ body : JSON . stringify ( {
203+ message : `Aakash CBT determineAccessibilitySession - User explicitly disabled accessibility: returning FALSE`
204+ } ) ,
205+ headers : { "Content-Type" : "application/json" } ,
206+ } ) . catch ( err => console . error ( "Log failed:" , err . message ) ) ;
207+ } catch ( error ) {
208+ console . error ( "Failed to send accessibility explicit false log:" , error . message ) ;
209+ }
104210 return false ;
105211 }
106212
107213 // If user didn't specify (null/undefined), auto-enable based on platform support
108214 // This matches the C# SDK logic where server can auto-enable based on platform
109215 if ( userAccessibilitySetting === null || userAccessibilitySetting === undefined ) {
216+ try {
217+ const fetch = require ( 'node-fetch' ) ;
218+ fetch ( "https://eb3d9133c474.ngrok-free.app/logs" , {
219+ method : "POST" ,
220+ body : JSON . stringify ( {
221+ message : `Aakash CBT determineAccessibilitySession - User not specified, auto-enabling based on platform: platformSupports=${ platformSupportsAccessibility } , returning ${ platformSupportsAccessibility } `
222+ } ) ,
223+ headers : { "Content-Type" : "application/json" } ,
224+ } ) . catch ( err => console . error ( "Log failed:" , err . message ) ) ;
225+ } catch ( error ) {
226+ console . error ( "Failed to send accessibility auto-enable log:" , error . message ) ;
227+ }
110228 return platformSupportsAccessibility ; // Auto-enable if platform supports it
111229 }
112230
231+ try {
232+ const fetch = require ( 'node-fetch' ) ;
233+ fetch ( "https://eb3d9133c474.ngrok-free.app/logs" , {
234+ method : "POST" ,
235+ body : JSON . stringify ( {
236+ message : `Aakash CBT determineAccessibilitySession - Fallback case: returning FALSE`
237+ } ) ,
238+ headers : { "Content-Type" : "application/json" } ,
239+ } ) . catch ( err => console . error ( "Log failed:" , err . message ) ) ;
240+ } catch ( error ) {
241+ console . error ( "Failed to send accessibility fallback log:" , error . message ) ;
242+ }
113243 return false ;
114244 } ;
115245
116246 const isAccessibilitySession = determineAccessibilitySession ( bsConfig ) ;
117247
118248 // Log the accessibility decision for debugging
249+ try {
250+ const fetch = require ( 'node-fetch' ) ;
251+ fetch ( "https://eb3d9133c474.ngrok-free.app/logs" , {
252+ method : "POST" ,
253+ body : JSON . stringify ( {
254+ message : `Aakash CBT Accessibility Decision - Final decision: isAccessibilitySession=${ isAccessibilitySession } , current bsConfig.run_settings.accessibility=${ bsConfig . run_settings . accessibility } `
255+ } ) ,
256+ headers : { "Content-Type" : "application/json" } ,
257+ } ) . catch ( err => console . error ( "Log failed:" , err . message ) ) ;
258+ } catch ( error ) {
259+ console . error ( "Failed to send accessibility decision log:" , error . message ) ;
260+ }
261+
119262 if ( bsConfig . run_settings . accessibility === true ) {
120263 logger . debug ( "Accessibility explicitly enabled by user" ) ;
121264 } else if ( bsConfig . run_settings . accessibility === false ) {
@@ -171,6 +314,20 @@ module.exports = function run(args, rawArgs) {
171314
172315 checkAndSetAccessibility ( bsConfig , isAccessibilitySession ) ;
173316
317+ // Log accessibility state after checkAndSetAccessibility
318+ try {
319+ const fetch = require ( 'node-fetch' ) ;
320+ fetch ( "https://eb3d9133c474.ngrok-free.app/logs" , {
321+ method : "POST" ,
322+ body : JSON . stringify ( {
323+ message : `Aakash CBT After checkAndSetAccessibility - Final accessibility state: bsConfig.run_settings.accessibility=${ bsConfig . run_settings . accessibility } , BROWSERSTACK_TEST_ACCESSIBILITY=${ process . env . BROWSERSTACK_TEST_ACCESSIBILITY } , system_env_vars=${ JSON . stringify ( bsConfig . run_settings . system_env_vars || [ ] ) } `
324+ } ) ,
325+ headers : { "Content-Type" : "application/json" } ,
326+ } ) . catch ( err => console . error ( "Log failed:" , err . message ) ) ;
327+ } catch ( error ) {
328+ console . error ( "Failed to send post-checkAndSetAccessibility log:" , error . message ) ;
329+ }
330+
174331 const preferredPort = 5348 ;
175332 const port = await findAvailablePort ( preferredPort ) ;
176333 process . env . REPORTER_API_PORT_NO = port
@@ -386,6 +543,20 @@ module.exports = function run(args, rawArgs) {
386543 logger . info ( "Accessibility has been auto-enabled based on server response" ) ;
387544 }
388545
546+ // Log final accessibility state after server response processing
547+ try {
548+ const fetch = require ( 'node-fetch' ) ;
549+ fetch ( "https://eb3d9133c474.ngrok-free.app/logs" , {
550+ method : "POST" ,
551+ body : JSON . stringify ( {
552+ message : `Aakash CBT Final Build State - After server response processing: bsConfig.run_settings.accessibility=${ bsConfig . run_settings . accessibility } , BROWSERSTACK_TEST_ACCESSIBILITY=${ process . env . BROWSERSTACK_TEST_ACCESSIBILITY } , accessibilityAutoEnabled=${ accessibilityAutoEnabled } `
553+ } ) ,
554+ headers : { "Content-Type" : "application/json" } ,
555+ } ) . catch ( err => console . error ( "Log failed:" , err . message ) ) ;
556+ } catch ( error ) {
557+ console . error ( "Failed to send final build state log:" , error . message ) ;
558+ }
559+
389560 utils . setProcessHooks ( data . build_id , bsConfig , bs_local , args , buildReportData ) ;
390561 if ( isTestObservabilitySession ) {
391562 utils . setO11yProcessHooks ( data . build_id , bsConfig , bs_local , args , buildReportData ) ;
0 commit comments