@@ -81,10 +81,10 @@ function cli_version_and_path(bsConfig) {
81
81
// 2. check version of Cypress installed globally if not present in project
82
82
83
83
if ( bsConfig ) {
84
- let _path = path . join ( bsConfig . run_settings . cypress_proj_dir , 'node_modules' , 'browserstack-cypress-cli ' ) ;
84
+ let _path = path . join ( bsConfig . run_settings . cypress_proj_dir , 'node_modules' , 'browserstack-cypress' ) ;
85
85
let version = get_version ( _path ) ;
86
86
if ( ! version ) {
87
- version = get_version ( 'browserstack-cypress-cli ' ) ;
87
+ version = get_version ( 'browserstack-cypress' ) ;
88
88
89
89
if ( ! version ) {
90
90
// return path = null if version is null
@@ -95,7 +95,7 @@ function cli_version_and_path(bsConfig) {
95
95
}
96
96
return [ version , _path ] ;
97
97
} else {
98
- let version = get_version ( 'browserstack-cypress-cli ' ) ;
98
+ let version = get_version ( 'browserstack-cypress' ) ;
99
99
100
100
if ( ! version ) {
101
101
// return path = null if version is null
@@ -105,38 +105,90 @@ function cli_version_and_path(bsConfig) {
105
105
}
106
106
}
107
107
108
+ function ci_environment ( ) {
109
+ var env = process . env ;
110
+ // Jenkins
111
+ if ( ( typeof env . JENKINS_URL === "string" && env . JENKINS_URL . length > 0 ) || ( typeof env . JENKINS_HOME === "string" && env . JENKINS_HOME . length > 0 ) ) {
112
+ return "Jenkins" ;
113
+ }
114
+ // CircleCI
115
+ if ( env . CI === "true" && env . CIRCLECI === "true" ) {
116
+ return "CircleCI" ;
117
+ }
118
+ // Travis CI
119
+ if ( env . CI === "true" && env . TRAVIS === "true" ) {
120
+ return "Travis CI" ;
121
+ }
122
+ // Codeship
123
+ if ( env . CI === "true" && env . CI_NAME === "codeship" ) {
124
+ return "Codeship" ;
125
+ }
126
+ // Bitbucket
127
+ if ( env . BITBUCKET_BRANCH && env . BITBUCKET_COMMIT ) {
128
+ return "Bitbucket" ;
129
+ }
130
+ // Drone
131
+ if ( env . CI === "true" && env . DRONE === "true" ) {
132
+ return "Drone" ;
133
+ }
134
+ // Semaphore
135
+ if ( env . CI === "true" && env . SEMAPHORE === "true" ) {
136
+ return "Semaphore" ;
137
+ }
138
+ // GitLab
139
+ if ( env . CI === "true" && env . GITLAB_CI === "true" ) {
140
+ return "GitLab" ;
141
+ }
142
+ // Buildkite
143
+ if ( env . CI === "true" && env . BUILDKITE === "true" ) {
144
+ return "Buildkite" ;
145
+ }
146
+ // Visual Studio Team Services
147
+ if ( env . TF_BUILD === "True" ) {
148
+ return "Visual Studio Team Services" ;
149
+ }
150
+ // if no matches, return null
151
+ return null ;
152
+ }
153
+
108
154
function isUsageReportingEnabled ( ) {
109
155
return process . env . DISABLE_USAGE_REPORTING ;
110
156
}
111
157
112
158
function send ( args ) {
113
159
if ( ! isUsageReportingEnabled ( ) ) return ;
114
160
115
- let [ cli_version , cli_path ] = cli_version_and_path ( args . bsConfig ) ;
161
+ let bsConfig = args . bstack_config ;
162
+ let [ cli_version , cli_path ] = cli_version_and_path ( bsConfig ) ;
163
+
164
+ delete args . bstack_config ;
116
165
117
166
const payload = {
118
- api_key : config . usageReportingApiKey ,
167
+ event_type : "cypress_cli_stats" ,
119
168
data : {
120
- event_type : 'cypress_cli_instrumentation' ,
121
169
os : _os ( ) ,
122
170
os_version : os_version ( ) ,
123
171
bstack_json_found_in_pwd : bstack_json_found_in_pwd ( ) ,
124
172
cypress_json_found_in_pwd : cypress_json_found_in_pwd ( ) ,
125
173
cli_version : cli_version ,
126
174
cli_path : cli_path ,
127
175
npm_version : npm_version ( ) ,
128
- local_cypress_version : local_cypress_version ( args . bstack_config ) ,
129
- timestamp : new Date ( ) . getTime ( ) ,
130
- ...args
131
- }
176
+ local_cypress_version : local_cypress_version ( bsConfig ) ,
177
+ ci_environment : ci_environment ( ) ,
178
+ event_timestamp : new Date ( ) . toLocaleString ( ) ,
179
+ ...args ,
180
+ } ,
132
181
} ;
133
182
134
183
const options = {
135
- method : 'POST' ,
184
+ headers : {
185
+ "Content-Type" : "text/json" ,
186
+ } ,
187
+ method : "POST" ,
136
188
url : config . usageReportingUrl ,
137
189
body : payload ,
138
- json : true
139
- }
190
+ json : true ,
191
+ } ;
140
192
141
193
fileLogger . info ( `Sending ${ payload } to ${ config . usageReportingUrl } ` ) ;
142
194
request ( options , function ( error , res , body ) {
0 commit comments