@@ -9,14 +9,21 @@ const archiver = require("../helpers/archiver"),
99 utils = require ( "../helpers/utils" ) ,
1010 fileHelpers = require ( "../helpers/fileHelpers" ) ,
1111 syncRunner = require ( "../helpers/syncRunner" ) ,
12- reportGenerator = require ( '../helpers/reporterHTML' ) . reportGenerator ;
12+ reportGenerator = require ( '../helpers/reporterHTML' ) . reportGenerator ,
13+ { initTimeComponents, markBlockStart, markBlockEnd, getTimeComponents} = require ( '../helpers/timeComponents' ) ;
1314
1415module . exports = function run ( args ) {
1516 let bsConfigPath = utils . getConfigPath ( args . cf ) ;
1617 //Delete build_results.txt from log folder if already present.
18+ initTimeComponents ( ) ;
19+ markBlockStart ( 'deleteOldResults' ) ;
1720 utils . deleteResults ( ) ;
21+ markBlockEnd ( 'deleteOldResults' ) ;
1822
23+ markBlockStart ( 'validateBstackJson' ) ;
1924 return utils . validateBstackJson ( bsConfigPath ) . then ( function ( bsConfig ) {
25+ markBlockEnd ( 'validateBstackJson' ) ;
26+ markBlockStart ( 'setConfig' ) ;
2027 utils . setUsageReportingFlag ( bsConfig , args . disableUsageReporting ) ;
2128
2229 utils . setDefaults ( bsConfig , args ) ;
@@ -56,10 +63,13 @@ module.exports = function run(args) {
5663
5764 // set the no-wrap
5865 utils . setNoWrap ( bsConfig , args ) ;
66+ markBlockEnd ( 'setConfig' ) ;
5967
6068 // Validate browserstack.json values and parallels specified via arguments
69+ markBlockStart ( 'validateConfig' ) ;
6170 return capabilityHelper . validate ( bsConfig , args ) . then ( function ( cypressJson ) {
62-
71+ markBlockEnd ( 'validateConfig' ) ;
72+ markBlockStart ( 'preArchiveSteps' ) ;
6373 //get the number of spec files
6474 let specFiles = utils . getNumberOfSpecFiles ( bsConfig , args , cypressJson ) ;
6575
@@ -69,17 +79,29 @@ module.exports = function run(args) {
6979 // warn if specFiles cross our limit
7080 utils . warnSpecLimit ( bsConfig , args , specFiles ) ;
7181
82+ markBlockEnd ( 'preArchiveSteps' ) ;
7283 // Archive the spec files
84+ markBlockStart ( 'zip' ) ;
85+ markBlockStart ( 'zip.archive' ) ;
7386 return archiver . archive ( bsConfig . run_settings , config . fileName , args . exclude ) . then ( function ( data ) {
7487
88+ markBlockEnd ( 'zip.archive' ) ;
7589 // Uploaded zip file
90+ markBlockStart ( 'zip.zipUpload' ) ;
7691 return zipUploader . zipUpload ( bsConfig , config . fileName ) . then ( async function ( zip ) {
92+
93+ markBlockEnd ( 'zip.zipUpload' ) ;
94+ markBlockEnd ( 'zip' ) ;
7795 // Create build
7896
7997 //setup Local Testing
98+ markBlockStart ( 'localSetup' ) ;
8099 let bs_local = await utils . setupLocalTesting ( bsConfig , args ) ;
81-
100+ markBlockEnd ( 'localSetup' ) ;
101+ markBlockStart ( 'createBuild' ) ;
82102 return build . createBuild ( bsConfig , zip ) . then ( function ( data ) {
103+ markBlockEnd ( 'createBuild' ) ;
104+ markBlockEnd ( 'total' ) ;
83105 let message = `${ data . message } ! ${ Constants . userMessages . BUILD_CREATED } with build id: ${ data . build_id } ` ;
84106 let dashboardLink = `${ Constants . userMessages . VISIT_DASHBOARD } ${ data . dashboard_url } ` ;
85107 utils . exportResults ( data . build_id , `${ config . dashboardUrl } ${ data . build_id } ` ) ;
@@ -114,7 +136,19 @@ module.exports = function run(args) {
114136 logger . info ( message ) ;
115137 logger . info ( dashboardLink ) ;
116138 if ( ! args . sync ) logger . info ( Constants . userMessages . EXIT_SYNC_CLI_MESSAGE . replace ( "<build-id>" , data . build_id ) ) ;
117- utils . sendUsageReport ( bsConfig , args , `${ message } \n${ dashboardLink } ` , Constants . messageTypes . SUCCESS , null ) ;
139+ let dataToSend = {
140+ time_components : getTimeComponents ( ) ,
141+ build_id : data . build_id ,
142+ } ;
143+ if ( bsConfig && bsConfig . connection_settings ) {
144+ if ( bsConfig . connection_settings . local_mode ) {
145+ dataToSend . local_mode = bsConfig . connection_settings . local_mode ;
146+ }
147+ if ( bsConfig . connection_settings . usedAutoLocal ) {
148+ dataToSend . used_auto_local = bsConfig . connection_settings . usedAutoLocal ;
149+ }
150+ }
151+ utils . sendUsageReport ( bsConfig , args , `${ message } \n${ dashboardLink } ` , Constants . messageTypes . SUCCESS , null , dataToSend ) ;
118152 return ;
119153 } ) . catch ( async function ( err ) {
120154 // Build creation failed
0 commit comments