@webex/internal-plugin-metrics 3.12.0-next.26 → 3.12.0-next.28
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 +23 -0
- package/dist/call-diagnostic/call-diagnostic-metrics-batcher.js.map +1 -1
- package/dist/call-diagnostic/call-diagnostic-metrics.js +29 -9
- package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -1
- package/dist/metrics.js +1 -1
- package/dist/prelogin-metrics-batcher.js +23 -0
- package/dist/prelogin-metrics-batcher.js.map +1 -1
- package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +13 -9
- package/package.json +2 -2
- package/src/call-diagnostic/call-diagnostic-metrics-batcher.ts +26 -0
- package/src/call-diagnostic/call-diagnostic-metrics.ts +27 -7
- package/src/prelogin-metrics-batcher.ts +26 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +136 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +96 -10
- package/test/unit/spec/prelogin-metrics-batcher.ts +190 -36
package/dist/metrics.js
CHANGED
|
@@ -7,6 +7,7 @@ _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"));
|
|
10
11
|
var _lodash = require("lodash");
|
|
11
12
|
var _batcher = _interopRequireDefault(require("./batcher"));
|
|
12
13
|
var _callDiagnosticMetrics = require("./call-diagnostic/call-diagnostic-metrics.util");
|
|
@@ -70,11 +71,33 @@ var PreLoginMetricsBatcher = _batcher.default.extend({
|
|
|
70
71
|
waitForServiceTimeout: this.webex.config.metrics.waitForServiceTimeout
|
|
71
72
|
}).then(function (res) {
|
|
72
73
|
_this.webex.logger.log(PRE_LOGIN_METRICS_IDENTIFIER, "PreLoginMetricsBatcher: @submitHttpRequest#".concat(batchId, ". Request successful."));
|
|
74
|
+
_this.handleHttpResponseStatus(res === null || res === void 0 ? void 0 : res.statusCode, payload);
|
|
73
75
|
return res;
|
|
74
76
|
}).catch(function (err) {
|
|
75
77
|
_this.webex.logger.error(PRE_LOGIN_METRICS_IDENTIFIER, "PreLoginMetricsBatcher: @submitHttpRequest#".concat(batchId, ". Request failed:"), "error: ".concat((0, _utils.generateCommonErrorMetadata)(err)));
|
|
78
|
+
_this.handleHttpResponseStatus(err === null || err === void 0 ? void 0 : err.statusCode, payload);
|
|
76
79
|
return _promise.default.reject(err);
|
|
77
80
|
});
|
|
81
|
+
},
|
|
82
|
+
/**
|
|
83
|
+
* React to the HTTP status code returned by the prelogin metrics endpoint.
|
|
84
|
+
* Only items submitted with `markTelemetryOptOutOnResponse: true` opt into
|
|
85
|
+
* this behavior.
|
|
86
|
+
* @param {number | undefined} statusCode
|
|
87
|
+
* @param {any[]} payload Items flushed in this HTTP batch.
|
|
88
|
+
* @returns {void}
|
|
89
|
+
*/
|
|
90
|
+
handleHttpResponseStatus: function handleHttpResponseStatus(statusCode, payload) {
|
|
91
|
+
var shouldMark = (0, _isArray.default)(payload) && payload.some(function (item) {
|
|
92
|
+
return (item === null || item === void 0 ? void 0 : item.markTelemetryOptOutOnResponse) === true;
|
|
93
|
+
});
|
|
94
|
+
if (!shouldMark) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (statusCode === 200) {
|
|
98
|
+
var _this$webex$internal$, _this$webex$internal$2;
|
|
99
|
+
(_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);
|
|
100
|
+
}
|
|
78
101
|
}
|
|
79
102
|
});
|
|
80
103
|
var _default = exports.default = PreLoginMetricsBatcher;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_lodash","require","_batcher","_interopRequireDefault","_callDiagnosticMetrics","_utils","PRE_LOGIN_METRICS_IDENTIFIER","PreLoginMetricsBatcher","Batcher","extend","namespace","preLoginId","undefined","savePreLoginId","prepareItem","item","_promise","default","resolve","prepareDiagnosticMetricItem","webex","prepareRequest","queue","forEach","eventPayload","originTime","sent","Date","toISOString","submitHttpRequest","payload","_this","batchId","uniqueId","logger","error","concat","reject","Error","request","method","service","resource","headers","authorization","body","metrics","waitForServiceTimeout","config","then","res","log","catch","err","generateCommonErrorMetadata","_default","exports"],"sources":["prelogin-metrics-batcher.ts"],"sourcesContent":["import {uniqueId} from 'lodash';\nimport Batcher from './batcher';\nimport {prepareDiagnosticMetricItem} from './call-diagnostic/call-diagnostic-metrics.util';\nimport {generateCommonErrorMetadata} from './utils';\n\nconst PRE_LOGIN_METRICS_IDENTIFIER = 'Pre Login Metrics -->';\n\nconst PreLoginMetricsBatcher = Batcher.extend({\n namespace: 'Metrics',\n preLoginId: undefined,\n\n /**\n * Save the pre-login ID.\n * @param {string} preLoginId The pre-login ID to be saved.\n * @returns {void}\n */\n savePreLoginId(preLoginId) {\n this.preLoginId = preLoginId;\n },\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: any) {\n const batchId = uniqueId('prelogin-batch-');\n if (this.preLoginId === undefined) {\n this.webex.logger.error(\n PRE_LOGIN_METRICS_IDENTIFIER,\n `PreLoginMetricsBatcher: @submitHttpRequest#${batchId}. PreLoginId is not set.`\n );\n\n return Promise.reject(new Error('PreLoginId is not set.'));\n }\n\n return this.webex\n .request({\n method: 'POST',\n service: 'metrics',\n resource: 'clientmetrics-prelogin',\n headers: {\n authorization: false,\n 'x-prelogin-userid': this.preLoginId,\n },\n body: {\n metrics: payload,\n },\n waitForServiceTimeout: this.webex.config.metrics.waitForServiceTimeout,\n })\n .then((res) => {\n this.webex.logger.log(\n PRE_LOGIN_METRICS_IDENTIFIER,\n `PreLoginMetricsBatcher: @submitHttpRequest#${batchId}. Request successful.`\n );\n\n return res;\n })\n .catch((err) => {\n this.webex.logger.error(\n PRE_LOGIN_METRICS_IDENTIFIER,\n `PreLoginMetricsBatcher: @submitHttpRequest#${batchId}. Request failed:`,\n `error: ${generateCommonErrorMetadata(err)}`\n );\n\n return Promise.reject(err);\n });\n },\n});\n\nexport default PreLoginMetricsBatcher;\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_lodash","require","_batcher","_interopRequireDefault","_callDiagnosticMetrics","_utils","PRE_LOGIN_METRICS_IDENTIFIER","PreLoginMetricsBatcher","Batcher","extend","namespace","preLoginId","undefined","savePreLoginId","prepareItem","item","_promise","default","resolve","prepareDiagnosticMetricItem","webex","prepareRequest","queue","forEach","eventPayload","originTime","sent","Date","toISOString","submitHttpRequest","payload","_this","batchId","uniqueId","logger","error","concat","reject","Error","request","method","service","resource","headers","authorization","body","metrics","waitForServiceTimeout","config","then","res","log","handleHttpResponseStatus","statusCode","catch","err","generateCommonErrorMetadata","shouldMark","_isArray","some","markTelemetryOptOutOnResponse","_this$webex$internal$","_this$webex$internal$2","internal","newMetrics","callDiagnosticMetrics","setIsTelemetryOptOutAutomatic","_default","exports"],"sources":["prelogin-metrics-batcher.ts"],"sourcesContent":["import {uniqueId} from 'lodash';\nimport Batcher from './batcher';\nimport {prepareDiagnosticMetricItem} from './call-diagnostic/call-diagnostic-metrics.util';\nimport {generateCommonErrorMetadata} from './utils';\n\nconst PRE_LOGIN_METRICS_IDENTIFIER = 'Pre Login Metrics -->';\n\nconst PreLoginMetricsBatcher = Batcher.extend({\n namespace: 'Metrics',\n preLoginId: undefined,\n\n /**\n * Save the pre-login ID.\n * @param {string} preLoginId The pre-login ID to be saved.\n * @returns {void}\n */\n savePreLoginId(preLoginId) {\n this.preLoginId = preLoginId;\n },\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: any) {\n const batchId = uniqueId('prelogin-batch-');\n if (this.preLoginId === undefined) {\n this.webex.logger.error(\n PRE_LOGIN_METRICS_IDENTIFIER,\n `PreLoginMetricsBatcher: @submitHttpRequest#${batchId}. PreLoginId is not set.`\n );\n\n return Promise.reject(new Error('PreLoginId is not set.'));\n }\n\n return this.webex\n .request({\n method: 'POST',\n service: 'metrics',\n resource: 'clientmetrics-prelogin',\n headers: {\n authorization: false,\n 'x-prelogin-userid': this.preLoginId,\n },\n body: {\n metrics: payload,\n },\n waitForServiceTimeout: this.webex.config.metrics.waitForServiceTimeout,\n })\n .then((res) => {\n this.webex.logger.log(\n PRE_LOGIN_METRICS_IDENTIFIER,\n `PreLoginMetricsBatcher: @submitHttpRequest#${batchId}. Request successful.`\n );\n\n this.handleHttpResponseStatus(res?.statusCode, payload);\n\n return res;\n })\n .catch((err) => {\n this.webex.logger.error(\n PRE_LOGIN_METRICS_IDENTIFIER,\n `PreLoginMetricsBatcher: @submitHttpRequest#${batchId}. Request failed:`,\n `error: ${generateCommonErrorMetadata(err)}`\n );\n\n this.handleHttpResponseStatus(err?.statusCode, payload);\n\n return Promise.reject(err);\n });\n },\n\n /**\n * React to the HTTP status code returned by the prelogin metrics endpoint.\n * Only items submitted with `markTelemetryOptOutOnResponse: true` opt into\n * this behavior.\n * @param {number | undefined} statusCode\n * @param {any[]} payload Items flushed in this HTTP batch.\n * @returns {void}\n */\n handleHttpResponseStatus(statusCode: number | undefined, payload: any[]) {\n const shouldMark =\n Array.isArray(payload) &&\n payload.some((item) => item?.markTelemetryOptOutOnResponse === true);\n\n if (!shouldMark) {\n return;\n }\n\n if (statusCode === 200) {\n this.webex.internal.newMetrics?.callDiagnosticMetrics?.setIsTelemetryOptOutAutomatic(true);\n }\n },\n});\n\nexport default PreLoginMetricsBatcher;\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -36,7 +36,8 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
|
|
|
36
36
|
private isMercuryConnected;
|
|
37
37
|
private eventLimitTracker;
|
|
38
38
|
private eventLimitWarningsLogged;
|
|
39
|
-
private
|
|
39
|
+
private isTelemetryOptOutManual;
|
|
40
|
+
private isTelemetryOptOutAutomatic;
|
|
40
41
|
validator: (options: {
|
|
41
42
|
type: 'mqe' | 'ce';
|
|
42
43
|
event: Event;
|
|
@@ -60,10 +61,15 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
|
|
|
60
61
|
*/
|
|
61
62
|
getTelemetryOptOut(): "manual" | "automatic";
|
|
62
63
|
/**
|
|
63
|
-
* Sets the
|
|
64
|
-
* @param value -
|
|
64
|
+
* Sets the manual telemetry opt-out status for the current user
|
|
65
|
+
* @param value - boolean value indicating manual telemetry opt-out status
|
|
65
66
|
*/
|
|
66
|
-
|
|
67
|
+
setIsTelemetryOptOutManual(value: boolean): void;
|
|
68
|
+
/**
|
|
69
|
+
* Sets the automatic telemetry opt-out status for the current user
|
|
70
|
+
* @param value - boolean value indicating automatic telemetry opt-out status
|
|
71
|
+
*/
|
|
72
|
+
setIsTelemetryOptOutAutomatic(value: boolean): void;
|
|
67
73
|
/**
|
|
68
74
|
* Returns if the meeting has converged architecture enabled
|
|
69
75
|
* @param options.meetingId
|
|
@@ -91,7 +97,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
|
|
|
91
97
|
* @returns
|
|
92
98
|
*/
|
|
93
99
|
getOrigin(options: GetOriginOptions, meetingId?: string): {
|
|
94
|
-
name: "
|
|
100
|
+
name: "endpoint" | "addin" | "antares" | "appapi" | "beech" | "breakout" | "calendar" | "cb" | "cca" | "ccc" | "cloudproxy" | "crc" | "edonus" | "givr" | "hecate" | "hedge" | "hesiod" | "homer" | "idbroker" | "superhomer" | "l2sip" | "linus" | "locus" | "mbs" | "mcc" | "mcs" | "mercury" | "mes" | "mjs" | "mmp" | "mrs" | "mygdon" | "ngpage" | "ngservice" | "oauth" | "orpheus" | "page" | "poros" | "publicapi" | "rhesos" | "sbs" | "terminus" | "tpgw" | "ucc" | "wdm" | "webexivr" | "meetingcontainer";
|
|
95
101
|
userAgent: string;
|
|
96
102
|
buildType?: "debug" | "test" | "prod" | "tap" | "analyzer-test";
|
|
97
103
|
upgradeChannel?: string;
|
|
@@ -119,10 +125,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
|
|
|
119
125
|
browser?: string;
|
|
120
126
|
browserVersion?: string;
|
|
121
127
|
clientType?: "MEETING_CENTER" | "EVENT_CENTER" | "TRAINING_CENTER" | "TEAMS_CLIENT" | "TEAMS_DEVICE" | "TEAMS_SHARE" | "SIP" | "RECORDING" | "CLOUD_AWARE_SIP" | "TEAMS_WXC_CLIENT" | "WXC_CLIENT" | "WXC_DEVICE" | "WEBEX_JS_SDK" | "VOICEA_CLIENT" | "CISCO_SIP_GW" | "WEBEX_SDK" | "CPAAS_THIRD_PARTY_SDK" | "WXC_THIRD_PARTY" | "WXCC" | "TEAMS_PHONE" | "WEBEX_RELAY";
|
|
122
|
-
subClientType?: "TEAMS_DEVICE" | "SIP" | "AUTOMOTIVE_APP" | "BROWSER_EXTENSION" | "DESKTOP_APP" | "DESKTOP_APP_VDI" | "DEVICE_CURRENT" | "DEVICE_LEGACY_2020" | "HOLOGRAM_HEADSET_APP" | "HVDI_APP" | "MIXED" | "MOBILE_APP" | "MOBILE_NETWORK" | "PAGE" | "VDI_APP" | "WEB_APP" | "PHONE_NOVUM" | "PHONE_ESPRESSO" | "PHONE_BUMBLEBEE" | "SIP_PSTN";
|
|
123
|
-
* Returns the telemetryOptOut value of the current user
|
|
124
|
-
* @returns one of 'manual', 'automatic', undefined
|
|
125
|
-
*/
|
|
128
|
+
subClientType?: "TEAMS_DEVICE" | "SIP" | "AUTOMOTIVE_APP" | "BROWSER_EXTENSION" | "DESKTOP_APP" | "DESKTOP_APP_VDI" | "DEVICE_CURRENT" | "DEVICE_LEGACY_2020" | "HOLOGRAM_HEADSET_APP" | "HVDI_APP" | "MIXED" | "MOBILE_APP" | "MOBILE_NETWORK" | "PAGE" | "VDI_APP" | "WEB_APP" | "PHONE_NOVUM" | "PHONE_ESPRESSO" | "PHONE_BUMBLEBEE" | "SIP_PSTN";
|
|
126
129
|
schedulingClientType?: "TEAMS_CLIENT" | "GOOGLE_ADDON" | "PT" | "PUBLIC_API" | "UNIFIED_PAGE" | "WEBEX_PAGE" | "GOOGLE_NOTIFICATION_CALENDAR" | "MSFT_NOTIFICATION_ADDIN" | "MSFT_NOTIFICATION_CALENDAR" | "OUTLOOK_ADDIN";
|
|
127
130
|
clientVersion?: string;
|
|
128
131
|
clientVersionStatus?: "CURRENT" | "LEGACY" | "UNSUPPORTED";
|
|
@@ -628,6 +631,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
|
|
|
628
631
|
* Prepare the event and send the request to metrics-a service, pre login.
|
|
629
632
|
* @param event
|
|
630
633
|
* @param preLoginId
|
|
634
|
+
* @param markTelemetryOptOutOnResponse
|
|
631
635
|
* @returns
|
|
632
636
|
*/
|
|
633
637
|
submitToCallDiagnosticsPreLogin: (event: Event, preLoginId?: string) => Promise<any>;
|
package/package.json
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@webex/common-timers": "3.12.0-next.5",
|
|
41
41
|
"@webex/test-helper-chai": "3.12.0-next.5",
|
|
42
42
|
"@webex/test-helper-mock-webex": "3.12.0-next.5",
|
|
43
|
-
"@webex/webex-core": "3.12.0-next.
|
|
43
|
+
"@webex/webex-core": "3.12.0-next.28",
|
|
44
44
|
"ip-anonymize": "^0.1.0",
|
|
45
45
|
"lodash": "^4.17.21",
|
|
46
46
|
"uuid": "^3.3.2"
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"test:style": "eslint ./src/**/*.*",
|
|
54
54
|
"test:unit": "webex-legacy-tools test --unit --runner mocha"
|
|
55
55
|
},
|
|
56
|
-
"version": "3.12.0-next.
|
|
56
|
+
"version": "3.12.0-next.28"
|
|
57
57
|
}
|
|
@@ -55,6 +55,8 @@ const CallDiagnosticEventsBatcher = Batcher.extend({
|
|
|
55
55
|
`CallDiagnosticEventsBatcher: @submitHttpRequest#${batchId}. Request successful.`
|
|
56
56
|
);
|
|
57
57
|
|
|
58
|
+
this.handleHttpResponseStatus(res?.statusCode, payload);
|
|
59
|
+
|
|
58
60
|
return res;
|
|
59
61
|
})
|
|
60
62
|
.catch((err) => {
|
|
@@ -64,9 +66,33 @@ const CallDiagnosticEventsBatcher = Batcher.extend({
|
|
|
64
66
|
`error: ${generateCommonErrorMetadata(err)}`
|
|
65
67
|
);
|
|
66
68
|
|
|
69
|
+
this.handleHttpResponseStatus(err?.statusCode, payload);
|
|
70
|
+
|
|
67
71
|
return Promise.reject(err);
|
|
68
72
|
});
|
|
69
73
|
},
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* React to the HTTP status code returned by the metrics endpoint.
|
|
77
|
+
* Only items submitted with `markTelemetryOptOutOnResponse: true` opt into
|
|
78
|
+
* this behavior.
|
|
79
|
+
* @param {number | undefined} statusCode
|
|
80
|
+
* @param {any[]} payload Items flushed in this HTTP batch.
|
|
81
|
+
* @returns {void}
|
|
82
|
+
*/
|
|
83
|
+
handleHttpResponseStatus(statusCode: number | undefined, payload: any[]) {
|
|
84
|
+
const shouldMark =
|
|
85
|
+
Array.isArray(payload) &&
|
|
86
|
+
payload.some((item) => item?.markTelemetryOptOutOnResponse === true);
|
|
87
|
+
|
|
88
|
+
if (!shouldMark) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (statusCode === 200) {
|
|
93
|
+
this.webex.internal.newMetrics?.callDiagnosticMetrics?.setIsTelemetryOptOutAutomatic(true);
|
|
94
|
+
}
|
|
95
|
+
},
|
|
70
96
|
});
|
|
71
97
|
|
|
72
98
|
export default CallDiagnosticEventsBatcher;
|
|
@@ -108,7 +108,8 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
|
|
|
108
108
|
private isMercuryConnected = false;
|
|
109
109
|
private eventLimitTracker: Map<string, number> = new Map();
|
|
110
110
|
private eventLimitWarningsLogged: Set<string> = new Set();
|
|
111
|
-
private
|
|
111
|
+
private isTelemetryOptOutManual = false;
|
|
112
|
+
private isTelemetryOptOutAutomatic = false;
|
|
112
113
|
|
|
113
114
|
// the default validator before piping an event to the batcher
|
|
114
115
|
// this function can be overridden by the user
|
|
@@ -150,16 +151,31 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
|
|
|
150
151
|
* Returns the telemetryOptOut value of the current user
|
|
151
152
|
* @returns one of 'manual', 'automatic', undefined
|
|
152
153
|
*/
|
|
153
|
-
getTelemetryOptOut() {
|
|
154
|
-
|
|
154
|
+
public getTelemetryOptOut() {
|
|
155
|
+
if (this.isTelemetryOptOutManual) {
|
|
156
|
+
return 'manual';
|
|
157
|
+
}
|
|
158
|
+
if (this.isTelemetryOptOutAutomatic) {
|
|
159
|
+
return 'automatic';
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return undefined;
|
|
155
163
|
}
|
|
156
164
|
|
|
157
165
|
/**
|
|
158
|
-
* Sets the
|
|
159
|
-
* @param value -
|
|
166
|
+
* Sets the manual telemetry opt-out status for the current user
|
|
167
|
+
* @param value - boolean value indicating manual telemetry opt-out status
|
|
160
168
|
*/
|
|
161
|
-
public
|
|
162
|
-
this.
|
|
169
|
+
public setIsTelemetryOptOutManual(value: boolean) {
|
|
170
|
+
this.isTelemetryOptOutManual = value;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Sets the automatic telemetry opt-out status for the current user
|
|
175
|
+
* @param value - boolean value indicating automatic telemetry opt-out status
|
|
176
|
+
*/
|
|
177
|
+
public setIsTelemetryOptOutAutomatic(value: boolean) {
|
|
178
|
+
this.isTelemetryOptOutAutomatic = value;
|
|
163
179
|
}
|
|
164
180
|
|
|
165
181
|
/**
|
|
@@ -1348,6 +1364,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
|
|
|
1348
1364
|
const finalEvent = {
|
|
1349
1365
|
eventPayload: event,
|
|
1350
1366
|
type: ['diagnostic-event'],
|
|
1367
|
+
markTelemetryOptOutOnResponse: true,
|
|
1351
1368
|
};
|
|
1352
1369
|
|
|
1353
1370
|
return this.callDiagnosticEventsBatcher.request(finalEvent);
|
|
@@ -1357,6 +1374,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
|
|
|
1357
1374
|
* Prepare the event and send the request to metrics-a service, pre login.
|
|
1358
1375
|
* @param event
|
|
1359
1376
|
* @param preLoginId
|
|
1377
|
+
* @param markTelemetryOptOutOnResponse
|
|
1360
1378
|
* @returns
|
|
1361
1379
|
*/
|
|
1362
1380
|
submitToCallDiagnosticsPreLogin = (event: Event, preLoginId?: string): Promise<any> => {
|
|
@@ -1364,7 +1382,9 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
|
|
|
1364
1382
|
const finalEvent = {
|
|
1365
1383
|
eventPayload: event,
|
|
1366
1384
|
type: ['diagnostic-event'],
|
|
1385
|
+
markTelemetryOptOutOnResponse: true,
|
|
1367
1386
|
};
|
|
1387
|
+
|
|
1368
1388
|
this.preLoginMetricsBatcher.savePreLoginId(preLoginId);
|
|
1369
1389
|
|
|
1370
1390
|
return this.preLoginMetricsBatcher.request(finalEvent);
|
|
@@ -78,6 +78,8 @@ const PreLoginMetricsBatcher = Batcher.extend({
|
|
|
78
78
|
`PreLoginMetricsBatcher: @submitHttpRequest#${batchId}. Request successful.`
|
|
79
79
|
);
|
|
80
80
|
|
|
81
|
+
this.handleHttpResponseStatus(res?.statusCode, payload);
|
|
82
|
+
|
|
81
83
|
return res;
|
|
82
84
|
})
|
|
83
85
|
.catch((err) => {
|
|
@@ -87,9 +89,33 @@ const PreLoginMetricsBatcher = Batcher.extend({
|
|
|
87
89
|
`error: ${generateCommonErrorMetadata(err)}`
|
|
88
90
|
);
|
|
89
91
|
|
|
92
|
+
this.handleHttpResponseStatus(err?.statusCode, payload);
|
|
93
|
+
|
|
90
94
|
return Promise.reject(err);
|
|
91
95
|
});
|
|
92
96
|
},
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* React to the HTTP status code returned by the prelogin metrics endpoint.
|
|
100
|
+
* Only items submitted with `markTelemetryOptOutOnResponse: true` opt into
|
|
101
|
+
* this behavior.
|
|
102
|
+
* @param {number | undefined} statusCode
|
|
103
|
+
* @param {any[]} payload Items flushed in this HTTP batch.
|
|
104
|
+
* @returns {void}
|
|
105
|
+
*/
|
|
106
|
+
handleHttpResponseStatus(statusCode: number | undefined, payload: any[]) {
|
|
107
|
+
const shouldMark =
|
|
108
|
+
Array.isArray(payload) &&
|
|
109
|
+
payload.some((item) => item?.markTelemetryOptOutOnResponse === true);
|
|
110
|
+
|
|
111
|
+
if (!shouldMark) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (statusCode === 200) {
|
|
116
|
+
this.webex.internal.newMetrics?.callDiagnosticMetrics?.setIsTelemetryOptOutAutomatic(true);
|
|
117
|
+
}
|
|
118
|
+
},
|
|
93
119
|
});
|
|
94
120
|
|
|
95
121
|
export default PreLoginMetricsBatcher;
|
|
@@ -516,5 +516,141 @@ describe('plugin-metrics', () => {
|
|
|
516
516
|
assert.deepEqual(prepareDiagnosticMetricItemCalls[0].args[1].type, ['diagnostic-event']);
|
|
517
517
|
});
|
|
518
518
|
});
|
|
519
|
+
|
|
520
|
+
describe('#submitHttpRequest', () => {
|
|
521
|
+
it('calls handleHttpResponseStatus with response status on success', async () => {
|
|
522
|
+
const payload = [
|
|
523
|
+
{
|
|
524
|
+
eventPayload: {event: 'my.event'},
|
|
525
|
+
type: ['diagnostic-event'],
|
|
526
|
+
},
|
|
527
|
+
];
|
|
528
|
+
|
|
529
|
+
webex.request = sinon.stub().resolves({statusCode: 200});
|
|
530
|
+
|
|
531
|
+
const handleHttpResponseStatusSpy = sinon.spy(
|
|
532
|
+
webex.internal.newMetrics.callDiagnosticMetrics.callDiagnosticEventsBatcher,
|
|
533
|
+
'handleHttpResponseStatus'
|
|
534
|
+
);
|
|
535
|
+
|
|
536
|
+
const promise =
|
|
537
|
+
webex.internal.newMetrics.callDiagnosticMetrics.callDiagnosticEventsBatcher.submitHttpRequest(
|
|
538
|
+
payload
|
|
539
|
+
);
|
|
540
|
+
|
|
541
|
+
assert.deepEqual(handleHttpResponseStatusSpy.getCalls().length, 0);
|
|
542
|
+
|
|
543
|
+
await flushPromises();
|
|
544
|
+
clock.tick(config.metrics.batcherWait);
|
|
545
|
+
|
|
546
|
+
await promise;
|
|
547
|
+
|
|
548
|
+
assert.calledOnce(webex.request);
|
|
549
|
+
assert.deepEqual(handleHttpResponseStatusSpy.getCalls().length, 1);
|
|
550
|
+
assert.deepEqual(handleHttpResponseStatusSpy.args[0][0], 200);
|
|
551
|
+
assert.deepEqual(handleHttpResponseStatusSpy.args[0][1], payload);
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
it('calls handleHttpResponseStatus with error status on failure', async () => {
|
|
555
|
+
const payload = [
|
|
556
|
+
{
|
|
557
|
+
eventPayload: {event: 'my.event'},
|
|
558
|
+
type: ['diagnostic-event'],
|
|
559
|
+
},
|
|
560
|
+
];
|
|
561
|
+
|
|
562
|
+
webex.request = sinon.stub().rejects({statusCode: 503});
|
|
563
|
+
|
|
564
|
+
const handleHttpResponseStatusSpy = sinon.spy(
|
|
565
|
+
webex.internal.newMetrics.callDiagnosticMetrics.callDiagnosticEventsBatcher,
|
|
566
|
+
'handleHttpResponseStatus'
|
|
567
|
+
);
|
|
568
|
+
|
|
569
|
+
const promise =
|
|
570
|
+
webex.internal.newMetrics.callDiagnosticMetrics.callDiagnosticEventsBatcher.submitHttpRequest(
|
|
571
|
+
payload
|
|
572
|
+
);
|
|
573
|
+
|
|
574
|
+
assert.deepEqual(handleHttpResponseStatusSpy.getCalls().length, 0);
|
|
575
|
+
|
|
576
|
+
await flushPromises();
|
|
577
|
+
clock.tick(config.metrics.batcherWait);
|
|
578
|
+
|
|
579
|
+
let error: any;
|
|
580
|
+
|
|
581
|
+
try {
|
|
582
|
+
await promise;
|
|
583
|
+
} catch (err) {
|
|
584
|
+
error = err;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
assert.deepEqual(error.statusCode, 503);
|
|
588
|
+
assert.calledOnce(webex.request);
|
|
589
|
+
assert.deepEqual(handleHttpResponseStatusSpy.getCalls().length, 1);
|
|
590
|
+
assert.deepEqual(handleHttpResponseStatusSpy.args[0][0], 503);
|
|
591
|
+
assert.deepEqual(handleHttpResponseStatusSpy.args[0][1], payload);
|
|
592
|
+
});
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
describe('#handleHttpResponseStatus', () => {
|
|
596
|
+
let setIsTelemetryOptOutAutomaticStub;
|
|
597
|
+
|
|
598
|
+
beforeEach(() => {
|
|
599
|
+
setIsTelemetryOptOutAutomaticStub = sinon.stub(
|
|
600
|
+
webex.internal.newMetrics.callDiagnosticMetrics,
|
|
601
|
+
'setIsTelemetryOptOutAutomatic'
|
|
602
|
+
);
|
|
603
|
+
});
|
|
604
|
+
|
|
605
|
+
[201, 400, 503, undefined].forEach((statusCode) => {
|
|
606
|
+
it(`does not call setIsTelemetryOptOutAutomatic() when statusCode is ${statusCode} and markTelemetryOptOutOnResponse is true`, () => {
|
|
607
|
+
webex.internal.newMetrics.callDiagnosticMetrics.callDiagnosticEventsBatcher.handleHttpResponseStatus(
|
|
608
|
+
statusCode,
|
|
609
|
+
[{markTelemetryOptOutOnResponse: true}]
|
|
610
|
+
);
|
|
611
|
+
|
|
612
|
+
assert.notCalled(setIsTelemetryOptOutAutomaticStub);
|
|
613
|
+
});
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
it('calls setIsTelemetryOptOutAutomatic(true) when statusCode is 200 and markTelemetryOptOutOnResponse is true', () => {
|
|
617
|
+
webex.internal.newMetrics.callDiagnosticMetrics.callDiagnosticEventsBatcher.handleHttpResponseStatus(
|
|
618
|
+
200,
|
|
619
|
+
[{markTelemetryOptOutOnResponse: true}]
|
|
620
|
+
);
|
|
621
|
+
|
|
622
|
+
assert.calledOnce(setIsTelemetryOptOutAutomaticStub);
|
|
623
|
+
assert.calledWithExactly(setIsTelemetryOptOutAutomaticStub, true);
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
[200, 201, 400, 503, undefined].forEach((statusCode) => {
|
|
627
|
+
it(`does not call setIsTelemetryOptOutAutomatic when shouldMark is false (statusCode: ${statusCode})`, () => {
|
|
628
|
+
webex.internal.newMetrics.callDiagnosticMetrics.callDiagnosticEventsBatcher.handleHttpResponseStatus(
|
|
629
|
+
statusCode,
|
|
630
|
+
[{markTelemetryOptOutOnResponse: false}]
|
|
631
|
+
);
|
|
632
|
+
|
|
633
|
+
assert.notCalled(setIsTelemetryOptOutAutomaticStub);
|
|
634
|
+
});
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
it('does not call setIsTelemetryOptOutAutomatic when payload is empty', () => {
|
|
638
|
+
webex.internal.newMetrics.callDiagnosticMetrics.callDiagnosticEventsBatcher.handleHttpResponseStatus(
|
|
639
|
+
200,
|
|
640
|
+
[]
|
|
641
|
+
);
|
|
642
|
+
|
|
643
|
+
assert.notCalled(setIsTelemetryOptOutAutomaticStub);
|
|
644
|
+
});
|
|
645
|
+
|
|
646
|
+
it('does not call setIsTelemetryOptOutAutomatic when payload is not an array', () => {
|
|
647
|
+
webex.internal.newMetrics.callDiagnosticMetrics.callDiagnosticEventsBatcher.handleHttpResponseStatus(
|
|
648
|
+
200,
|
|
649
|
+
null
|
|
650
|
+
);
|
|
651
|
+
|
|
652
|
+
assert.notCalled(setIsTelemetryOptOutAutomaticStub);
|
|
653
|
+
});
|
|
654
|
+
});
|
|
519
655
|
});
|
|
520
656
|
});
|
|
@@ -3119,7 +3119,11 @@ describe('internal-plugin-metrics', () => {
|
|
|
3119
3119
|
cd.callDiagnosticEventsBatcher = {request: requestStub};
|
|
3120
3120
|
//@ts-ignore
|
|
3121
3121
|
cd.submitToCallDiagnostics({event: 'test'});
|
|
3122
|
-
assert.calledWith(requestStub, {
|
|
3122
|
+
assert.calledWith(requestStub, {
|
|
3123
|
+
eventPayload: {event: 'test'},
|
|
3124
|
+
type: ['diagnostic-event'],
|
|
3125
|
+
markTelemetryOptOutOnResponse: true,
|
|
3126
|
+
});
|
|
3123
3127
|
});
|
|
3124
3128
|
});
|
|
3125
3129
|
|
|
@@ -4031,15 +4035,93 @@ describe('internal-plugin-metrics', () => {
|
|
|
4031
4035
|
});
|
|
4032
4036
|
|
|
4033
4037
|
describe('#getTelemetryOptOut', () => {
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
});
|
|
4038
|
+
it('returns "manual" when manual telemetry opt-out is enabled', () => {
|
|
4039
|
+
cd.setIsTelemetryOptOutManual(true);
|
|
4040
|
+
assert.equal(cd.getTelemetryOptOut(), 'manual');
|
|
4041
|
+
});
|
|
4039
4042
|
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
+
it('returns "automatic" when automatic telemetry opt-out is enabled', () => {
|
|
4044
|
+
cd.setIsTelemetryOptOutAutomatic(true);
|
|
4045
|
+
assert.equal(cd.getTelemetryOptOut(), 'automatic');
|
|
4046
|
+
});
|
|
4047
|
+
|
|
4048
|
+
it('returns "manual" when manual opt-out takes precedence over automatic', () => {
|
|
4049
|
+
cd.setIsTelemetryOptOutManual(true);
|
|
4050
|
+
cd.setIsTelemetryOptOutAutomatic(true);
|
|
4051
|
+
assert.equal(cd.getTelemetryOptOut(), 'manual');
|
|
4052
|
+
});
|
|
4053
|
+
|
|
4054
|
+
it('returns undefined when neither manual nor automatic opt-out is set', () => {
|
|
4055
|
+
assert.isUndefined(cd.getTelemetryOptOut());
|
|
4056
|
+
});
|
|
4057
|
+
|
|
4058
|
+
it('returns undefined after disabling manual opt-out', () => {
|
|
4059
|
+
cd.setIsTelemetryOptOutManual(true);
|
|
4060
|
+
cd.setIsTelemetryOptOutManual(false);
|
|
4061
|
+
assert.isUndefined(cd.getTelemetryOptOut());
|
|
4062
|
+
});
|
|
4063
|
+
});
|
|
4064
|
+
|
|
4065
|
+
describe('#setIsTelemetryOptOutManual', () => {
|
|
4066
|
+
it('sets manual telemetry opt-out to true', () => {
|
|
4067
|
+
cd.setIsTelemetryOptOutManual(true);
|
|
4068
|
+
assert.equal(cd.getTelemetryOptOut(), 'manual');
|
|
4069
|
+
});
|
|
4070
|
+
|
|
4071
|
+
it('sets manual telemetry opt-out to false', () => {
|
|
4072
|
+
cd.setIsTelemetryOptOutManual(true);
|
|
4073
|
+
cd.setIsTelemetryOptOutManual(false);
|
|
4074
|
+
assert.isUndefined(cd.getTelemetryOptOut());
|
|
4075
|
+
});
|
|
4076
|
+
|
|
4077
|
+
it('can toggle manual telemetry opt-out multiple times', () => {
|
|
4078
|
+
cd.setIsTelemetryOptOutManual(true);
|
|
4079
|
+
assert.equal(cd.getTelemetryOptOut(), 'manual');
|
|
4080
|
+
|
|
4081
|
+
cd.setIsTelemetryOptOutManual(false);
|
|
4082
|
+
assert.isUndefined(cd.getTelemetryOptOut());
|
|
4083
|
+
|
|
4084
|
+
cd.setIsTelemetryOptOutManual(true);
|
|
4085
|
+
assert.equal(cd.getTelemetryOptOut(), 'manual');
|
|
4086
|
+
});
|
|
4087
|
+
|
|
4088
|
+
it('manual opt-out takes precedence when automatic is also set', () => {
|
|
4089
|
+
cd.setIsTelemetryOptOutAutomatic(true);
|
|
4090
|
+
cd.setIsTelemetryOptOutManual(true);
|
|
4091
|
+
assert.equal(cd.getTelemetryOptOut(), 'manual');
|
|
4092
|
+
});
|
|
4093
|
+
});
|
|
4094
|
+
|
|
4095
|
+
describe('#setIsTelemetryOptOutAutomatic', () => {
|
|
4096
|
+
it('sets automatic telemetry opt-out to true', () => {
|
|
4097
|
+
cd.setIsTelemetryOptOutAutomatic(true);
|
|
4098
|
+
assert.equal(cd.getTelemetryOptOut(), 'automatic');
|
|
4099
|
+
});
|
|
4100
|
+
|
|
4101
|
+
it('sets automatic telemetry opt-out to false', () => {
|
|
4102
|
+
cd.setIsTelemetryOptOutAutomatic(true);
|
|
4103
|
+
cd.setIsTelemetryOptOutAutomatic(false);
|
|
4104
|
+
assert.isUndefined(cd.getTelemetryOptOut());
|
|
4105
|
+
});
|
|
4106
|
+
|
|
4107
|
+
it('can toggle automatic telemetry opt-out multiple times', () => {
|
|
4108
|
+
cd.setIsTelemetryOptOutAutomatic(true);
|
|
4109
|
+
assert.equal(cd.getTelemetryOptOut(), 'automatic');
|
|
4110
|
+
|
|
4111
|
+
cd.setIsTelemetryOptOutAutomatic(false);
|
|
4112
|
+
assert.isUndefined(cd.getTelemetryOptOut());
|
|
4113
|
+
|
|
4114
|
+
cd.setIsTelemetryOptOutAutomatic(true);
|
|
4115
|
+
assert.equal(cd.getTelemetryOptOut(), 'automatic');
|
|
4116
|
+
});
|
|
4117
|
+
|
|
4118
|
+
it('does not override manual opt-out', () => {
|
|
4119
|
+
cd.setIsTelemetryOptOutManual(true);
|
|
4120
|
+
cd.setIsTelemetryOptOutAutomatic(true);
|
|
4121
|
+
assert.equal(cd.getTelemetryOptOut(), 'manual');
|
|
4122
|
+
|
|
4123
|
+
cd.setIsTelemetryOptOutAutomatic(false);
|
|
4124
|
+
assert.equal(cd.getTelemetryOptOut(), 'manual');
|
|
4043
4125
|
});
|
|
4044
4126
|
});
|
|
4045
4127
|
|
|
@@ -4337,7 +4419,11 @@ describe('internal-plugin-metrics', () => {
|
|
|
4337
4419
|
cd.submitToCallDiagnosticsPreLogin({event: 'test'}, preLoginId);
|
|
4338
4420
|
//@ts-ignore
|
|
4339
4421
|
assert.calledWith(cd.preLoginMetricsBatcher.savePreLoginId, preLoginId);
|
|
4340
|
-
assert.calledWith(requestStub, {
|
|
4422
|
+
assert.calledWith(requestStub, {
|
|
4423
|
+
eventPayload: {event: 'test'},
|
|
4424
|
+
type: ['diagnostic-event'],
|
|
4425
|
+
markTelemetryOptOutOnResponse: true,
|
|
4426
|
+
});
|
|
4341
4427
|
});
|
|
4342
4428
|
});
|
|
4343
4429
|
|