roboto-js 1.6.13 → 1.6.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -108,7 +108,7 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
108
108
  _createClass(Roboto, [{
109
109
  key: "getVersion",
110
110
  value: function getVersion() {
111
- return '1.6.12';
111
+ return '1.6.15';
112
112
  }
113
113
  }, {
114
114
  key: "setSiteEnv",
@@ -70,7 +70,7 @@ var RbtMetricsApi = exports["default"] = /*#__PURE__*/function (_EventEmitter) {
70
70
  * sendEvent({ event: 'foo', ... });
71
71
  *
72
72
  roboto.metrics.sendEvent("UIMain.userAction.login", { foo: 123, bar: "baz" });
73
- This will POST a payload like:
73
+ This will POST a payload like:
74
74
  {
75
75
  "event": "UIMain.userAction.login",
76
76
  "category": "UIMain",
@@ -126,7 +126,7 @@ var RbtMetricsApi = exports["default"] = /*#__PURE__*/function (_EventEmitter) {
126
126
  }
127
127
  _context.prev = 13;
128
128
  _context.next = 16;
129
- return this._axios.post('/event', payload);
129
+ return this._axios.post('/v1/metrics/event', payload);
130
130
  case 16:
131
131
  res = _context.sent;
132
132
  this.emit('sent', payload, res.data);
@@ -146,6 +146,42 @@ var RbtMetricsApi = exports["default"] = /*#__PURE__*/function (_EventEmitter) {
146
146
  return _sendEvent.apply(this, arguments);
147
147
  }
148
148
  return sendEvent;
149
+ }()
150
+ /**
151
+ * Count-based metric event (requires `count` param).
152
+ * Example:
153
+ * roboto.metrics.countEvent("PGPT.Tool.SendSMS", { count: 4, agentId: "ABC" })
154
+ * is equivalent to:
155
+ * roboto.metrics.sendEvent("PGPT.Tool.SendSMS", { count: 4, agentId: "ABC" })
156
+ */
157
+ )
158
+ }, {
159
+ key: "countEvent",
160
+ value: (function () {
161
+ var _countEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(eventOrObj) {
162
+ var paramsObj,
163
+ _args2 = arguments;
164
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
165
+ while (1) switch (_context2.prev = _context2.next) {
166
+ case 0:
167
+ paramsObj = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
168
+ if (!(!paramsObj || typeof paramsObj.count !== 'number')) {
169
+ _context2.next = 3;
170
+ break;
171
+ }
172
+ throw new Error('countEvent requires a count param (number)');
173
+ case 3:
174
+ return _context2.abrupt("return", this.sendEvent(eventOrObj, paramsObj));
175
+ case 4:
176
+ case "end":
177
+ return _context2.stop();
178
+ }
179
+ }, _callee2, this);
180
+ }));
181
+ function countEvent(_x2) {
182
+ return _countEvent.apply(this, arguments);
183
+ }
184
+ return countEvent;
149
185
  }())
150
186
  }]);
151
187
  return RbtMetricsApi;
package/dist/esm/index.js CHANGED
@@ -8,7 +8,7 @@ export { RbtApi, RbtObject, RbtFile
8
8
  };
9
9
  export default class Roboto {
10
10
  getVersion() {
11
- return '1.6.12';
11
+ return '1.6.15';
12
12
  }
13
13
  constructor({
14
14
  host,
@@ -40,7 +40,7 @@ export default class RbtMetricsApi extends EventEmitter {
40
40
  * sendEvent({ event: 'foo', ... });
41
41
  *
42
42
  roboto.metrics.sendEvent("UIMain.userAction.login", { foo: 123, bar: "baz" });
43
- This will POST a payload like:
43
+ This will POST a payload like:
44
44
  {
45
45
  "event": "UIMain.userAction.login",
46
46
  "category": "UIMain",
@@ -74,7 +74,7 @@ export default class RbtMetricsApi extends EventEmitter {
74
74
  payload.deviceId = deviceId;
75
75
  }
76
76
  try {
77
- const res = await this._axios.post('/event', payload);
77
+ const res = await this._axios.post('/v1/metrics/event', payload);
78
78
  this.emit('sent', payload, res.data);
79
79
  return res.data;
80
80
  } catch (err) {
@@ -82,4 +82,18 @@ export default class RbtMetricsApi extends EventEmitter {
82
82
  throw err;
83
83
  }
84
84
  }
85
+
86
+ /**
87
+ * Count-based metric event (requires `count` param).
88
+ * Example:
89
+ * roboto.metrics.countEvent("PGPT.Tool.SendSMS", { count: 4, agentId: "ABC" })
90
+ * is equivalent to:
91
+ * roboto.metrics.sendEvent("PGPT.Tool.SendSMS", { count: 4, agentId: "ABC" })
92
+ */
93
+ async countEvent(eventOrObj, paramsObj = {}) {
94
+ if (!paramsObj || typeof paramsObj.count !== 'number') {
95
+ throw new Error('countEvent requires a count param (number)');
96
+ }
97
+ return this.sendEvent(eventOrObj, paramsObj);
98
+ }
85
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.6.13",
3
+ "version": "1.6.15",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
package/src/index.js CHANGED
@@ -15,7 +15,7 @@ export {
15
15
  export default class Roboto{
16
16
 
17
17
  getVersion(){
18
- return '1.6.12';
18
+ return '1.6.15';
19
19
  }
20
20
 
21
21
  constructor({ host, accessKey, localStorageAdaptor, disableWebSocket = false, metricsHost }, proxyReq = null) {
@@ -42,6 +42,7 @@ export default class RbtMetricsApi extends EventEmitter {
42
42
  * sendEvent({ event: 'foo', ... });
43
43
  *
44
44
  roboto.metrics.sendEvent("UIMain.userAction.login", { foo: 123, bar: "baz" });
45
+
45
46
  This will POST a payload like:
46
47
  {
47
48
  "event": "UIMain.userAction.login",
@@ -79,7 +80,7 @@ export default class RbtMetricsApi extends EventEmitter {
79
80
  }
80
81
 
81
82
  try {
82
- const res = await this._axios.post('/event', payload);
83
+ const res = await this._axios.post('/v1/metrics/event', payload);
83
84
  this.emit('sent', payload, res.data);
84
85
  return res.data;
85
86
  } catch (err) {
@@ -87,4 +88,19 @@ export default class RbtMetricsApi extends EventEmitter {
87
88
  throw err;
88
89
  }
89
90
  }
91
+
92
+ /**
93
+ * Count-based metric event (requires `count` param).
94
+ * Example:
95
+ * roboto.metrics.countEvent("PGPT.Tool.SendSMS", { count: 4, agentId: "ABC" })
96
+ * is equivalent to:
97
+ * roboto.metrics.sendEvent("PGPT.Tool.SendSMS", { count: 4, agentId: "ABC" })
98
+ */
99
+ async countEvent(eventOrObj, paramsObj = {}) {
100
+ if (!paramsObj || typeof paramsObj.count !== 'number') {
101
+ throw new Error('countEvent requires a count param (number)');
102
+ }
103
+ return this.sendEvent(eventOrObj, paramsObj);
104
+ }
105
+
90
106
  }