Skip to content

Commit 32803dd

Browse files
author
Dolev Dotan
committed
Support analytics (metadata and events) in Tradeoff Analytics
1 parent 24075ee commit 32803dd

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "watson-developer-cloud",
3-
"version": "0.9.29",
3+
"version": "0.9.30",
44
"description": "Nodejs Client Wrapper to use the IBM Watson and Services",
55
"main": "./lib/index",
66
"repository": {

services/tradeoff_analytics/v1.js

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,47 @@ function TradeoffAnalytics(options) {
3535
* The resolution contains a set of optimal options,
3636
* their analytical characteristics, and representation on a 2D space.
3737
*
38-
* @param {Array} params.columns List of possible objectives
39-
* @param {String} params.subject Name of the decision problem
40-
* @param {String} params.options A list of options. Typically, the rows in a
38+
* @param {Array} requestBody.columns List of possible objectives
39+
* @param {String} requestBody.subject Name of the decision problem
40+
* @param {String} requestBody.options A list of options. Typically, the rows in a
4141
* table representation of your data
42+
* @param {String} metadataHeader Value of the x-watson-metadata header to be forwarded
43+
* for analytics purposes
4244
*/
43-
TradeoffAnalytics.prototype.dilemmas = function(params, callback) {
45+
TradeoffAnalytics.prototype.dilemmas = function(requestBody, callback, metadataHeader) {
4446
var parameters = {
4547
options: {
4648
method: 'POST',
4749
url: '/v1/dilemmas',
48-
body: params,
49-
json: true,
50+
body: requestBody,
51+
headers: {
52+
'x-watson-metadata' : metadataHeader
53+
},
54+
json: true
5055
},
5156
requiredParams: ['columns', 'subject', 'options'],
5257
defaultOptions: this._options
5358
};
5459
return requestFactory(parameters, callback);
5560
};
5661

62+
/**
63+
* Forward events from the Tradeoff Analytics widget to the service
64+
*/
65+
TradeoffAnalytics.prototype.events = function(requestBody, callback, metadataHeader) {
66+
var parameters = {
67+
options: {
68+
method: 'POST',
69+
url: '/v1/events',
70+
body: requestBody,
71+
headers: {
72+
'x-watson-metadata' : metadataHeader
73+
},
74+
json: true
75+
},
76+
defaultOptions: this._options
77+
};
78+
return requestFactory(parameters, callback);
79+
};
80+
5781
module.exports = TradeoffAnalytics;

0 commit comments

Comments
 (0)