roboto-js 1.8.4 → 1.8.6
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.
- package/.last-build +1 -1
- package/BUILD_NOTES.md +30 -0
- package/babel.config.json +13 -0
- package/dist/cjs/cookie_storage_adaptor.cjs +38 -84
- package/dist/cjs/index.cjs +21 -14
- package/dist/cjs/rbt_api.cjs +34 -97
- package/dist/cjs/rbt_object.cjs +5 -14
- package/dist/cjs/rbt_user.cjs +1 -3
- package/dist/cookie_storage_adaptor.js +415 -0
- package/dist/esm/cookie_storage_adaptor.js +354 -197
- package/dist/esm/index.js +604 -182
- package/dist/esm/rbt_api.js +1976 -1172
- package/dist/esm/rbt_file.js +222 -126
- package/dist/esm/rbt_metrics_api.js +166 -71
- package/dist/esm/rbt_object.js +1014 -708
- package/dist/esm/rbt_user.js +209 -138
- package/dist/index.js +594 -0
- package/dist/rbt_api.js +2115 -0
- package/dist/rbt_file.js +223 -0
- package/dist/rbt_metrics_api.js +200 -0
- package/dist/rbt_object.js +1110 -0
- package/dist/rbt_user.js +235 -0
- package/package.json +4 -3
- package/src/index.js +21 -11
- package/src/rbt_api.js +9 -0
|
@@ -1,8 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _axios = _interopRequireDefault(require("axios"));
|
|
8
|
+
var _eventemitter = _interopRequireDefault(require("eventemitter3"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
11
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
12
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
16
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
17
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
18
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
19
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
20
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
21
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
22
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
23
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
24
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
25
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
26
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
27
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
28
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
3
29
|
function getOrCreateDeviceId() {
|
|
4
30
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
5
|
-
|
|
31
|
+
var deviceId = localStorage.getItem('robotoDeviceId');
|
|
6
32
|
if (!deviceId) {
|
|
7
33
|
// Modern browsers support crypto.randomUUID()
|
|
8
34
|
deviceId = crypto && crypto.randomUUID ? crypto.randomUUID() : Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
@@ -13,24 +39,28 @@ function getOrCreateDeviceId() {
|
|
|
13
39
|
// On server/Node.js, return undefined (or you can fallback to some other logic)
|
|
14
40
|
return undefined;
|
|
15
41
|
}
|
|
16
|
-
|
|
42
|
+
var RbtMetricsApi = exports["default"] = /*#__PURE__*/function (_EventEmitter) {
|
|
43
|
+
_inherits(RbtMetricsApi, _EventEmitter);
|
|
17
44
|
/**
|
|
18
45
|
* You can pass either:
|
|
19
46
|
* - axiosInstance: an existing axios instance (recommended for same-host)
|
|
20
47
|
* - config: { baseUrl, headers, ... } to create a new instance (for different host)
|
|
21
48
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
49
|
+
function RbtMetricsApi() {
|
|
50
|
+
var _this;
|
|
51
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
52
|
+
axiosInstance = _ref.axiosInstance,
|
|
53
|
+
config = _ref.config;
|
|
54
|
+
_classCallCheck(this, RbtMetricsApi);
|
|
55
|
+
_this = _callSuper(this, RbtMetricsApi);
|
|
27
56
|
if (axiosInstance) {
|
|
28
|
-
|
|
57
|
+
_this._axios = axiosInstance;
|
|
29
58
|
} else if (config) {
|
|
30
|
-
|
|
59
|
+
_this._axios = _axios["default"].create(config);
|
|
31
60
|
} else {
|
|
32
61
|
throw new Error("RbtMetricsApi requires either axiosInstance or config");
|
|
33
62
|
}
|
|
63
|
+
return _this;
|
|
34
64
|
}
|
|
35
65
|
|
|
36
66
|
/**
|
|
@@ -51,64 +81,129 @@ export default class RbtMetricsApi extends EventEmitter {
|
|
|
51
81
|
"bar": "baz"
|
|
52
82
|
}
|
|
53
83
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
84
|
+
_createClass(RbtMetricsApi, [{
|
|
85
|
+
key: "sendEvent",
|
|
86
|
+
value: (function () {
|
|
87
|
+
var _sendEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(eventOrObj) {
|
|
88
|
+
var paramsObj,
|
|
89
|
+
payload,
|
|
90
|
+
parts,
|
|
91
|
+
deviceId,
|
|
92
|
+
res,
|
|
93
|
+
summary,
|
|
94
|
+
_err$response,
|
|
95
|
+
_err$response2,
|
|
96
|
+
_err$response3,
|
|
97
|
+
_err$config,
|
|
98
|
+
_err$config2,
|
|
99
|
+
_args = arguments;
|
|
100
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
101
|
+
while (1) switch (_context.prev = _context.next) {
|
|
102
|
+
case 0:
|
|
103
|
+
paramsObj = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
104
|
+
if (!(typeof eventOrObj === 'string')) {
|
|
105
|
+
_context.next = 6;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
parts = eventOrObj.split('.');
|
|
109
|
+
payload = _objectSpread({
|
|
110
|
+
event: eventOrObj,
|
|
111
|
+
category: parts[0] || undefined,
|
|
112
|
+
action: parts[1] || undefined,
|
|
113
|
+
label: parts[2] || undefined
|
|
114
|
+
}, paramsObj);
|
|
115
|
+
_context.next = 11;
|
|
116
|
+
break;
|
|
117
|
+
case 6:
|
|
118
|
+
if (!(_typeof(eventOrObj) === 'object' && eventOrObj !== null)) {
|
|
119
|
+
_context.next = 10;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
payload = eventOrObj;
|
|
123
|
+
_context.next = 11;
|
|
124
|
+
break;
|
|
125
|
+
case 10:
|
|
126
|
+
throw new Error("Invalid arguments to sendEvent");
|
|
127
|
+
case 11:
|
|
128
|
+
// Add deviceId (only if available)
|
|
129
|
+
deviceId = getOrCreateDeviceId();
|
|
130
|
+
if (deviceId) {
|
|
131
|
+
payload.deviceId = deviceId;
|
|
132
|
+
}
|
|
133
|
+
_context.prev = 13;
|
|
134
|
+
_context.next = 16;
|
|
135
|
+
return this._axios.post('/v1/metrics/event', payload);
|
|
136
|
+
case 16:
|
|
137
|
+
res = _context.sent;
|
|
138
|
+
this.emit('sent', payload, res.data);
|
|
139
|
+
return _context.abrupt("return", res.data);
|
|
140
|
+
case 21:
|
|
141
|
+
_context.prev = 21;
|
|
142
|
+
_context.t0 = _context["catch"](13);
|
|
143
|
+
// Summarize Axios errors for clarity
|
|
144
|
+
summary = _context.t0;
|
|
145
|
+
if (_context.t0.isAxiosError) {
|
|
146
|
+
summary = {
|
|
147
|
+
isAxiosError: true,
|
|
148
|
+
message: _context.t0.message,
|
|
149
|
+
status: (_err$response = _context.t0.response) === null || _err$response === void 0 ? void 0 : _err$response.status,
|
|
150
|
+
statusText: (_err$response2 = _context.t0.response) === null || _err$response2 === void 0 ? void 0 : _err$response2.statusText,
|
|
151
|
+
data: (_err$response3 = _context.t0.response) === null || _err$response3 === void 0 ? void 0 : _err$response3.data,
|
|
152
|
+
url: (_err$config = _context.t0.config) === null || _err$config === void 0 ? void 0 : _err$config.url,
|
|
153
|
+
method: (_err$config2 = _context.t0.config) === null || _err$config2 === void 0 ? void 0 : _err$config2.method
|
|
154
|
+
// original: err, // Omit for clean logs, add if you want the raw error for debugging
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
this.emit('error', summary, payload);
|
|
158
|
+
throw summary;
|
|
159
|
+
case 27:
|
|
160
|
+
case "end":
|
|
161
|
+
return _context.stop();
|
|
162
|
+
}
|
|
163
|
+
}, _callee, this, [[13, 21]]);
|
|
164
|
+
}));
|
|
165
|
+
function sendEvent(_x) {
|
|
166
|
+
return _sendEvent.apply(this, arguments);
|
|
94
167
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
168
|
+
return sendEvent;
|
|
169
|
+
}()
|
|
170
|
+
/**
|
|
171
|
+
* Count-based metric event (requires `count` param).
|
|
172
|
+
* Example:
|
|
173
|
+
* roboto.metrics.countEvents("PGPT.Tool.SendSMS", { count: 4, agentId: "ABC" })
|
|
174
|
+
*
|
|
175
|
+
* is equivalent to:
|
|
176
|
+
* roboto.metrics.sendEvent("PGPT.Tool.SendSMS", { count: 4, agentId: "ABC" })
|
|
177
|
+
*/
|
|
178
|
+
)
|
|
179
|
+
}, {
|
|
180
|
+
key: "countEvents",
|
|
181
|
+
value: (function () {
|
|
182
|
+
var _countEvents = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(eventOrObj) {
|
|
183
|
+
var paramsObj,
|
|
184
|
+
_args2 = arguments;
|
|
185
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
186
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
187
|
+
case 0:
|
|
188
|
+
paramsObj = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
|
|
189
|
+
if (!(!paramsObj || typeof paramsObj.count !== 'number')) {
|
|
190
|
+
_context2.next = 3;
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
throw new Error('countEvent requires a count param (number)');
|
|
194
|
+
case 3:
|
|
195
|
+
return _context2.abrupt("return", this.sendEvent(eventOrObj, paramsObj));
|
|
196
|
+
case 4:
|
|
197
|
+
case "end":
|
|
198
|
+
return _context2.stop();
|
|
199
|
+
}
|
|
200
|
+
}, _callee2, this);
|
|
201
|
+
}));
|
|
202
|
+
function countEvents(_x2) {
|
|
203
|
+
return _countEvents.apply(this, arguments);
|
|
204
|
+
}
|
|
205
|
+
return countEvents;
|
|
206
|
+
}())
|
|
207
|
+
}]);
|
|
208
|
+
return RbtMetricsApi;
|
|
209
|
+
}(_eventemitter["default"]);
|