@@ -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
@@ -128,7 +131,7 @@ module.exports = function run(args, rawArgs) {
128131 utils . setParallels ( bsConfig , args , specFiles . length ) ;
129132
130133 // warn if specFiles cross our limit
131- utils . warnSpecLimit ( bsConfig , args , specFiles , rawArgs ) ;
134+ utils . warnSpecLimit ( bsConfig , args , specFiles , rawArgs , buildReportData ) ;
132135 markBlockEnd ( 'preArchiveSteps' ) ;
133136 logger . debug ( "Completed pre-archive steps" ) ;
134137 markBlockStart ( 'zip' ) ;
@@ -168,7 +171,7 @@ module.exports = function run(args, rawArgs) {
168171 //setup Local Testing
169172 markBlockStart ( 'localSetup' ) ;
170173 logger . debug ( "Started setting up BrowserStack Local connection" ) ;
171- let bs_local = await utils . setupLocalTesting ( bsConfig , args , rawArgs ) ;
174+ let bs_local = await utils . setupLocalTesting ( bsConfig , args , rawArgs , buildReportData ) ;
172175 logger . debug ( 'Completed setting up BrowserStack Local connection' ) ;
173176 markBlockEnd ( 'localSetup' ) ;
174177 logger . debug ( "Started build creation" ) ;
@@ -177,14 +180,10 @@ module.exports = function run(args, rawArgs) {
177180 logger . debug ( "Completed build creation" ) ;
178181 markBlockEnd ( 'createBuild' ) ;
179182 markBlockEnd ( 'total' ) ;
180- utils . setProcessHooks ( data . build_id , bsConfig , bs_local , args ) ;
183+ utils . setProcessHooks ( data . build_id , bsConfig , bs_local , args , buildReportData ) ;
181184 let message = `${ data . message } ! ${ Constants . userMessages . BUILD_CREATED } with build id: ${ data . build_id } ` ;
182185 let dashboardLink = `${ Constants . userMessages . VISIT_DASHBOARD } ${ data . dashboard_url } ` ;
183- let buildReportData = {
184- 'build_id' : data . build_id ,
185- 'user_id' : data . user_id ,
186- 'parallels' : userSpecifiedParallels
187- } ;
186+ buildReportData = { 'build_id' : data . build_id , 'parallels' : userSpecifiedParallels , ...buildReportData }
188187 utils . exportResults ( data . build_id , `${ config . dashboardUrl } ${ data . build_id } ` ) ;
189188 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 ) ) {
190189 logger . warn ( Constants . userMessages . NO_PARALLELS ) ;
@@ -208,11 +207,11 @@ module.exports = function run(args, rawArgs) {
208207
209208 if ( args . sync ) {
210209 logger . debug ( "Started polling build status from BrowserStack" ) ;
211- syncRunner . pollBuildStatus ( bsConfig , data , rawArgs ) . then ( async ( exitCode ) => {
210+ syncRunner . pollBuildStatus ( bsConfig , data , rawArgs , buildReportData ) . then ( async ( exitCode ) => {
212211 logger . debug ( "Completed polling of build status" ) ;
213212
214213 // stop the Local instance
215- await utils . stopLocalBinary ( bsConfig , bs_local , args , rawArgs ) ;
214+ await utils . stopLocalBinary ( bsConfig , bs_local , args , rawArgs , buildReportData ) ;
216215
217216 // waiting for 5 secs for upload to complete (as a safety measure)
218217 await new Promise ( resolve => setTimeout ( resolve , 5000 ) ) ;
@@ -221,11 +220,11 @@ module.exports = function run(args, rawArgs) {
221220 if ( exitCode != Constants . BUILD_FAILED_EXIT_CODE ) {
222221 if ( utils . nonEmptyArray ( bsConfig . run_settings . downloads ) ) {
223222 logger . debug ( "Downloading build artifacts" ) ;
224- await downloadBuildArtifacts ( bsConfig , data . build_id , args , rawArgs ) ;
223+ await downloadBuildArtifacts ( bsConfig , data . build_id , args , rawArgs , buildReportData ) ;
225224 }
226225
227226 // Generate custom report!
228- reportGenerator ( bsConfig , data . build_id , args , rawArgs , function ( ) {
227+ reportGenerator ( bsConfig , data . build_id , args , rawArgs , buildReportData , function ( ) {
229228 utils . sendUsageReport ( bsConfig , args , `${ message } \n${ dashboardLink } ` , Constants . messageTypes . SUCCESS , null , buildReportData , rawArgs ) ;
230229 utils . handleSyncExit ( exitCode , data . dashboard_url ) ;
231230 } ) ;
@@ -299,24 +298,24 @@ module.exports = function run(args, rawArgs) {
299298 // Build creation failed
300299 logger . error ( err ) ;
301300 // stop the Local instance
302- await utils . stopLocalBinary ( bsConfig , bs_local , args , rawArgs ) ;
301+ await utils . stopLocalBinary ( bsConfig , bs_local , args , rawArgs , buildReportData ) ;
303302
304- utils . sendUsageReport ( bsConfig , args , err , Constants . messageTypes . ERROR , 'build_failed' , null , rawArgs ) ;
303+ utils . sendUsageReport ( bsConfig , args , err , Constants . messageTypes . ERROR , 'build_failed' , buildReportData , rawArgs ) ;
305304 process . exitCode = Constants . ERROR_EXIT_CODE ;
306305 } ) ;
307306 } ) . catch ( function ( err ) {
308307 // Zip Upload failed | Local Start failed
309308 logger . error ( err ) ;
310309 if ( err === Constants . userMessages . LOCAL_START_FAILED ) {
311- utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . LOCAL_START_FAILED } ` , Constants . messageTypes . ERROR , 'local_start_failed' , null , rawArgs ) ;
310+ utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . LOCAL_START_FAILED } ` , Constants . messageTypes . ERROR , 'local_start_failed' , buildReportData , rawArgs ) ;
312311 } else {
313312 logger . error ( Constants . userMessages . ZIP_UPLOAD_FAILED ) ;
314313 fileHelpers . deleteZip ( ) ;
315- utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . ZIP_UPLOAD_FAILED } ` , Constants . messageTypes . ERROR , 'zip_upload_failed' , null , rawArgs ) ;
314+ utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . ZIP_UPLOAD_FAILED } ` , Constants . messageTypes . ERROR , 'zip_upload_failed' , buildReportData , rawArgs ) ;
316315 try {
317316 fileHelpers . deletePackageArchieve ( ) ;
318317 } catch ( err ) {
319- utils . sendUsageReport ( bsConfig , args , Constants . userMessages . NPM_DELETE_FAILED , Constants . messageTypes . ERROR , 'npm_deletion_failed' , null , rawArgs ) ;
318+ utils . sendUsageReport ( bsConfig , args , Constants . userMessages . NPM_DELETE_FAILED , Constants . messageTypes . ERROR , 'npm_deletion_failed' , buildReportData , rawArgs ) ;
320319 }
321320 }
322321 process . exitCode = Constants . ERROR_EXIT_CODE ;
@@ -325,36 +324,36 @@ module.exports = function run(args, rawArgs) {
325324 // Zipping failed
326325 logger . error ( err ) ;
327326 logger . error ( Constants . userMessages . FAILED_TO_ZIP ) ;
328- utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . FAILED_TO_ZIP } ` , Constants . messageTypes . ERROR , 'zip_creation_failed' , null , rawArgs ) ;
327+ utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . FAILED_TO_ZIP } ` , Constants . messageTypes . ERROR , 'zip_creation_failed' , buildReportData , rawArgs ) ;
329328 try {
330329 fileHelpers . deleteZip ( ) ;
331330 } catch ( err ) {
332- utils . sendUsageReport ( bsConfig , args , Constants . userMessages . ZIP_DELETE_FAILED , Constants . messageTypes . ERROR , 'zip_deletion_failed' , null , rawArgs ) ;
331+ utils . sendUsageReport ( bsConfig , args , Constants . userMessages . ZIP_DELETE_FAILED , Constants . messageTypes . ERROR , 'zip_deletion_failed' , buildReportData , rawArgs ) ;
333332 }
334333 try {
335334 fileHelpers . deletePackageArchieve ( ) ;
336335 } catch ( err ) {
337- utils . sendUsageReport ( bsConfig , args , Constants . userMessages . NPM_DELETE_FAILED , Constants . messageTypes . ERROR , 'npm_deletion_failed' , null , rawArgs ) ;
336+ utils . sendUsageReport ( bsConfig , args , Constants . userMessages . NPM_DELETE_FAILED , Constants . messageTypes . ERROR , 'npm_deletion_failed' , buildReportData , rawArgs ) ;
338337 }
339338 process . exitCode = Constants . ERROR_EXIT_CODE ;
340339 } ) ;
341340 } ) . catch ( function ( err ) {
342341 // package installer failed
343342 logger . error ( err ) ;
344343 logger . error ( Constants . userMessages . FAILED_CREATE_NPM_ARCHIVE ) ;
345- utils . sendUsageReport ( bsConfig , args , Constants . userMessages . FAILED_CREATE_NPM_ARCHIVE , Constants . messageTypes . ERROR , 'npm_package_archive_failed' , null , rawArgs ) ;
344+ utils . sendUsageReport ( bsConfig , args , Constants . userMessages . FAILED_CREATE_NPM_ARCHIVE , Constants . messageTypes . ERROR , 'npm_package_archive_failed' , buildReportData , rawArgs ) ;
346345 try {
347346 fileHelpers . deletePackageArchieve ( ) ;
348347 } catch ( err ) {
349- utils . sendUsageReport ( bsConfig , args , Constants . userMessages . NPM_DELETE_FAILED , Constants . messageTypes . ERROR , 'npm_deletion_failed' , null , rawArgs ) ;
348+ utils . sendUsageReport ( bsConfig , args , Constants . userMessages . NPM_DELETE_FAILED , Constants . messageTypes . ERROR , 'npm_deletion_failed' , buildReportData , rawArgs ) ;
350349 }
351350 process . exitCode = Constants . ERROR_EXIT_CODE ;
352351 } ) ;
353352 } ) . catch ( function ( err ) {
354353 // md5 check failed
355354 logger . error ( err ) ;
356355 logger . error ( Constants . userMessages . FAILED_MD5_CHECK ) ;
357- utils . sendUsageReport ( bsConfig , args , Constants . userMessages . MD5_CHECK_FAILED , Constants . messageTypes . ERROR , 'zip_already_uploaded_failed' , null , rawArgs ) ;
356+ utils . sendUsageReport ( bsConfig , args , Constants . userMessages . MD5_CHECK_FAILED , Constants . messageTypes . ERROR , 'zip_already_uploaded_failed' , buildReportData , rawArgs ) ;
358357 process . exitCode = Constants . ERROR_EXIT_CODE ;
359358 } ) ;
360359 } ) . catch ( function ( err ) {
@@ -368,7 +367,7 @@ module.exports = function run(args, rawArgs) {
368367 }
369368
370369 let error_code = utils . getErrorCodeFromMsg ( err ) ;
371- utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . validationMessages . NOT_VALID } ` , Constants . messageTypes . ERROR , error_code , null , rawArgs ) ;
370+ utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . validationMessages . NOT_VALID } ` , Constants . messageTypes . ERROR , error_code , buildReportData , rawArgs ) ;
372371 process . exitCode = Constants . ERROR_EXIT_CODE ;
373372 } ) ;
374373 } ) . catch ( function ( err ) {
0 commit comments