@webex/internal-plugin-metrics 3.12.0-next.30 → 3.12.0-next.32
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/dist/call-diagnostic/call-diagnostic-metrics-batcher.js +0 -23
- package/dist/call-diagnostic/call-diagnostic-metrics-batcher.js.map +1 -1
- package/dist/call-diagnostic/call-diagnostic-metrics.js +25 -7
- package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -1
- package/dist/metrics.js +1 -1
- package/dist/prelogin-metrics-batcher.js +0 -23
- package/dist/prelogin-metrics-batcher.js.map +1 -1
- package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +30 -1
- package/package.json +3 -3
- package/src/call-diagnostic/call-diagnostic-metrics-batcher.ts +0 -26
- package/src/call-diagnostic/call-diagnostic-metrics.ts +23 -3
- package/src/prelogin-metrics-batcher.ts +0 -26
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +0 -136
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +75 -2
- package/test/unit/spec/prelogin-metrics-batcher.ts +1 -120
|
@@ -7,7 +7,6 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
10
|
-
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/array/is-array"));
|
|
11
10
|
var _lodash = require("lodash");
|
|
12
11
|
var _batcher = _interopRequireDefault(require("../batcher"));
|
|
13
12
|
var _callDiagnosticMetrics = require("./call-diagnostic-metrics.util");
|
|
@@ -54,33 +53,11 @@ var CallDiagnosticEventsBatcher = _batcher.default.extend({
|
|
|
54
53
|
waitForServiceTimeout: this.webex.config.metrics.waitForServiceTimeout
|
|
55
54
|
}).then(function (res) {
|
|
56
55
|
_this.webex.logger.log(_config.CALL_DIAGNOSTIC_LOG_IDENTIFIER, "CallDiagnosticEventsBatcher: @submitHttpRequest#".concat(batchId, ". Request successful."));
|
|
57
|
-
_this.handleHttpResponseStatus(res === null || res === void 0 ? void 0 : res.statusCode, payload);
|
|
58
56
|
return res;
|
|
59
57
|
}).catch(function (err) {
|
|
60
58
|
_this.webex.logger.error(_config.CALL_DIAGNOSTIC_LOG_IDENTIFIER, "CallDiagnosticEventsBatcher: @submitHttpRequest#".concat(batchId, ". Request failed:"), "error: ".concat((0, _utils.generateCommonErrorMetadata)(err)));
|
|
61
|
-
_this.handleHttpResponseStatus(err === null || err === void 0 ? void 0 : err.statusCode, payload);
|
|
62
59
|
return _promise.default.reject(err);
|
|
63
60
|
});
|
|
64
|
-
},
|
|
65
|
-
/**
|
|
66
|
-
* React to the HTTP status code returned by the metrics endpoint.
|
|
67
|
-
* Only items submitted with `markTelemetryOptOutOnResponse: true` opt into
|
|
68
|
-
* this behavior.
|
|
69
|
-
* @param {number | undefined} statusCode
|
|
70
|
-
* @param {any[]} payload Items flushed in this HTTP batch.
|
|
71
|
-
* @returns {void}
|
|
72
|
-
*/
|
|
73
|
-
handleHttpResponseStatus: function handleHttpResponseStatus(statusCode, payload) {
|
|
74
|
-
var shouldMark = (0, _isArray.default)(payload) && payload.some(function (item) {
|
|
75
|
-
return (item === null || item === void 0 ? void 0 : item.markTelemetryOptOutOnResponse) === true;
|
|
76
|
-
});
|
|
77
|
-
if (!shouldMark) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
if (statusCode === 200) {
|
|
81
|
-
var _this$webex$internal$, _this$webex$internal$2;
|
|
82
|
-
(_this$webex$internal$ = this.webex.internal.newMetrics) === null || _this$webex$internal$ === void 0 ? void 0 : (_this$webex$internal$2 = _this$webex$internal$.callDiagnosticMetrics) === null || _this$webex$internal$2 === void 0 ? void 0 : _this$webex$internal$2.setIsTelemetryOptOutAutomatic(true);
|
|
83
|
-
}
|
|
84
61
|
}
|
|
85
62
|
});
|
|
86
63
|
var _default = exports.default = CallDiagnosticEventsBatcher;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_lodash","require","_batcher","_interopRequireDefault","_callDiagnosticMetrics","_config","_utils","CallDiagnosticEventsBatcher","Batcher","extend","namespace","prepareItem","item","_promise","default","resolve","prepareDiagnosticMetricItem","webex","prepareRequest","queue","forEach","eventPayload","originTime","sent","Date","toISOString","submitHttpRequest","payload","_this","batchId","uniqueId","request","method","service","resource","body","metrics","waitForServiceTimeout","config","then","res","logger","log","CALL_DIAGNOSTIC_LOG_IDENTIFIER","concat","
|
|
1
|
+
{"version":3,"names":["_lodash","require","_batcher","_interopRequireDefault","_callDiagnosticMetrics","_config","_utils","CallDiagnosticEventsBatcher","Batcher","extend","namespace","prepareItem","item","_promise","default","resolve","prepareDiagnosticMetricItem","webex","prepareRequest","queue","forEach","eventPayload","originTime","sent","Date","toISOString","submitHttpRequest","payload","_this","batchId","uniqueId","request","method","service","resource","body","metrics","waitForServiceTimeout","config","then","res","logger","log","CALL_DIAGNOSTIC_LOG_IDENTIFIER","concat","catch","err","error","generateCommonErrorMetadata","reject","_default","exports"],"sources":["call-diagnostic-metrics-batcher.ts"],"sourcesContent":["import {uniqueId} from 'lodash';\nimport Batcher from '../batcher';\nimport {prepareDiagnosticMetricItem} from './call-diagnostic-metrics.util';\nimport {CALL_DIAGNOSTIC_LOG_IDENTIFIER} from './config';\nimport {generateCommonErrorMetadata} from '../utils';\n\nconst CallDiagnosticEventsBatcher = Batcher.extend({\n namespace: 'Metrics',\n\n /**\n * Prepare item\n * @param {any} item\n * @returns {Promise<any>}\n */\n prepareItem(item) {\n return Promise.resolve(prepareDiagnosticMetricItem(this.webex, item));\n },\n\n /**\n * Prepare request, add time sensitive date etc.\n * @param {any[]} queue\n * @returns {Promise<any[]>}\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 /**\n *\n * @param {any} payload\n * @returns {Promise<any>}\n */\n submitHttpRequest(payload) {\n const batchId = uniqueId('ca-batch-');\n\n return this.webex\n .request({\n method: 'POST',\n service: 'metrics',\n resource: 'clientmetrics',\n body: {\n metrics: payload,\n },\n waitForServiceTimeout: this.webex.config.metrics.waitForServiceTimeout,\n })\n .then((res) => {\n this.webex.logger.log(\n CALL_DIAGNOSTIC_LOG_IDENTIFIER,\n `CallDiagnosticEventsBatcher: @submitHttpRequest#${batchId}. Request successful.`\n );\n\n return res;\n })\n .catch((err) => {\n this.webex.logger.error(\n CALL_DIAGNOSTIC_LOG_IDENTIFIER,\n `CallDiagnosticEventsBatcher: @submitHttpRequest#${batchId}. Request failed:`,\n `error: ${generateCommonErrorMetadata(err)}`\n );\n\n return Promise.reject(err);\n });\n },\n});\n\nexport default CallDiagnosticEventsBatcher;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAEA,IAAMM,2BAA2B,GAAGC,gBAAO,CAACC,MAAM,CAAC;EACjDC,SAAS,EAAE,SAAS;EAEpB;AACF;AACA;AACA;AACA;EACEC,WAAW,WAAXA,WAAWA,CAACC,IAAI,EAAE;IAChB,OAAOC,QAAA,CAAAC,OAAA,CAAQC,OAAO,CAAC,IAAAC,kDAA2B,EAAC,IAAI,CAACC,KAAK,EAAEL,IAAI,CAAC,CAAC;EACvE,CAAC;EAED;AACF;AACA;AACA;AACA;EACEM,cAAc,WAAdA,cAAcA,CAACC,KAAK,EAAE;IACpB;IACAA,KAAK,CAACC,OAAO,CAAC,UAACR,IAAI,EAAK;MACtBA,IAAI,CAACS,YAAY,CAACC,UAAU,GAAGV,IAAI,CAACS,YAAY,CAACC,UAAU,IAAI,CAAC,CAAC;MACjEV,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essW
|
|
|
91
91
|
* Prepare the event and send the request to metrics-a service, pre login.
|
|
92
92
|
* @param event
|
|
93
93
|
* @param preLoginId
|
|
94
|
-
* @param markTelemetryOptOutOnResponse
|
|
95
94
|
* @returns
|
|
96
95
|
*/
|
|
97
96
|
(0, _defineProperty2.default)(_this, "submitToCallDiagnosticsPreLogin", function (event, preLoginId) {
|
|
98
97
|
// build metrics-a event type
|
|
99
98
|
var finalEvent = {
|
|
100
99
|
eventPayload: event,
|
|
101
|
-
type: ['diagnostic-event']
|
|
102
|
-
markTelemetryOptOutOnResponse: true
|
|
100
|
+
type: ['diagnostic-event']
|
|
103
101
|
};
|
|
104
102
|
_this.preLoginMetricsBatcher.savePreLoginId(preLoginId);
|
|
105
103
|
return _this.preLoginMetricsBatcher.request(finalEvent);
|
|
@@ -132,6 +130,23 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
|
|
|
132
130
|
return null;
|
|
133
131
|
}
|
|
134
132
|
|
|
133
|
+
/**
|
|
134
|
+
* Returns the user activation state reported from the browser's navigator.userActivation API
|
|
135
|
+
* @returns object with hasBeenActive and isActive booleans, or undefined if unavailable
|
|
136
|
+
*/
|
|
137
|
+
}, {
|
|
138
|
+
key: "getUserActivation",
|
|
139
|
+
value: function getUserActivation() {
|
|
140
|
+
var userActivation = typeof navigator !== 'undefined' ? navigator.userActivation : undefined;
|
|
141
|
+
if (userActivation) {
|
|
142
|
+
return {
|
|
143
|
+
hasBeenActive: userActivation.hasBeenActive,
|
|
144
|
+
isActive: userActivation.isActive
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
|
|
135
150
|
/**
|
|
136
151
|
* Returns the telemetryOptOut value of the current user
|
|
137
152
|
* @returns one of 'manual', 'automatic', undefined
|
|
@@ -956,7 +971,9 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
|
|
|
956
971
|
// @ts-ignore
|
|
957
972
|
webClientPreload: (_this$webex$meetings2 = this.webex.meetings) === null || _this$webex$meetings2 === void 0 ? void 0 : (_this$webex$meetings3 = _this$webex$meetings2.config) === null || _this$webex$meetings3 === void 0 ? void 0 : (_this$webex$meetings4 = _this$webex$meetings3.metrics) === null || _this$webex$meetings4 === void 0 ? void 0 : _this$webex$meetings4.webClientPreload,
|
|
958
973
|
isVipMeeting: (meeting === null || meeting === void 0 ? void 0 : (_meeting$meetingInfo0 = meeting.meetingInfo) === null || _meeting$meetingInfo0 === void 0 ? void 0 : _meeting$meetingInfo0.vipmeeting) || false,
|
|
959
|
-
isAutomatedUser: typeof window !== 'undefined' && typeof navigator !== 'undefined' && !!((_navigator = navigator) !== null && _navigator !== void 0 && _navigator.webdriver)
|
|
974
|
+
isAutomatedUser: typeof window !== 'undefined' && typeof navigator !== 'undefined' && !!((_navigator = navigator) !== null && _navigator !== void 0 && _navigator.webdriver),
|
|
975
|
+
// if webdriver is true, it's most likely in a test environment
|
|
976
|
+
userActivation: this.getUserActivation()
|
|
960
977
|
});
|
|
961
978
|
var joinFlowVersion = (_options$joinFlowVers = options.joinFlowVersion) !== null && _options$joinFlowVers !== void 0 ? _options$joinFlowVers : (_meeting$callStateFor = meeting.callStateForMetrics) === null || _meeting$callStateFor === void 0 ? void 0 : _meeting$callStateFor.joinFlowVersion;
|
|
962
979
|
if (joinFlowVersion) {
|
|
@@ -1067,7 +1084,9 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
|
|
|
1067
1084
|
telemetryOptOut: this.getTelemetryOptOut(),
|
|
1068
1085
|
// @ts-ignore
|
|
1069
1086
|
webClientPreload: (_this$webex$meetings5 = this.webex.meetings) === null || _this$webex$meetings5 === void 0 ? void 0 : (_this$webex$meetings6 = _this$webex$meetings5.config) === null || _this$webex$meetings6 === void 0 ? void 0 : (_this$webex$meetings7 = _this$webex$meetings6.metrics) === null || _this$webex$meetings7 === void 0 ? void 0 : _this$webex$meetings7.webClientPreload,
|
|
1070
|
-
isAutomatedUser: typeof window !== 'undefined' && typeof navigator !== 'undefined' && !!((_navigator2 = navigator) !== null && _navigator2 !== void 0 && _navigator2.webdriver)
|
|
1087
|
+
isAutomatedUser: typeof window !== 'undefined' && typeof navigator !== 'undefined' && !!((_navigator2 = navigator) !== null && _navigator2 !== void 0 && _navigator2.webdriver),
|
|
1088
|
+
// if webdriver is true, it's most likely in a test environment
|
|
1089
|
+
userActivation: this.getUserActivation()
|
|
1071
1090
|
};
|
|
1072
1091
|
if (options.joinFlowVersion) {
|
|
1073
1092
|
clientEventObject.joinFlowVersion = options.joinFlowVersion;
|
|
@@ -1253,8 +1272,7 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
|
|
|
1253
1272
|
// build metrics-a event type
|
|
1254
1273
|
var finalEvent = {
|
|
1255
1274
|
eventPayload: event,
|
|
1256
|
-
type: ['diagnostic-event']
|
|
1257
|
-
markTelemetryOptOutOnResponse: true
|
|
1275
|
+
type: ['diagnostic-event']
|
|
1258
1276
|
};
|
|
1259
1277
|
return this.callDiagnosticEventsBatcher.request(finalEvent);
|
|
1260
1278
|
}
|