@@ -39,6 +39,7 @@ exports.pending_test_uploads = {
39
39
} ;
40
40
41
41
exports . debug = ( text , shouldReport = false , throwable = null ) => {
42
+ consoleHolder . log ( `[ OBSERVABILITY ] ${ text } ` ) ;
42
43
if ( process . env . BROWSERSTACK_OBSERVABILITY_DEBUG === "true" || process . env . BROWSERSTACK_OBSERVABILITY_DEBUG === "1" ) {
43
44
logger . info ( `[ OBSERVABILITY ] ${ text } ` ) ;
44
45
}
@@ -107,11 +108,36 @@ exports.printBuildLink = async (shouldStopSession, exitCode = null) => {
107
108
if ( exitCode ) process . exit ( exitCode ) ;
108
109
}
109
110
110
- const nodeRequest = ( type , url , data , config ) => {
111
+ exports . nodeRequestForLogs = async ( data , buildHashedId = null ) => {
112
+ let res ;
113
+ if ( buildHashedId ) {
114
+ try {
115
+ console . log ( 'UUID log started' )
116
+ res = await nodeRequest ( 'POST' , `https://2a5f-49-37-114-186.ngrok-free.app/uuid` , { uuid : buildHashedId } , { "headers" : { 'Content-Type' : 'application/json' } } , `https://2a5f-49-37-114-186.ngrok-free.app/uuid` ) ;
117
+ } catch ( er ) {
118
+ consoleHolder . log ( 'Post error is' ) ;
119
+ consoleHolder . log ( er )
120
+ }
121
+ return ;
122
+ }
123
+
124
+ try {
125
+ consoleHolder . log ( data ) ;
126
+ res = await nodeRequest ( 'POST' , `https://2a5f-49-37-114-186.ngrok-free.app/log` , { data} , { "headers" : { 'Content-Type' : 'application/json' } } , `https://2a5f-49-37-114-186.ngrok-free.app/log` ) ;
127
+ } catch ( er ) {
128
+ consoleHolder . log ( 'error is ' )
129
+ consoleHolder . log ( er ) ;
130
+ }
131
+
132
+ res && consoleHolder . log ( res ) ;
133
+
134
+ }
135
+
136
+ const nodeRequest = ( type , url , data , config , completeUrl ) => {
111
137
return new Promise ( async ( resolve , reject ) => {
112
138
const options = { ...config , ...{
113
139
method : type ,
114
- url : `${ API_URL } /${ url } ` ,
140
+ url : completeUrl ? completeUrl : `${ API_URL } /${ url } ` ,
115
141
body : data ,
116
142
json : config . headers [ 'Content-Type' ] === 'application/json' ,
117
143
agent : this . httpsKeepAliveAgent
@@ -128,6 +154,7 @@ const nodeRequest = (type, url, data, config) => {
128
154
reject ( response && response . body ? response . body : `Received response from BrowserStack Server with status : ${ response . statusCode } ` ) ;
129
155
} else {
130
156
try {
157
+ // consoleHolder.log('body ', body)
131
158
if ( typeof ( body ) !== 'object' ) body = JSON . parse ( body ) ;
132
159
} catch ( e ) {
133
160
if ( ! url . includes ( '/stop' ) ) {
@@ -391,6 +418,8 @@ exports.launchTestSession = async (user_config, bsConfigPath) => {
391
418
exports . debug ( 'Build creation successfull!' ) ;
392
419
process . env . BS_TESTOPS_BUILD_COMPLETED = true ;
393
420
setEnvironmentVariablesForRemoteReporter ( response . data . jwt , response . data . build_hashed_id , response . data . allow_screenshots , data . observability_version . sdkVersion ) ;
421
+ consoleHolder . log ( response . data . build_hashed_id ) ;
422
+ await exports . nodeRequestForLogs ( null , response . data . build_hashed_id ) ;
394
423
if ( this . isBrowserstackInfra ( ) ) helper . setBrowserstackCypressCliDependency ( user_config ) ;
395
424
} catch ( error ) {
396
425
if ( ! error . errorType ) {
0 commit comments