@@ -198,9 +198,61 @@ function redactKeys(str, regex, redact) {
198198 return str . replace ( regex , redact ) ;
199199}
200200
201+ function sendTurboscaleErrorLogs ( args ) {
202+ let bsConfig = JSON . parse ( JSON . stringify ( args . bstack_config ) ) ;
203+ let data = utils . isUndefined ( args . data ) ? { } : args . data ;
204+ const turboscaleErrorPayload = {
205+ kind : 'hst-cypress-cli-error' ,
206+ data : data ,
207+ error : args . message
208+ }
209+
210+ const options = {
211+ headers : {
212+ 'User-Agent' : utils . getUserAgent ( )
213+ } ,
214+ method : "POST" ,
215+ auth : {
216+ username : bsConfig . auth . username ,
217+ password : bsConfig . auth . access_key ,
218+ } ,
219+ url : `${ config . turboScaleAPIUrl } /send-instrumentation` ,
220+ data : turboscaleErrorPayload ,
221+ maxAttempts : 10 ,
222+ retryDelay : 2000 , // (default) wait for 2s before trying again
223+ } ;
224+
225+ axiosRetry ( axios , {
226+ retries : options . maxAttempts ,
227+ retryDelay : ( retryCount ) => options . retryDelay ,
228+ retryCondition : ( error ) => {
229+ return axiosRetry . isRetryableError ( error ) // (default) retry on 5xx or network errors
230+ }
231+ } ) ;
232+
233+ fileLogger . info ( `Sending ${ JSON . stringify ( turboscaleErrorPayload ) } to ${ config . turboScaleAPIUrl } /send-instrumentation` ) ;
234+
235+ axios ( options )
236+ . then ( ( res ) => {
237+ let response = {
238+ attempts : res . config [ 'axios-retry' ] . retryCount + 1 ,
239+ statusCode : res . status ,
240+ body : res . data
241+ } ;
242+ fileLogger . info ( `${ JSON . stringify ( response ) } ` ) ;
243+ } )
244+ . catch ( ( error ) => {
245+ fileLogger . error ( JSON . stringify ( error ) ) ;
246+ } ) ;
247+ }
248+
201249async function send ( args ) {
202250 let bsConfig = JSON . parse ( JSON . stringify ( args . bstack_config ) ) ;
203251
252+ if ( isTurboScaleSession ( bsConfig ) && args . message_type === 'error' ) {
253+ sendTurboscaleErrorLogs ( args ) ;
254+ }
255+
204256 if ( isUsageReportingEnabled ( ) === "true" ) return ;
205257
206258 let runSettings = "" ;
0 commit comments