Skip to content

Commit 9323b02

Browse files
authored
Merge pull request #151 from splunk/DVPL-10513
Added 'User-Agent' and 'Splunk-Client' headers in REST API calls for the telemetry
2 parents 7202fec + 7a51d09 commit 9323b02

File tree

8 files changed

+168
-42
lines changed

8 files changed

+168
-42
lines changed

bin/cli.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@
103103
headers: {
104104
"Content-Length": req.headers["content-length"] || 0,
105105
"Content-Type": req.headers["content-type"] || '',
106-
"Authorization": req.headers["authorization"] || ''
106+
"Authorization": req.headers["authorization"] || '',
107+
"User-Agent": "splunk-sdk-javascript/" + SDK_VERSION
107108
},
108109
followAllRedirects: true,
109110
body: body || '',
@@ -488,7 +489,7 @@
488489
fs.writeFileSync(path,code);
489490
console.log("Compiled " + path);
490491
});
491-
492+
492493
};
493494

494495
var outOfDate = function (dependencies, compiled, compiledMin) {

client/splunk.js

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3289,6 +3289,7 @@ module.exports = utils;
32893289
(function() {
32903290
var Http = require('../../http');
32913291
var utils = require('../../utils');
3292+
var SDK_VERSION = require('../../../package.json').version;
32923293

32933294
var root = exports || this;
32943295

@@ -3311,6 +3312,7 @@ module.exports = utils;
33113312
},
33123313

33133314
makeRequest: function(url, message, callback) {
3315+
message.headers["Splunk-Client"] = "splunk-sdk-javascript/" + SDK_VERSION;
33143316
var that = this;
33153317
var params = {
33163318
url: url,
@@ -3354,7 +3356,7 @@ module.exports = utils;
33543356
}
33553357
});
33563358
})();
3357-
},{"../../http":7,"../../utils":25}],22:[function(require,module,exports){
3359+
},{"../../../package.json":280,"../../http":7,"../../utils":25}],22:[function(require,module,exports){
33583360

33593361
// Copyright 2011 Splunk, Inc.
33603362
//
@@ -3373,6 +3375,7 @@ module.exports = utils;
33733375
(function() {
33743376
var Http = require('../../http');
33753377
var utils = require('../../utils');
3378+
var SDK_VERSION = require('../../../package.json').version;
33763379

33773380
var root = exports || this;
33783381

@@ -3442,6 +3445,7 @@ module.exports = utils;
34423445
// as some proxy implementations would rather
34433446
// use this.
34443447
message.headers["X-ProxyDestination"] = url;
3448+
message.headers["Splunk-Client"] = "splunk-sdk-javascript/" + SDK_VERSION;
34453449

34463450
// Need to remove the hostname from the URL
34473451
var parsed = parseUri(url);
@@ -3517,7 +3521,7 @@ module.exports = utils;
35173521
}
35183522
});
35193523
})();
3520-
},{"../../http":7,"../../utils":25}],23:[function(require,module,exports){
3524+
},{"../../../package.json":280,"../../http":7,"../../utils":25}],23:[function(require,module,exports){
35213525
(function (Buffer){(function (){
35223526

35233527
// Copyright 2011 Splunk, Inc.
@@ -3538,6 +3542,7 @@ module.exports = utils;
35383542
var needle = require('needle');
35393543
var Http = require('../../http');
35403544
var utils = require('../../utils');
3545+
var SDK_VERSION = require('../../../package.json').version;
35413546

35423547
var root = exports || this;
35433548

@@ -3561,6 +3566,7 @@ module.exports = utils;
35613566

35623567
// Get the byte-length of the content, which adjusts for multi-byte characters
35633568
request_options.headers["Content-Length"] = Buffer.byteLength(request_options.body, "utf8");
3569+
request_options.headers["User-Agent"] = "splunk-sdk-javascript/" + SDK_VERSION;
35643570

35653571
if(message.query && ["xml", "csv"].includes(message.query.output_mode)){
35663572
request_options.parse_response = false;
@@ -3621,6 +3627,7 @@ module.exports = utils;
36213627

36223628
// Get the byte-length of the content, which adjusts for multi-byte characters
36233629
request_options.headers["Content-Length"] = Buffer.byteLength(request_options.body, "utf8");
3630+
request_options.headers["User-Agent"] = "splunk-sdk-javascript/" + SDK_VERSION;
36243631

36253632
var that = this;
36263633
var response = needle(request_options.method, request_options.url, request_options.body, request_options);
@@ -3635,7 +3642,7 @@ module.exports = utils;
36353642
})();
36363643

36373644
}).call(this)}).call(this,require("buffer").Buffer)
3638-
},{"../../http":7,"../../utils":25,"buffer":81,"needle":195}],24:[function(require,module,exports){
3645+
},{"../../../package.json":280,"../../http":7,"../../utils":25,"buffer":81,"needle":195}],24:[function(require,module,exports){
36393646
/*!*/
36403647
// Copyright 2014 Splunk, Inc.
36413648
//
@@ -32404,7 +32411,7 @@ module.exports={
3240432411
"_args": [
3240532412
[
3240632413
"elliptic@6.5.4",
32407-
"/Users/abhis/Documents/python/splunk-sdk-javascript"
32414+
"/Users/abhis/Documents/GitHub/splunk-sdk-javascript"
3240832415
]
3240932416
],
3241032417
"_development": true,
@@ -32430,7 +32437,7 @@ module.exports={
3243032437
],
3243132438
"_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",
3243232439
"_spec": "6.5.4",
32433-
"_where": "/Users/abhis/Documents/python/splunk-sdk-javascript",
32440+
"_where": "/Users/abhis/Documents/GitHub/splunk-sdk-javascript",
3243432441
"author": {
3243532442
"name": "Fedor Indutny",
3243632443
"email": "fedor@indutny.com"
@@ -42314,7 +42321,7 @@ module.exports={
4231442321
"_args": [
4231542322
[
4231642323
"needle@3.0.0",
42317-
"/Users/abhis/Documents/python/splunk-sdk-javascript"
42324+
"/Users/abhis/Documents/GitHub/splunk-sdk-javascript"
4231842325
]
4231942326
],
4232042327
"_from": "needle@3.0.0",
@@ -42338,7 +42345,7 @@ module.exports={
4233842345
],
4233942346
"_resolved": "https://registry.npmjs.org/needle/-/needle-3.0.0.tgz",
4234042347
"_spec": "3.0.0",
42341-
"_where": "/Users/abhis/Documents/python/splunk-sdk-javascript",
42348+
"_where": "/Users/abhis/Documents/GitHub/splunk-sdk-javascript",
4234242349
"author": {
4234342350
"name": "Tomás Pollak",
4234442351
"email": "tomas@forkhq.com"
@@ -59715,6 +59722,60 @@ function extend() {
5971559722
return target
5971659723
}
5971759724

59725+
},{}],280:[function(require,module,exports){
59726+
module.exports={
59727+
"name": "splunk-sdk",
59728+
"version": "1.11.0",
59729+
"description": "SDK for usage with the Splunk REST API",
59730+
"homepage": "http://dev.splunk.com",
59731+
"main": "index.js",
59732+
"directories": {
59733+
"example": "examples",
59734+
"lib": "lib",
59735+
"test": "tests"
59736+
},
59737+
"repository": {
59738+
"type": "git",
59739+
"url": "http://github.com/splunk/splunk-sdk-javascript.git"
59740+
},
59741+
"keywords": [
59742+
"splunk",
59743+
"data",
59744+
"search",
59745+
"logs",
59746+
"javascript"
59747+
],
59748+
"scripts": {
59749+
"test": "nyc mocha tests/tests.js -t 50000 --allow-uncaught --exit --reporter mochawesome"
59750+
},
59751+
"dependencies": {
59752+
"cookie": "0.4.2",
59753+
"dotenv": "16.0.0",
59754+
"elementtree": "0.1.7",
59755+
"needle": "3.0.0"
59756+
},
59757+
"devDependencies": {
59758+
"browserify": "^17.0.0",
59759+
"chai": "^4.3.6",
59760+
"jshint": "2.13.4",
59761+
"mocha": "7.2.0",
59762+
"mochawesome": "7.1.0",
59763+
"mustache": "4.2.0",
59764+
"nyc": "^15.1.0",
59765+
"readable-stream": "3.6.0",
59766+
"uglify-js": "3.15.2"
59767+
},
59768+
"author": {
59769+
"name": "Splunk",
59770+
"email": "devinfo@splunk.com",
59771+
"url": "http://dev.splunk.com"
59772+
},
59773+
"license": "Apache-2.0",
59774+
"engine": {
59775+
"node": ">=0.8.0"
59776+
}
59777+
}
59778+
5971859779
},{}]},{},[5]);
5971959780

5972059781

client/splunk.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)