@@ -10,6 +10,7 @@ const archiver = require("../helpers/archiver"),
1010 Constants = require ( "../helpers/constants" ) ,
1111 utils = require ( "../helpers/utils" ) ,
1212 fileHelpers = require ( "../helpers/fileHelpers" ) ,
13+ getInitialDetails = require ( '../helpers/getInitialDetails' ) . getInitialDetails ,
1314 syncRunner = require ( "../helpers/syncRunner" ) ,
1415 checkUploaded = require ( "../helpers/checkUploaded" ) ,
1516 packageInstaller = require ( "../helpers/packageInstaller" ) ,
@@ -52,6 +53,8 @@ module.exports = function run(args, rawArgs) {
5253 // accept the access key from command line or env variable if provided
5354 utils . setAccessKey ( bsConfig , args ) ;
5455
56+ let buildReportData = await getInitialDetails ( bsConfig , args , rawArgs ) ;
57+
5558 // accept the build name from command line if provided
5659 utils . setBuildName ( bsConfig , args ) ;
5760
@@ -131,7 +134,7 @@ module.exports = function run(args, rawArgs) {
131134 utils . setParallels ( bsConfig , args , specFiles . length ) ;
132135
133136 // warn if specFiles cross our limit
134- utils . warnSpecLimit ( bsConfig , args , specFiles , rawArgs ) ;
137+ utils . warnSpecLimit ( bsConfig , args , specFiles , rawArgs , buildReportData ) ;
135138 markBlockEnd ( 'preArchiveSteps' ) ;
136139 logger . debug ( "Completed pre-archive steps" ) ;
137140 markBlockStart ( 'zip' ) ;
@@ -171,7 +174,7 @@ module.exports = function run(args, rawArgs) {
171174 //setup Local Testing
172175 markBlockStart ( 'localSetup' ) ;
173176 logger . debug ( "Started setting up BrowserStack Local connection" ) ;
174- let bs_local = await utils . setupLocalTesting ( bsConfig , args , rawArgs ) ;
177+ let bs_local = await utils . setupLocalTesting ( bsConfig , args , rawArgs , buildReportData ) ;
175178 logger . debug ( 'Completed setting up BrowserStack Local connection' ) ;
176179 markBlockEnd ( 'localSetup' ) ;
177180 logger . debug ( "Started build creation" ) ;
@@ -180,14 +183,10 @@ module.exports = function run(args, rawArgs) {
180183 logger . debug ( "Completed build creation" ) ;
181184 markBlockEnd ( 'createBuild' ) ;
182185 markBlockEnd ( 'total' ) ;
183- utils . setProcessHooks ( data . build_id , bsConfig , bs_local , args ) ;
186+ utils . setProcessHooks ( data . build_id , bsConfig , bs_local , args , buildReportData ) ;
184187 let message = `${ data . message } ! ${ Constants . userMessages . BUILD_CREATED } with build id: ${ data . build_id } ` ;
185188 let dashboardLink = `${ Constants . userMessages . VISIT_DASHBOARD } ${ data . dashboard_url } ` ;
186- let buildReportData = {
187- 'build_id' : data . build_id ,
188- 'user_id' : data . user_id ,
189- 'parallels' : userSpecifiedParallels
190- } ;
189+ buildReportData = { 'build_id' : data . build_id , 'parallels' : userSpecifiedParallels , ...buildReportData }
191190 utils . exportResults ( data . build_id , `${ config . dashboardUrl } ${ data . build_id } ` ) ;
192191 if ( ( utils . isUndefined ( bsConfig . run_settings . parallels ) && utils . isUndefined ( args . parallels ) ) || ( ! utils . isUndefined ( bsConfig . run_settings . parallels ) && bsConfig . run_settings . parallels == Constants . cliMessages . RUN . DEFAULT_PARALLEL_MESSAGE ) ) {
193192 logger . warn ( Constants . userMessages . NO_PARALLELS ) ;
@@ -211,11 +210,11 @@ module.exports = function run(args, rawArgs) {
211210
212211 if ( args . sync ) {
213212 logger . debug ( "Started polling build status from BrowserStack" ) ;
214- syncRunner . pollBuildStatus ( bsConfig , data , rawArgs ) . then ( async ( exitCode ) => {
213+ syncRunner . pollBuildStatus ( bsConfig , data , rawArgs , buildReportData ) . then ( async ( exitCode ) => {
215214 logger . debug ( "Completed polling of build status" ) ;
216215
217216 // stop the Local instance
218- await utils . stopLocalBinary ( bsConfig , bs_local , args , rawArgs ) ;
217+ await utils . stopLocalBinary ( bsConfig , bs_local , args , rawArgs , buildReportData ) ;
219218
220219 // waiting for 5 secs for upload to complete (as a safety measure)
221220 await new Promise ( resolve => setTimeout ( resolve , 5000 ) ) ;
@@ -224,11 +223,11 @@ module.exports = function run(args, rawArgs) {
224223 if ( exitCode != Constants . BUILD_FAILED_EXIT_CODE ) {
225224 if ( utils . nonEmptyArray ( bsConfig . run_settings . downloads ) ) {
226225 logger . debug ( "Downloading build artifacts" ) ;
227- await downloadBuildArtifacts ( bsConfig , data . build_id , args , rawArgs ) ;
226+ await downloadBuildArtifacts ( bsConfig , data . build_id , args , rawArgs , buildReportData ) ;
228227 }
229228
230229 // Generate custom report!
231- reportGenerator ( bsConfig , data . build_id , args , rawArgs , function ( ) {
230+ reportGenerator ( bsConfig , data . build_id , args , rawArgs , buildReportData , function ( ) {
232231 utils . sendUsageReport ( bsConfig , args , `${ message } \n${ dashboardLink } ` , Constants . messageTypes . SUCCESS , null , buildReportData , rawArgs ) ;
233232 utils . handleSyncExit ( exitCode , data . dashboard_url ) ;
234233 } ) ;
@@ -302,24 +301,24 @@ module.exports = function run(args, rawArgs) {
302301 // Build creation failed
303302 logger . error ( err ) ;
304303 // stop the Local instance
305- await utils . stopLocalBinary ( bsConfig , bs_local , args , rawArgs ) ;
304+ await utils . stopLocalBinary ( bsConfig , bs_local , args , rawArgs , buildReportData ) ;
306305
307- utils . sendUsageReport ( bsConfig , args , err , Constants . messageTypes . ERROR , 'build_failed' , null , rawArgs ) ;
306+ utils . sendUsageReport ( bsConfig , args , err , Constants . messageTypes . ERROR , 'build_failed' , buildReportData , rawArgs ) ;
308307 process . exitCode = Constants . ERROR_EXIT_CODE ;
309308 } ) ;
310309 } ) . catch ( function ( err ) {
311310 // Zip Upload failed | Local Start failed
312311 logger . error ( err ) ;
313312 if ( err === Constants . userMessages . LOCAL_START_FAILED ) {
314- utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . LOCAL_START_FAILED } ` , Constants . messageTypes . ERROR , 'local_start_failed' , null , rawArgs ) ;
313+ utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . LOCAL_START_FAILED } ` , Constants . messageTypes . ERROR , 'local_start_failed' , buildReportData , rawArgs ) ;
315314 } else {
316315 logger . error ( Constants . userMessages . ZIP_UPLOAD_FAILED ) ;
317316 fileHelpers . deleteZip ( ) ;
318- utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . ZIP_UPLOAD_FAILED } ` , Constants . messageTypes . ERROR , 'zip_upload_failed' , null , rawArgs ) ;
317+ utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . ZIP_UPLOAD_FAILED } ` , Constants . messageTypes . ERROR , 'zip_upload_failed' , buildReportData , rawArgs ) ;
319318 try {
320319 fileHelpers . deletePackageArchieve ( ) ;
321320 } catch ( err ) {
322- utils . sendUsageReport ( bsConfig , args , Constants . userMessages . NPM_DELETE_FAILED , Constants . messageTypes . ERROR , 'npm_deletion_failed' , null , rawArgs ) ;
321+ utils . sendUsageReport ( bsConfig , args , Constants . userMessages . NPM_DELETE_FAILED , Constants . messageTypes . ERROR , 'npm_deletion_failed' , buildReportData , rawArgs ) ;
323322 }
324323 }
325324 process . exitCode = Constants . ERROR_EXIT_CODE ;
@@ -328,36 +327,36 @@ module.exports = function run(args, rawArgs) {
328327 // Zipping failed
329328 logger . error ( err ) ;
330329 logger . error ( Constants . userMessages . FAILED_TO_ZIP ) ;
331- utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . FAILED_TO_ZIP } ` , Constants . messageTypes . ERROR , 'zip_creation_failed' , null , rawArgs ) ;
330+ utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . FAILED_TO_ZIP } ` , Constants . messageTypes . ERROR , 'zip_creation_failed' , buildReportData , rawArgs ) ;
332331 try {
333332 fileHelpers . deleteZip ( ) ;
334333 } catch ( err ) {
335- utils . sendUsageReport ( bsConfig , args , Constants . userMessages . ZIP_DELETE_FAILED , Constants . messageTypes . ERROR , 'zip_deletion_failed' , null , rawArgs ) ;
334+ utils . sendUsageReport ( bsConfig , args , Constants . userMessages . ZIP_DELETE_FAILED , Constants . messageTypes . ERROR , 'zip_deletion_failed' , buildReportData , rawArgs ) ;
336335 }
337336 try {
338337 fileHelpers . deletePackageArchieve ( ) ;
339338 } catch ( err ) {
340- utils . sendUsageReport ( bsConfig , args , Constants . userMessages . NPM_DELETE_FAILED , Constants . messageTypes . ERROR , 'npm_deletion_failed' , null , rawArgs ) ;
339+ utils . sendUsageReport ( bsConfig , args , Constants . userMessages . NPM_DELETE_FAILED , Constants . messageTypes . ERROR , 'npm_deletion_failed' , buildReportData , rawArgs ) ;
341340 }
342341 process . exitCode = Constants . ERROR_EXIT_CODE ;
343342 } ) ;
344343 } ) . catch ( function ( err ) {
345344 // package installer failed
346345 logger . error ( err ) ;
347346 logger . error ( Constants . userMessages . FAILED_CREATE_NPM_ARCHIVE ) ;
348- utils . sendUsageReport ( bsConfig , args , Constants . userMessages . FAILED_CREATE_NPM_ARCHIVE , Constants . messageTypes . ERROR , 'npm_package_archive_failed' , null , rawArgs ) ;
347+ utils . sendUsageReport ( bsConfig , args , Constants . userMessages . FAILED_CREATE_NPM_ARCHIVE , Constants . messageTypes . ERROR , 'npm_package_archive_failed' , buildReportData , rawArgs ) ;
349348 try {
350349 fileHelpers . deletePackageArchieve ( ) ;
351350 } catch ( err ) {
352- utils . sendUsageReport ( bsConfig , args , Constants . userMessages . NPM_DELETE_FAILED , Constants . messageTypes . ERROR , 'npm_deletion_failed' , null , rawArgs ) ;
351+ utils . sendUsageReport ( bsConfig , args , Constants . userMessages . NPM_DELETE_FAILED , Constants . messageTypes . ERROR , 'npm_deletion_failed' , buildReportData , rawArgs ) ;
353352 }
354353 process . exitCode = Constants . ERROR_EXIT_CODE ;
355354 } ) ;
356355 } ) . catch ( function ( err ) {
357356 // md5 check failed
358357 logger . error ( err ) ;
359358 logger . error ( Constants . userMessages . FAILED_MD5_CHECK ) ;
360- utils . sendUsageReport ( bsConfig , args , Constants . userMessages . MD5_CHECK_FAILED , Constants . messageTypes . ERROR , 'zip_already_uploaded_failed' , null , rawArgs ) ;
359+ utils . sendUsageReport ( bsConfig , args , Constants . userMessages . MD5_CHECK_FAILED , Constants . messageTypes . ERROR , 'zip_already_uploaded_failed' , buildReportData , rawArgs ) ;
361360 process . exitCode = Constants . ERROR_EXIT_CODE ;
362361 } ) ;
363362 } ) . catch ( function ( err ) {
@@ -371,7 +370,7 @@ module.exports = function run(args, rawArgs) {
371370 }
372371
373372 let error_code = utils . getErrorCodeFromMsg ( err ) ;
374- utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . validationMessages . NOT_VALID } ` , Constants . messageTypes . ERROR , error_code , null , rawArgs ) ;
373+ utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . validationMessages . NOT_VALID } ` , Constants . messageTypes . ERROR , error_code , buildReportData , rawArgs ) ;
375374 process . exitCode = Constants . ERROR_EXIT_CODE ;
376375 } ) ;
377376 } ) . catch ( function ( err ) {
0 commit comments