Skip to content

Commit

Permalink
fix disable-usage-reporting flag bug
Browse files Browse the repository at this point in the history
  • Loading branch information
nagpalkaran95 committed May 7, 2020
1 parent c1caee0 commit 3f61f91
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions bin/commands/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function buildInfo(args) {
let bsConfigPath = process.cwd() + args.cf;

util.validateBstackJson(bsConfigPath).then(function (bsConfig) {
util.setUsageReportingFlag(bsConfig, args.cf.disableUsageReporting);
util.setUsageReportingFlag(bsConfig, args.disableUsageReporting);

let buildId = args._[1];

Expand Down Expand Up @@ -85,7 +85,7 @@ function buildInfo(args) {
})
}).catch(function (err) {
logger.error(err);
util.setUsageReportingFlag(null, args.cf.disableUsageReporting);
util.setUsageReportingFlag(null, args.disableUsageReporting);
util.sendUsageReport(null, args, err.message, Constants.messageTypes.ERROR, util.getErrorCodeFromErr(err));
})
}
4 changes: 2 additions & 2 deletions bin/commands/runs.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function runCypress(args) {
let bsConfigPath = process.cwd() + args.cf;

util.validateBstackJson(bsConfigPath).then(function (bsConfig) {
util.setUsageReportingFlag(bsConfig, args.cf.disableUsageReporting);
util.setUsageReportingFlag(bsConfig, args.disableUsageReporting);

// Validate browserstack.json values
capabilityHelper.validate(bsConfig).then(function (validated) {
Expand Down Expand Up @@ -77,7 +77,7 @@ function runCypress(args) {
});
}).catch(function (err) {
logger.error(err);
util.setUsageReportingFlag(null, args.cf.disableUsageReporting);
util.setUsageReportingFlag(null, args.disableUsageReporting);
util.sendUsageReport(null, args, err.message, Constants.messageTypes.ERROR, util.getErrorCodeFromErr(err));
})
}
4 changes: 2 additions & 2 deletions bin/commands/stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function buildStop(args) {
let bsConfigPath = process.cwd() + args.cf;

util.validateBstackJson(bsConfigPath).then(function (bsConfig) {
util.setUsageReportingFlag(bsConfig, args.cf.disableUsageReporting);
util.setUsageReportingFlag(bsConfig, args.disableUsageReporting);

let buildId = args._[1];

Expand Down Expand Up @@ -81,7 +81,7 @@ function buildStop(args) {
})
}).catch(function (err) {
logger.error(err);
util.setUsageReportingFlag(null, args.cf.disableUsageReporting);
util.setUsageReportingFlag(null, args.disableUsageReporting);
util.sendUsageReport(null, args, err.message, Constants.messageTypes.ERROR, util.getErrorCodeFromErr(err));
})
}
2 changes: 1 addition & 1 deletion bin/helpers/usageReporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function isUsageReportingEnabled() {
}

function send(args) {
if (!isUsageReportingEnabled()) return;
if (isUsageReportingEnabled() === "true") return;

let bsConfig = args.bstack_config;
let cli_details = cli_version_and_path(bsConfig);
Expand Down
8 changes: 3 additions & 5 deletions bin/helpers/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ exports.sendUsageReport = (bsConfig, args, message, message_type, error_code) =>
}

exports.setUsageReportingFlag = (bsConfig, disableUsageReporting) => {
if (disableUsageReporting === undefined && bsConfig && bsConfig.disable_usage_reporting != undefined) {
process.env.DISABLE_USAGE_REPORTING = bsConfig.disable_usage_reporting;
} else if (!disableUsageReporting) {
process.env.DISABLE_USAGE_REPORTING = false;
if (disableUsageReporting === undefined && bsConfig && bsConfig['disable-usage-reporting'] != undefined) {
process.env.DISABLE_USAGE_REPORTING = bsConfig['disable-usage-reporting'];
} else {
process.env.DISABLE_USAGE_REPORTING = true;
process.env.DISABLE_USAGE_REPORTING = disableUsageReporting;
}
}
3 changes: 2 additions & 1 deletion bin/templates/configTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ module.exports = function () {
"connection_settings": {
"local": false,
"localIdentifier": null
}
},
"disable-usage-reporting": false
}
var EOL = require('os').EOL
var file = [
Expand Down

0 comments on commit 3f61f91

Please sign in to comment.