Skip to content

Commit

Permalink
PLT-928 Set user agent in requests from Babel and Echo Clients (#37)
Browse files Browse the repository at this point in the history
* Build/Dev changes

* Add User Agent to babel

* Add User Agent to echo

---------

Co-authored-by: Malcolm Landon <[email protected]>
  • Loading branch information
malcyL and Malcolm Landon authored Sep 23, 2024
1 parent b4a5dfd commit 605a208
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 51 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.18.0
23 changes: 0 additions & 23 deletions Dockerfile

This file was deleted.

1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# talis-node
[![build status](https://travis-ci.org/talis/talis-node.svg?branch=master)](https://travis-ci.org/talis/talis-node)

# Development Version - Not For General Use

Expand Down
31 changes: 23 additions & 8 deletions babel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ var _ = require('lodash'),
md5 = require('md5'),
querystring = require('querystring');

var clientVer = require('../package.json').version || 'unknown';

// log severities
var DEBUG = "debug";
var ERROR = "error";
Expand Down Expand Up @@ -35,6 +37,10 @@ var BabelClient = function babelClient(config) {
}

this.config.babel_hostname = this.config.babel_host.split('://', 2)[1];

this.userAgent = (process && _.has(process, ["version", "env.NODE_ENV"])) ? "talis-node/" +
clientVer + " (nodejs/" + process.version + "; NODE_ENV=" +
process.env.NODE_ENV + ")" : "talis-node/" + clientVer;
};

/**
Expand Down Expand Up @@ -71,7 +77,8 @@ BabelClient.prototype.headTargetFeed = function headTargetFeed(target, token, pa
headers: {
'Accept': 'application/json',
'Authorization':'Bearer '+token,
'Host': this.config.babel_hostname
'Host': this.config.babel_hostname,
'User-Agent': this.userAgent,
}
};

Expand Down Expand Up @@ -133,6 +140,7 @@ BabelClient.prototype.getEntireTargetFeed = async function (target, token, hydra
'Accept': 'application/json',
'Authorization':'Bearer '+ token,
'Host': this.config.babel_hostname,
'User-Agent': this.userAgent,
},
};

Expand Down Expand Up @@ -219,7 +227,8 @@ BabelClient.prototype.getTargetFeed = function getTargetFeed(target, token, hydr
headers: {
'Accept': 'application/json',
'Authorization':'Bearer '+token,
'Host': this.config.babel_hostname
'Host': this.config.babel_hostname,
'User-Agent': this.userAgent,
}
};

Expand Down Expand Up @@ -261,7 +270,8 @@ BabelClient.prototype.getFeeds = function getFeeds(feeds, token, callback) {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer ' + token,
'Host': this.config.babel_hostname
'Host': this.config.babel_hostname,
'User-Agent': this.userAgent,
}
};

Expand Down Expand Up @@ -299,7 +309,8 @@ BabelClient.prototype.getAnnotation = function getAnnotation(token, id, callback
headers: {
'Accept': 'application/json',
'Authorization':'Bearer '+token,
'Host': this.config.babel_hostname
'Host': this.config.babel_hostname,
'User-Agent': this.userAgent,
}
};

Expand Down Expand Up @@ -343,7 +354,8 @@ BabelClient.prototype.getAnnotations = function getAnnotations(token, querystrin
headers: {
'Accept': 'application/json',
'Authorization':'Bearer '+token,
'Host': this.config.babel_hostname
'Host': this.config.babel_hostname,
'User-Agent': this.userAgent,
}
};

Expand Down Expand Up @@ -440,7 +452,8 @@ BabelClient.prototype.createAnnotation = function createAnnotation(token, data,
headers: {
'Accept': 'application/json',
'Authorization':'Bearer '+token,
'Host': this.config.babel_hostname
'Host': this.config.babel_hostname,
'User-Agent': this.userAgent,
}
};

Expand Down Expand Up @@ -542,7 +555,8 @@ BabelClient.prototype.updateAnnotation = function updateAnnotation(token, data,
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer ' + token,
'Host': this.config.babel_hostname
'Host': this.config.babel_hostname,
'User-Agent': this.userAgent,
}
};

Expand Down Expand Up @@ -583,7 +597,8 @@ BabelClient.prototype.deleteAnnotation = function deleteAnnotation(token, annota
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer ' + token,
'Host': this.config.babel_hostname
'Host': this.config.babel_hostname,
'User-Agent': this.userAgent,
}
};

Expand Down
Loading

0 comments on commit 605a208

Please sign in to comment.