@@ -9,7 +9,7 @@ const config = require('./config'),
99 fileLogger = require ( './logger' ) . fileLogger ,
1010 utils = require ( './utils' ) ;
1111
12- const { AUTH_REGEX , REDACTED_AUTH } = require ( "./constants" ) ;
12+ const { AUTH_REGEX , REDACTED_AUTH , REDACTED } = require ( "./constants" ) ;
1313
1414function get_version ( package_name ) {
1515 try {
@@ -172,15 +172,38 @@ function isUsageReportingEnabled() {
172172 return process . env . DISABLE_USAGE_REPORTING ;
173173}
174174
175+ function redactBsConfig ( bsConfig ) {
176+ if ( typeof bsConfig === 'object' && ! utils . isUndefined ( bsConfig . run_settings ) ) {
177+ if ( ! utils . isUndefined ( bsConfig . run_settings [ "projectId" ] ) ) { bsConfig . run_settings [ "projectId" ] = REDACTED }
178+ if ( ! utils . isUndefined ( bsConfig . run_settings [ "record-key" ] ) ) { bsConfig . run_settings [ "record-key" ] = REDACTED }
179+ }
180+ }
181+
182+ function redactArgs ( args ) {
183+ if ( typeof args === 'object' && ! utils . isUndefined ( args . cli_args ) ) {
184+ if ( ! utils . isUndefined ( args . cli_args [ "projectId" ] ) ) { args . cli_args [ "projectId" ] = REDACTED }
185+ if ( ! utils . isUndefined ( args . cli_args [ "project-id" ] ) ) { args . cli_args [ "project-id" ] = REDACTED }
186+ if ( ! utils . isUndefined ( args . cli_args [ "record-key" ] ) ) { args . cli_args [ "record-key" ] = REDACTED }
187+ if ( ! utils . isUndefined ( args . cli_args [ "recordKey" ] ) ) { args . cli_args [ "recordKey" ] = REDACTED }
188+ }
189+ }
190+
191+ function redactRecordCaps ( bsConfig , args ) {
192+ redactBsConfig ( bsConfig ) ;
193+ redactArgs ( args ) ;
194+ }
195+
175196function send ( args ) {
176197 if ( isUsageReportingEnabled ( ) === "true" ) return ;
177198
178199 let bsConfig = JSON . parse ( JSON . stringify ( args . bstack_config ) ) ;
179200 let runSettings = "" ;
180201 let sanitizedbsConfig = "" ;
181202 let cli_details = cli_version_and_path ( bsConfig ) ;
182- let data = utils . isUndefined ( args . data ) ? { } : args . data ;
183203
204+ redactRecordCaps ( bsConfig , args ) ;
205+
206+ let data = utils . isUndefined ( args . data ) ? { } : args . data ;
184207 if ( bsConfig && bsConfig . run_settings ) {
185208 runSettings = bsConfig . run_settings ;
186209 data . cypress_version = bsConfig . run_settings . cypress_version ;
0 commit comments