@webex/internal-plugin-metrics 1.144.2 → 1.146.1
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.
|
@@ -21,11 +21,25 @@ var _batcher = _interopRequireDefault(require("./batcher"));
|
|
|
21
21
|
*/
|
|
22
22
|
var CallDiagnosticEventsBatcher = _batcher.default.extend({
|
|
23
23
|
namespace: 'Metrics',
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @param {string} webClientDomain
|
|
27
|
+
* @returns {string}
|
|
28
|
+
*/
|
|
29
|
+
getBuildType: function getBuildType(webClientDomain) {
|
|
30
|
+
if (webClientDomain !== null && webClientDomain !== void 0 && webClientDomain.includes('teams.webex.com') || webClientDomain !== null && webClientDomain !== void 0 && webClientDomain.includes('localhost') || webClientDomain !== null && webClientDomain !== void 0 && webClientDomain.includes('127.0.0.1') || process.env.NODE_ENV !== 'production') {
|
|
31
|
+
return 'test';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return process.env.NODE_ENV === 'production' ? 'prod' : 'test';
|
|
35
|
+
},
|
|
24
36
|
prepareItem: function prepareItem(item) {
|
|
37
|
+
var _item$event, _item$event$eventData;
|
|
38
|
+
|
|
25
39
|
// networkType should be a enum value: `wifi`, `ethernet`, `cellular`, or `unknown`.
|
|
26
40
|
// Browsers cannot provide such information right now. However, it is a required field.
|
|
27
41
|
var origin = {
|
|
28
|
-
buildType:
|
|
42
|
+
buildType: this.getBuildType((_item$event = item.event) === null || _item$event === void 0 ? void 0 : (_item$event$eventData = _item$event.eventData) === null || _item$event$eventData === void 0 ? void 0 : _item$event$eventData.webClientDomain),
|
|
29
43
|
networkType: 'unknown'
|
|
30
44
|
};
|
|
31
45
|
item.eventPayload.origin = (0, _assign.default)(origin, item.eventPayload.origin);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["call-diagnostic-events-batcher.js"],"names":["CallDiagnosticEventsBatcher","Batcher","extend","namespace","prepareItem","item","origin","buildType","
|
|
1
|
+
{"version":3,"sources":["call-diagnostic-events-batcher.js"],"names":["CallDiagnosticEventsBatcher","Batcher","extend","namespace","getBuildType","webClientDomain","includes","process","env","NODE_ENV","prepareItem","item","origin","buildType","event","eventData","networkType","eventPayload","resolve","prepareRequest","queue","forEach","originTime","sent","Date","toISOString","submitHttpRequest","payload","webex","request","method","service","resource","body","metrics"],"mappings":";;;;;;;;;;;;;;;;AAIA;;AAJA;AACA;AACA;AAIA,IAAMA,2BAA2B,GAAGC,iBAAQC,MAAR,CAAe;AACjDC,EAAAA,SAAS,EAAE,SADsC;;AAGjD;AACF;AACA;AACA;AACEC,EAAAA,YAPiD,wBAOpCC,eAPoC,EAOnB;AAC5B,QACEA,eAAe,SAAf,IAAAA,eAAe,WAAf,IAAAA,eAAe,CAAEC,QAAjB,CAA0B,iBAA1B,KACAD,eADA,aACAA,eADA,eACAA,eAAe,CAAEC,QAAjB,CAA0B,WAA1B,CADA,IAEAD,eAFA,aAEAA,eAFA,eAEAA,eAAe,CAAEC,QAAjB,CAA0B,WAA1B,CAFA,IAGAC,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAJ3B,EAKE;AACA,aAAO,MAAP;AACD;;AAED,WAAOF,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAAzB,GAAwC,MAAxC,GAAiD,MAAxD;AACD,GAlBgD;AAoBjDC,EAAAA,WApBiD,uBAoBrCC,IApBqC,EAoB/B;AAAA;;AAChB;AACA;AACA,QAAMC,MAAM,GAAG;AACbC,MAAAA,SAAS,EAAE,KAAKT,YAAL,gBAAkBO,IAAI,CAACG,KAAvB,yEAAkB,YAAYC,SAA9B,0DAAkB,sBAAuBV,eAAzC,CADE;AAEbW,MAAAA,WAAW,EAAE;AAFA,KAAf;AAKAL,IAAAA,IAAI,CAACM,YAAL,CAAkBL,MAAlB,GAA2B,qBAAcA,MAAd,EAAsBD,IAAI,CAACM,YAAL,CAAkBL,MAAxC,CAA3B;AAEA,WAAO,iBAAQM,OAAR,CAAgBP,IAAhB,CAAP;AACD,GA/BgD;AAiCjDQ,EAAAA,cAjCiD,0BAiClCC,KAjCkC,EAiC3B;AACpB;AACAA,IAAAA,KAAK,CAACC,OAAN,CAAc,UAACV,IAAD,EAAU;AACtBA,MAAAA,IAAI,CAACM,YAAL,CAAkBK,UAAlB,GAA+BX,IAAI,CAACM,YAAL,CAAkBK,UAAlB,IAAgC,EAA/D;AACAX,MAAAA,IAAI,CAACM,YAAL,CAAkBK,UAAlB,CAA6BC,IAA7B,GAAoC,IAAIC,IAAJ,GAAWC,WAAX,EAApC;AACD,KAHD;AAKA,WAAO,iBAAQP,OAAR,CAAgBE,KAAhB,CAAP;AACD,GAzCgD;AA2CjDM,EAAAA,iBA3CiD,6BA2C/BC,OA3C+B,EA2CtB;AACzB,WAAO,KAAKC,KAAL,CAAWC,OAAX,CAAmB;AACxBC,MAAAA,MAAM,EAAE,MADgB;AAExBC,MAAAA,OAAO,EAAE,SAFe;AAGxBC,MAAAA,QAAQ,EAAE,eAHc;AAIxBC,MAAAA,IAAI,EAAE;AACJC,QAAAA,OAAO,EAAEP;AADL;AAJkB,KAAnB,CAAP;AAQD;AApDgD,CAAf,CAApC;;eAuDe3B,2B","sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport Batcher from './batcher';\n\nconst CallDiagnosticEventsBatcher = Batcher.extend({\n namespace: 'Metrics',\n\n /**\n * @param {string} webClientDomain\n * @returns {string}\n */\n getBuildType(webClientDomain) {\n if (\n webClientDomain?.includes('teams.webex.com') ||\n webClientDomain?.includes('localhost') ||\n webClientDomain?.includes('127.0.0.1') ||\n process.env.NODE_ENV !== 'production'\n ) {\n return 'test';\n }\n\n return process.env.NODE_ENV === 'production' ? 'prod' : 'test';\n },\n\n prepareItem(item) {\n // networkType should be a enum value: `wifi`, `ethernet`, `cellular`, or `unknown`.\n // Browsers cannot provide such information right now. However, it is a required field.\n const origin = {\n buildType: this.getBuildType(item.event?.eventData?.webClientDomain),\n networkType: 'unknown'\n };\n\n item.eventPayload.origin = Object.assign(origin, item.eventPayload.origin);\n\n return Promise.resolve(item);\n },\n\n prepareRequest(queue) {\n // Add sent timestamp\n queue.forEach((item) => {\n item.eventPayload.originTime = item.eventPayload.originTime || {};\n item.eventPayload.originTime.sent = new Date().toISOString();\n });\n\n return Promise.resolve(queue);\n },\n\n submitHttpRequest(payload) {\n return this.webex.request({\n method: 'POST',\n service: 'metrics',\n resource: 'clientmetrics',\n body: {\n metrics: payload\n }\n });\n }\n});\n\nexport default CallDiagnosticEventsBatcher;\n"]}
|
package/dist/metrics.js
CHANGED
|
@@ -135,7 +135,7 @@ var Metrics = _webexCore.WebexPlugin.extend((_dec = (0, _common.deprecated)('Met
|
|
|
135
135
|
};
|
|
136
136
|
return this.callDiagnosticEventsBatcher.request(event);
|
|
137
137
|
},
|
|
138
|
-
version: "1.
|
|
138
|
+
version: "1.146.1"
|
|
139
139
|
}, ((0, _applyDecoratedDescriptor2.default)(_obj, "sendUnstructured", [_dec], (0, _getOwnPropertyDescriptor.default)(_obj, "sendUnstructured"), _obj)), _obj)));
|
|
140
140
|
|
|
141
141
|
var _default = Metrics;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/internal-plugin-metrics",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.146.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Ian W. Remmel <iremmel@cisco.com>",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@babel/runtime-corejs2": "^7.14.8",
|
|
20
|
-
"@webex/internal-plugin-device": "1.
|
|
21
|
-
"@webex/webex-core": "1.
|
|
22
|
-
"@webex/common": "1.
|
|
23
|
-
"@webex/common-timers": "1.
|
|
20
|
+
"@webex/internal-plugin-device": "1.146.1",
|
|
21
|
+
"@webex/webex-core": "1.146.1",
|
|
22
|
+
"@webex/common": "1.146.1",
|
|
23
|
+
"@webex/common-timers": "1.146.1",
|
|
24
24
|
"envify": "^4.1.0"
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -7,11 +7,28 @@ import Batcher from './batcher';
|
|
|
7
7
|
const CallDiagnosticEventsBatcher = Batcher.extend({
|
|
8
8
|
namespace: 'Metrics',
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @param {string} webClientDomain
|
|
12
|
+
* @returns {string}
|
|
13
|
+
*/
|
|
14
|
+
getBuildType(webClientDomain) {
|
|
15
|
+
if (
|
|
16
|
+
webClientDomain?.includes('teams.webex.com') ||
|
|
17
|
+
webClientDomain?.includes('localhost') ||
|
|
18
|
+
webClientDomain?.includes('127.0.0.1') ||
|
|
19
|
+
process.env.NODE_ENV !== 'production'
|
|
20
|
+
) {
|
|
21
|
+
return 'test';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return process.env.NODE_ENV === 'production' ? 'prod' : 'test';
|
|
25
|
+
},
|
|
26
|
+
|
|
10
27
|
prepareItem(item) {
|
|
11
28
|
// networkType should be a enum value: `wifi`, `ethernet`, `cellular`, or `unknown`.
|
|
12
29
|
// Browsers cannot provide such information right now. However, it is a required field.
|
|
13
30
|
const origin = {
|
|
14
|
-
buildType:
|
|
31
|
+
buildType: this.getBuildType(item.event?.eventData?.webClientDomain),
|
|
15
32
|
networkType: 'unknown'
|
|
16
33
|
};
|
|
17
34
|
|
|
@@ -239,6 +239,78 @@ describe('plugin-metrics', () => {
|
|
|
239
239
|
assert.property(metric.eventPayload.origin, 'buildType');
|
|
240
240
|
assert.property(metric.eventPayload.origin, 'networkType');
|
|
241
241
|
assert.property(metric.eventPayload.originTime, 'sent');
|
|
242
|
+
assert.equal(metric.eventPayload.origin.buildType, 'test');
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it('submits a call diagnostic event with buildType set in the payload', () => {
|
|
247
|
+
const promise = metrics.submitCallDiagnosticEvents({
|
|
248
|
+
...mockCallDiagnosticEvent,
|
|
249
|
+
origin: {
|
|
250
|
+
buildType: 'prod'
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
return promiseTick(50)
|
|
255
|
+
.then(() => clock.tick(config.metrics.batcherWait))
|
|
256
|
+
.then(() => promise)
|
|
257
|
+
.then(() => {
|
|
258
|
+
assert.calledOnce(webex.request);
|
|
259
|
+
const req = webex.request.args[0][0];
|
|
260
|
+
const metric = req.body.metrics[0];
|
|
261
|
+
|
|
262
|
+
assert.property(metric.eventPayload, 'origin');
|
|
263
|
+
assert.property(metric.eventPayload, 'originTime');
|
|
264
|
+
assert.property(metric.eventPayload.origin, 'buildType');
|
|
265
|
+
assert.property(metric.eventPayload.origin, 'networkType');
|
|
266
|
+
assert.property(metric.eventPayload.originTime, 'sent');
|
|
267
|
+
assert.equal(metric.eventPayload.origin.buildType, 'prod');
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
xit('submits a call diagnostic event with a test domain', () => {
|
|
272
|
+
global.window.location.hostname = 'test.webex.com';
|
|
273
|
+
|
|
274
|
+
const promise = metrics.submitCallDiagnosticEvents(mockCallDiagnosticEvent);
|
|
275
|
+
|
|
276
|
+
return promiseTick(50)
|
|
277
|
+
.then(() => clock.tick(config.metrics.batcherWait))
|
|
278
|
+
.then(() => promise)
|
|
279
|
+
.then(() => {
|
|
280
|
+
assert.calledOnce(webex.request);
|
|
281
|
+
const req = webex.request.args[0][0];
|
|
282
|
+
const metric = req.body.metrics[0];
|
|
283
|
+
|
|
284
|
+
assert.property(metric.eventPayload, 'origin');
|
|
285
|
+
assert.property(metric.eventPayload, 'originTime');
|
|
286
|
+
assert.property(metric.eventPayload.origin, 'buildType');
|
|
287
|
+
assert.property(metric.eventPayload.origin, 'networkType');
|
|
288
|
+
assert.property(metric.eventPayload.originTime, 'sent');
|
|
289
|
+
assert.equal(metric.eventPayload.origin.buildType, 'test');
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// Skip because it's current unable to overwrite NODE_ENV
|
|
294
|
+
// However doing `NODE_ENV=test npm run test ...` will get this test case to pass
|
|
295
|
+
xit('submits a call diagnostic event with a NODE_ENV=production', () => {
|
|
296
|
+
process.env.NODE_ENV = 'production';
|
|
297
|
+
|
|
298
|
+
const promise = metrics.submitCallDiagnosticEvents(mockCallDiagnosticEvent);
|
|
299
|
+
|
|
300
|
+
return promiseTick(50)
|
|
301
|
+
.then(() => clock.tick(config.metrics.batcherWait))
|
|
302
|
+
.then(() => promise)
|
|
303
|
+
.then(() => {
|
|
304
|
+
assert.calledOnce(webex.request);
|
|
305
|
+
const req = webex.request.args[0][0];
|
|
306
|
+
const metric = req.body.metrics[0];
|
|
307
|
+
|
|
308
|
+
assert.property(metric.eventPayload, 'origin');
|
|
309
|
+
assert.property(metric.eventPayload, 'originTime');
|
|
310
|
+
assert.property(metric.eventPayload.origin, 'buildType');
|
|
311
|
+
assert.property(metric.eventPayload.origin, 'networkType');
|
|
312
|
+
assert.property(metric.eventPayload.originTime, 'sent');
|
|
313
|
+
assert.equal(metric.eventPayload.origin.buildType, 'prod');
|
|
242
314
|
});
|
|
243
315
|
});
|
|
244
316
|
});
|