Skip to content

Commit 67dd517

Browse files
committed
add user-agent while calling api
1 parent 8d9d4d3 commit 67dd517

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

bin/commands/info.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@ function buildInfo(args) {
2020

2121
let options = {
2222
url: config.buildUrl + buildId,
23-
method: 'GET',
23+
method: "GET",
2424
auth: {
2525
user: bsConfig.auth.username,
26-
password: bsConfig.auth.access_key
27-
}
28-
}
26+
password: bsConfig.auth.access_key,
27+
},
28+
headers: {
29+
"User-Agent": util.getUserAgent,
30+
},
31+
};
2932

3033
request(options, function (err, resp, body) {
3134
let message = null;

bin/commands/stop.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@ function buildStop(args) {
2020

2121
let options = {
2222
url: config.buildStopUrl + buildId,
23-
method: 'POST',
23+
method: "POST",
2424
auth: {
2525
user: bsConfig.auth.username,
26-
password: bsConfig.auth.access_key
27-
}
28-
}
26+
password: bsConfig.auth.access_key,
27+
},
28+
headers: {
29+
"User-Agent": util.getUserAgent(),
30+
},
31+
};
2932

3033
request(options, function (err, resp, body) {
3134
let message = null;

bin/helpers/build.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ const request = require('request');
33

44
const config = require('./config'),
55
capabilityHelper = require("../helpers/capabilityHelper"),
6-
Constants = require('../helpers/constants');
6+
Constants = require('../helpers/constants'),
7+
util =require('../helpers/util');
78

89
const createBuild = (bsConfig, zip) => {
910
return new Promise(function (resolve, reject) {
@@ -15,7 +16,8 @@ const createBuild = (bsConfig, zip) => {
1516
password: bsConfig.auth.access_key
1617
},
1718
headers: {
18-
'Content-Type': 'application/json'
19+
'Content-Type': 'application/json',
20+
"User-Agent": util.getUserAgent(),
1921
},
2022
body: data
2123
}

bin/helpers/util.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,7 @@ exports.setUsageReportingFlag = (bsConfig, disableUsageReporting) => {
6767
process.env.DISABLE_USAGE_REPORTING = disableUsageReporting;
6868
}
6969
}
70+
71+
exports.getUserAgent = () => {
72+
return `BStack-Cypress-CLI`;
73+
}

bin/helpers/zipUpload.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ const config = require("./config"),
33
request = require("request"),
44
fs = require("fs"),
55
logger = require("./logger").winstonLogger,
6-
Constants = require("./constants");
6+
Constants = require("./constants"),
7+
util = require("./util");
78

89
const uploadCypressZip = (bsConfig, filePath) => {
910
return new Promise(function (resolve, reject) {
@@ -17,6 +18,9 @@ const uploadCypressZip = (bsConfig, filePath) => {
1718
file: fs.createReadStream(filePath),
1819
filetype: 'zip',
1920
filename: 'tests'
21+
},
22+
headers: {
23+
"User-Agent": util.getUserAgent,
2024
}
2125
}
2226

0 commit comments

Comments
 (0)