@webex/internal-plugin-metrics 3.0.0-beta.2 → 3.0.0-beta.200
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/README.md +1 -3
- package/dist/batcher.js +3 -22
- package/dist/batcher.js.map +1 -1
- package/dist/call-diagnostic/call-diagnostic-metrics-batcher.js +56 -0
- package/dist/call-diagnostic/call-diagnostic-metrics-batcher.js.map +1 -0
- package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js +451 -0
- package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js.map +1 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.js +584 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js +225 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js.map +1 -0
- package/dist/call-diagnostic/config.js +461 -0
- package/dist/call-diagnostic/config.js.map +1 -0
- package/dist/call-diagnostic/generated-types-temp/ClientEvent.js +7 -0
- package/dist/call-diagnostic/generated-types-temp/ClientEvent.js.map +1 -0
- package/dist/call-diagnostic/generated-types-temp/Event.js +7 -0
- package/dist/call-diagnostic/generated-types-temp/Event.js.map +1 -0
- package/dist/call-diagnostic/generated-types-temp/MediaQualityEvent.js +7 -0
- package/dist/call-diagnostic/generated-types-temp/MediaQualityEvent.js.map +1 -0
- package/dist/client-metrics-batcher.js +1 -7
- package/dist/client-metrics-batcher.js.map +1 -1
- package/dist/config.js +21 -5
- package/dist/config.js.map +1 -1
- package/dist/index.js +26 -10
- package/dist/index.js.map +1 -1
- package/dist/metrics.js +43 -80
- package/dist/metrics.js.map +1 -1
- package/dist/metrics.types.js +7 -0
- package/dist/metrics.types.js.map +1 -0
- package/dist/new-metrics.js +249 -0
- package/dist/new-metrics.js.map +1 -0
- package/dist/types/batcher.d.ts +2 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics-batcher.d.ts +2 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics-latencies.d.ts +189 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +348 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics.util.d.ts +52 -0
- package/dist/types/call-diagnostic/config.d.ts +57 -0
- package/dist/types/call-diagnostic/generated-types-temp/ClientEvent.d.ts +1112 -0
- package/dist/types/call-diagnostic/generated-types-temp/Event.d.ts +4851 -0
- package/dist/types/call-diagnostic/generated-types-temp/MediaQualityEvent.d.ts +2121 -0
- package/dist/types/client-metrics-batcher.d.ts +2 -0
- package/dist/types/config.d.ts +35 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/metrics.d.ts +3 -0
- package/dist/types/metrics.types.d.ts +92 -0
- package/dist/types/new-metrics.d.ts +119 -0
- package/package.json +12 -8
- package/src/batcher.js +33 -26
- package/src/call-diagnostic/call-diagnostic-metrics-batcher.ts +51 -0
- package/src/call-diagnostic/call-diagnostic-metrics-latencies.ts +408 -0
- package/src/call-diagnostic/call-diagnostic-metrics.ts +591 -0
- package/src/call-diagnostic/call-diagnostic-metrics.util.ts +233 -0
- package/src/call-diagnostic/config.ts +455 -0
- package/src/call-diagnostic/generated-types-temp/ClientEvent.ts +2395 -0
- package/src/call-diagnostic/generated-types-temp/Event.ts +7762 -0
- package/src/call-diagnostic/generated-types-temp/MediaQualityEvent.ts +2321 -0
- package/src/client-metrics-batcher.js +3 -4
- package/src/config.js +25 -5
- package/src/index.ts +39 -0
- package/src/metrics.js +44 -58
- package/src/metrics.types.ts +137 -0
- package/src/new-metrics.ts +223 -0
- package/test/unit/spec/batcher.js +26 -15
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +243 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-latencies.ts +474 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +820 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.util.ts +336 -0
- package/test/unit/spec/client-metrics-batcher.js +26 -15
- package/test/unit/spec/metrics.js +85 -116
- package/test/unit/spec/new-metrics.ts +153 -0
- package/tsconfig.json +6 -0
- package/dist/call-diagnostic-events-batcher.js +0 -70
- package/dist/call-diagnostic-events-batcher.js.map +0 -1
- package/src/call-diagnostic-events-batcher.js +0 -62
- package/src/index.js +0 -17
- package/test/unit/spec/call-diagnostic-events-batcher.js +0 -180
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CallDiagnosticLatencies","args","latencyTimestamps","precomputedLatencies","clear","meetingId","webex","meetings","meetingCollection","get","undefined","key","value","Date","getTime","options","setMeetingId","saveFirstTimestampOnly","set","has","a","b","start","end","getDiffBetweenTimestamps","interstitialJoinClickTimestamp","mediaFlowStartedTimestamp","Math","min","lobbyTime","getStayLobbyTime","clickToInterstitial","getClickToInterstitial","interstitialToJoinOk","getInterstitialToJoinOK","joinReqResp","getJoinReqResp","ICESetupTime","getICESetupTime","joinConfJMT","getJoinConfJMT","totalMediaJMT","getMeeting","allowMediaInLobby","WebexPlugin"],"sources":["call-diagnostic-metrics-latencies.ts"],"sourcesContent":["/* eslint-disable class-methods-use-this */\n/* eslint-disable valid-jsdoc */\nimport {WebexPlugin} from '@webex/webex-core';\n\nimport {MetricEventNames} from '../metrics.types';\n\n// we only care about client event and feature event for now\n\n/**\n * @description Helper class to store latencies timestamp and to calculate various latencies for CA.\n * @exports\n * @class CallDiagnosticLatencies\n */\nexport default class CallDiagnosticLatencies extends WebexPlugin {\n latencyTimestamps: Map<MetricEventNames, number>;\n precomputedLatencies: Map<string, number>;\n // meetingId that the current latencies are for\n private meetingId?: string;\n\n /**\n * @constructor\n */\n constructor(...args) {\n super(...args);\n this.latencyTimestamps = new Map();\n this.precomputedLatencies = new Map();\n }\n\n /**\n * Clear timestamps\n */\n public clearTimestamps() {\n this.latencyTimestamps.clear();\n }\n\n /**\n * Associate current latencies with a meeting id\n * @param meetingId\n */\n private setMeetingId(meetingId: string) {\n this.meetingId = meetingId;\n }\n\n /**\n * Returns the meeting object associated with current latencies\n * @returns meeting object\n */\n private getMeeting() {\n if (this.meetingId) {\n // @ts-ignore\n return this.webex.meetings.meetingCollection.get(this.meetingId);\n }\n\n return undefined;\n }\n\n /**\n * Store timestamp value\n * @param key - key\n * @param value -value\n * @throws\n * @returns\n */\n public saveTimestamp({\n key,\n value = new Date().getTime(),\n options = {},\n }: {\n key: MetricEventNames;\n value?: number;\n options?: {meetingId?: string};\n }) {\n // save the meetingId so we can use the meeting object in latency calculations if needed\n const {meetingId} = options;\n if (meetingId) {\n this.setMeetingId(meetingId);\n }\n // for some events we're only interested in the first timestamp not last\n // as these events can happen multiple times\n if (key === 'client.media.rx.start' || key === 'client.media.tx.start') {\n this.saveFirstTimestampOnly(key, value);\n } else {\n this.latencyTimestamps.set(key, value);\n }\n }\n\n /**\n * Store precomputed latency value\n * @param key - key\n * @param value -value\n * @throws\n * @returns\n */\n public saveLatency(key: string, value: number) {\n this.precomputedLatencies.set(key, value);\n }\n\n /**\n * Store only the first timestamp value for the given key\n * @param key - key\n * @param value -value\n * @throws\n * @returns\n */\n saveFirstTimestampOnly(key: MetricEventNames, value: number = new Date().getTime()) {\n if (this.latencyTimestamps.has(key)) {\n return;\n }\n this.latencyTimestamps.set(key, value);\n }\n\n /**\n * Helper to calculate end - start\n * @param a start\n * @param b end\n * @returns latency\n */\n public getDiffBetweenTimestamps(a: MetricEventNames, b: MetricEventNames) {\n const start = this.latencyTimestamps.get(a);\n const end = this.latencyTimestamps.get(b);\n if (start && end) {\n return end - start;\n }\n\n return undefined;\n }\n\n /**\n * Meeting Info Request\n * @note Meeting Info request happen not just in the join phase. CA requires\n * metrics around meeting info request that are only part of join phase.\n * This internal.* event is used to track the real timestamps\n * (when the actual request/response happen). This is because the actual CA event is\n * sent inside the join method on the meeting object based on some logic, but that's not exactly when\n * those events are actually fired. The logic only confirms that they have happened, and we send them over.\n * @returns - latency\n */\n public getMeetingInfoReqResp() {\n return this.getDiffBetweenTimestamps(\n 'internal.client.meetinginfo.request',\n 'internal.client.meetinginfo.response'\n );\n }\n\n /**\n * Interstitial Time\n * @returns - latency\n */\n public getShowInterstitialTime() {\n return this.getDiffBetweenTimestamps(\n 'internal.client.interstitial-window.launched',\n 'internal.client.interstitial-window.click.joinbutton'\n );\n }\n\n /**\n * Call Init Join Request\n * @returns - latency\n */\n public getCallInitJoinReq() {\n if (this.latencyTimestamps.get('internal.client.meeting.click.joinbutton')) {\n return this.getDiffBetweenTimestamps(\n 'internal.client.meeting.click.joinbutton',\n 'client.locus.join.request'\n );\n }\n\n // for cross launch and guest flows\n return this.precomputedLatencies.get('internal.call.init.join.req') || undefined;\n }\n\n /**\n * Locus Join Request\n * @returns - latency\n */\n public getJoinReqResp() {\n return this.getDiffBetweenTimestamps('client.locus.join.request', 'client.locus.join.response');\n }\n\n /**\n * Locus Join Response Sent Received\n * @returns - latency\n */\n public getJoinRespSentReceived() {\n // TODO: not clear SPARK-440554\n return undefined;\n }\n\n /**\n * Local SDP Generated Remote SDP REceived\n * @returns - latency\n */\n public getLocalSDPGenRemoteSDPRecv() {\n return this.getDiffBetweenTimestamps(\n 'client.media-engine.local-sdp-generated',\n 'client.media-engine.remote-sdp-received'\n );\n }\n\n /**\n * ICE Setup Time\n * @returns - latency\n */\n public getICESetupTime() {\n return this.getDiffBetweenTimestamps('client.ice.start', 'client.ice.end');\n }\n\n /**\n * Audio ICE time\n * @returns - latency\n */\n public getAudioICESetupTime() {\n return this.getDiffBetweenTimestamps('client.ice.start', 'client.ice.end');\n }\n\n /**\n * Video ICE Time\n * @returns - latency\n */\n public getVideoICESetupTime() {\n return this.getDiffBetweenTimestamps('client.ice.start', 'client.ice.end');\n }\n\n /**\n * Share ICE Time\n * @returns - latency\n */\n public getShareICESetupTime() {\n return this.getDiffBetweenTimestamps('client.ice.start', 'client.ice.end');\n }\n\n /**\n * Stay Lobby Time\n * @returns - latency\n */\n public getStayLobbyTime() {\n return this.getDiffBetweenTimestamps(\n 'client.locus.join.response',\n 'internal.host.meeting.participant.admitted'\n );\n }\n\n /**\n * Page JMT\n * @returns - latency\n */\n public getPageJMT() {\n return this.precomputedLatencies.get('internal.client.pageJMT') || undefined;\n }\n\n /**\n * Click To Interstitial\n * @returns - latency\n */\n public getClickToInterstitial() {\n // for normal join (where green join button exists before interstitial, i.e reminder, space list etc)\n if (this.latencyTimestamps.get('internal.client.meeting.click.joinbutton')) {\n return this.getDiffBetweenTimestamps(\n 'internal.client.meeting.click.joinbutton',\n 'internal.client.meeting.interstitial-window.showed'\n );\n }\n\n // for cross launch and guest flows\n return this.precomputedLatencies.get('internal.click.to.interstitial') || undefined;\n }\n\n /**\n * Interstitial To Join Ok\n * @returns - latency\n */\n public getInterstitialToJoinOK() {\n return this.getDiffBetweenTimestamps(\n 'internal.client.interstitial-window.click.joinbutton',\n 'client.locus.join.response'\n );\n }\n\n /**\n * Call Init To MediaEngineReady\n * @returns - latency\n */\n public getCallInitMediaEngineReady() {\n return this.getDiffBetweenTimestamps(\n 'internal.client.interstitial-window.click.joinbutton',\n 'client.media-engine.ready'\n );\n }\n\n /**\n * Interstitial To Media Ok\n * @returns - latency\n */\n public getInterstitialToMediaOKJMT() {\n const interstitialJoinClickTimestamp = this.latencyTimestamps.get(\n 'internal.client.interstitial-window.click.joinbutton'\n );\n\n // get the first timestamp\n const mediaFlowStartedTimestamp = Math.min(\n this.latencyTimestamps.get('client.media.rx.start'),\n this.latencyTimestamps.get('client.media.tx.start')\n );\n\n const lobbyTime = this.getStayLobbyTime() || 0;\n\n if (interstitialJoinClickTimestamp && mediaFlowStartedTimestamp) {\n return mediaFlowStartedTimestamp - interstitialJoinClickTimestamp - lobbyTime;\n }\n\n return undefined;\n }\n\n /**\n * Total JMT\n * @returns - latency\n */\n public getTotalJMT() {\n const clickToInterstitial = this.getClickToInterstitial();\n const interstitialToJoinOk = this.getInterstitialToJoinOK();\n\n if (clickToInterstitial && interstitialToJoinOk) {\n return clickToInterstitial + interstitialToJoinOk;\n }\n\n return undefined;\n }\n\n /**\n * Join Conf JMT\n * @returns - latency\n */\n public getJoinConfJMT() {\n const joinReqResp = this.getJoinReqResp();\n const ICESetupTime = this.getICESetupTime();\n\n if (joinReqResp && ICESetupTime) {\n return joinReqResp + ICESetupTime;\n }\n\n return undefined;\n }\n\n /**\n * Total Media JMT\n * @returns - latency\n */\n public getTotalMediaJMT() {\n const clickToInterstitial = this.getClickToInterstitial();\n const interstitialToJoinOk = this.getInterstitialToJoinOK();\n const joinConfJMT = this.getJoinConfJMT();\n const lobbyTime = this.getStayLobbyTime();\n\n if (clickToInterstitial && interstitialToJoinOk && joinConfJMT) {\n const totalMediaJMT = clickToInterstitial + interstitialToJoinOk + joinConfJMT;\n if (this.getMeeting()?.allowMediaInLobby) {\n return totalMediaJMT;\n }\n\n return totalMediaJMT - lobbyTime;\n }\n\n return undefined;\n }\n\n /**\n * Client JMT\n * @returns - latency\n */\n public getClientJMT() {\n const interstitialToJoinOk = this.getInterstitialToJoinOK();\n const joinConfJMT = this.getJoinConfJMT();\n\n if (interstitialToJoinOk && joinConfJMT) {\n return interstitialToJoinOk - joinConfJMT;\n }\n\n return undefined;\n }\n\n /**\n * Audio setup delay receive\n */\n public getAudioJoinRespRxStart() {\n return this.getDiffBetweenTimestamps('client.locus.join.response', 'client.media.rx.start');\n }\n\n /**\n * Video setup delay receive\n */\n public getVideoJoinRespRxStart() {\n return this.getDiffBetweenTimestamps('client.locus.join.response', 'client.media.rx.start');\n }\n\n /**\n * Audio setup delay transmit\n */\n public getAudioJoinRespTxStart() {\n return this.getDiffBetweenTimestamps('client.locus.join.response', 'client.media.tx.start');\n }\n\n /**\n * Video setup delay transmit\n */\n public getVideoJoinRespTxStart() {\n return this.getDiffBetweenTimestamps('client.locus.join.response', 'client.media.tx.start');\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAEA;AAA8C;AAAA;AAI9C;AAEA;AACA;AACA;AACA;AACA;AAJA,IAKqBA,uBAAuB;EAAA;EAAA;EAG1C;;EAGA;AACF;AACA;EACE,mCAAqB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;IAEA;AACF;AACA;EAFE;IAAA;IAAA,OAGA,mCAAiC;MAC/B,OAAO,IAAI,CAACc,wBAAwB,CAAC,4BAA4B,EAAE,uBAAuB,CAAC;IAC7F;;IAEA;AACF;AACA;EAFE;IAAA;IAAA,OAGA,mCAAiC;MAC/B,OAAO,IAAI,CAACA,wBAAwB,CAAC,4BAA4B,EAAE,uBAAuB,CAAC;IAC7F;;IAEA;AACF;AACA;EAFE;IAAA;IAAA,OAGA,mCAAiC;MAC/B,OAAO,IAAI,CAACA,wBAAwB,CAAC,4BAA4B,EAAE,uBAAuB,CAAC;IAC7F;;IAEA;AACF;AACA;EAFE;IAAA;IAAA,OAGA,mCAAiC;MAC/B,OAAO,IAAI,CAACA,wBAAwB,CAAC,4BAA4B,EAAE,uBAAuB,CAAC;IAC7F;EAAC;EAAA;AAAA,EAzYkDoB,sBAAW;AAAA"}
|
|
@@ -0,0 +1,584 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Reflect$construct = require("@babel/runtime-corejs2/core-js/reflect/construct");
|
|
4
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
6
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.default = void 0;
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
|
|
11
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
|
|
13
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
|
|
14
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/assertThisInitialized"));
|
|
15
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/inherits"));
|
|
16
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/possibleConstructorReturn"));
|
|
17
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/getPrototypeOf"));
|
|
18
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
19
|
+
var _merge2 = _interopRequireDefault(require("lodash/merge"));
|
|
20
|
+
var _internalPluginMetrics = require("@webex/internal-plugin-metrics");
|
|
21
|
+
var _common = require("@webex/common");
|
|
22
|
+
var _uuid = _interopRequireDefault(require("uuid"));
|
|
23
|
+
var _webexCore = require("@webex/webex-core");
|
|
24
|
+
var _callDiagnosticMetrics = require("./call-diagnostic-metrics.util");
|
|
25
|
+
var _config = require("../config");
|
|
26
|
+
var _callDiagnosticMetricsBatcher = _interopRequireDefault(require("./call-diagnostic-metrics-batcher"));
|
|
27
|
+
var _config2 = require("./config");
|
|
28
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
29
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
30
|
+
var _BrowserDetection = (0, _common.BrowserDetection)(),
|
|
31
|
+
getOSVersion = _BrowserDetection.getOSVersion,
|
|
32
|
+
getBrowserName = _BrowserDetection.getBrowserName,
|
|
33
|
+
getBrowserVersion = _BrowserDetection.getBrowserVersion;
|
|
34
|
+
/**
|
|
35
|
+
* @description Util class to handle Call Analyzer Metrics
|
|
36
|
+
* @export
|
|
37
|
+
* @class CallDiagnosticMetrics
|
|
38
|
+
*/
|
|
39
|
+
var CallDiagnosticMetrics = /*#__PURE__*/function (_StatelessWebexPlugin) {
|
|
40
|
+
(0, _inherits2.default)(CallDiagnosticMetrics, _StatelessWebexPlugin);
|
|
41
|
+
var _super = _createSuper(CallDiagnosticMetrics);
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Constructor
|
|
46
|
+
* @param args
|
|
47
|
+
*/
|
|
48
|
+
function CallDiagnosticMetrics() {
|
|
49
|
+
var _this;
|
|
50
|
+
(0, _classCallCheck2.default)(this, CallDiagnosticMetrics);
|
|
51
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
52
|
+
args[_key] = arguments[_key];
|
|
53
|
+
}
|
|
54
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "callDiagnosticEventsBatcher", void 0);
|
|
57
|
+
_this.callDiagnosticEventsBatcher = new _callDiagnosticMetricsBatcher.default({}, {
|
|
58
|
+
parent: _this.webex
|
|
59
|
+
});
|
|
60
|
+
return _this;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Returns the login type of the current user
|
|
65
|
+
* @returns one of 'login-ci','unverified-guest', null
|
|
66
|
+
*/
|
|
67
|
+
(0, _createClass2.default)(CallDiagnosticMetrics, [{
|
|
68
|
+
key: "getCurLoginType",
|
|
69
|
+
value: function getCurLoginType() {
|
|
70
|
+
// @ts-ignore
|
|
71
|
+
if (this.webex.canAuthorize) {
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
return this.webex.credentials.isUnverifiedGuest ? 'unverified-guest' : 'login-ci';
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Get origin object for Call Diagnostic Event payload.
|
|
80
|
+
* @param options
|
|
81
|
+
* @param meetingId
|
|
82
|
+
* @returns
|
|
83
|
+
*/
|
|
84
|
+
}, {
|
|
85
|
+
key: "getOrigin",
|
|
86
|
+
value: function getOrigin(options, meetingId) {
|
|
87
|
+
var _this$webex$meetings$, _this$webex$meetings$2, _this$webex$meetings$3, _this$webex$meetings$4;
|
|
88
|
+
var defaultClientType = // @ts-ignore
|
|
89
|
+
(_this$webex$meetings$ = this.webex.meetings.config) === null || _this$webex$meetings$ === void 0 ? void 0 : (_this$webex$meetings$2 = _this$webex$meetings$.metrics) === null || _this$webex$meetings$2 === void 0 ? void 0 : _this$webex$meetings$2.clientType;
|
|
90
|
+
var defaultSubClientType = // @ts-ignore
|
|
91
|
+
(_this$webex$meetings$3 = this.webex.meetings.config) === null || _this$webex$meetings$3 === void 0 ? void 0 : (_this$webex$meetings$4 = _this$webex$meetings$3.metrics) === null || _this$webex$meetings$4 === void 0 ? void 0 : _this$webex$meetings$4.subClientType;
|
|
92
|
+
if (defaultClientType && defaultSubClientType || options.clientType && options.subClientType) {
|
|
93
|
+
var _this$webex$meetings, _this$webex$meetings$5, _this$webex$meetings$6;
|
|
94
|
+
var origin = {
|
|
95
|
+
name: 'endpoint',
|
|
96
|
+
networkType: (options === null || options === void 0 ? void 0 : options.networkType) || 'unknown',
|
|
97
|
+
userAgent: (0, _callDiagnosticMetrics.userAgentToString)({
|
|
98
|
+
// @ts-ignore
|
|
99
|
+
clientName: (_this$webex$meetings = this.webex.meetings) === null || _this$webex$meetings === void 0 ? void 0 : (_this$webex$meetings$5 = _this$webex$meetings.metrics) === null || _this$webex$meetings$5 === void 0 ? void 0 : _this$webex$meetings$5.clientName,
|
|
100
|
+
// @ts-ignore
|
|
101
|
+
webexVersion: this.webex.version
|
|
102
|
+
}),
|
|
103
|
+
clientInfo: {
|
|
104
|
+
clientType: (options === null || options === void 0 ? void 0 : options.clientType) || defaultClientType,
|
|
105
|
+
// @ts-ignore
|
|
106
|
+
clientVersion: "".concat(_config.CLIENT_NAME, "/").concat(this.webex.version),
|
|
107
|
+
localNetworkPrefix:
|
|
108
|
+
// @ts-ignore
|
|
109
|
+
(0, _callDiagnosticMetrics.anonymizeIPAddress)((_this$webex$meetings$6 = this.webex.meetings.geoHintInfo) === null || _this$webex$meetings$6 === void 0 ? void 0 : _this$webex$meetings$6.clientAddress) || undefined,
|
|
110
|
+
osVersion: getOSVersion() || 'unknown',
|
|
111
|
+
subClientType: (options === null || options === void 0 ? void 0 : options.subClientType) || defaultSubClientType,
|
|
112
|
+
os: (0, _internalPluginMetrics.getOSNameInternal)(),
|
|
113
|
+
browser: getBrowserName(),
|
|
114
|
+
browserVersion: getBrowserVersion()
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
if (meetingId) {
|
|
118
|
+
// @ts-ignore
|
|
119
|
+
var meeting = this.webex.meetings.meetingCollection.get(meetingId);
|
|
120
|
+
if (meeting !== null && meeting !== void 0 && meeting.environment) {
|
|
121
|
+
origin.environment = meeting.environment;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return origin;
|
|
125
|
+
}
|
|
126
|
+
throw new Error("ClientType and SubClientType can't be undefined");
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Gather identifier details for call diagnostic payload.
|
|
131
|
+
* @throws Error if initialization fails.
|
|
132
|
+
* @param options
|
|
133
|
+
*/
|
|
134
|
+
}, {
|
|
135
|
+
key: "getIdentifiers",
|
|
136
|
+
value: function getIdentifiers(options) {
|
|
137
|
+
var _meeting$locusInfo;
|
|
138
|
+
var meeting = options.meeting,
|
|
139
|
+
mediaConnections = options.mediaConnections,
|
|
140
|
+
correlationId = options.correlationId;
|
|
141
|
+
var identifiers = {
|
|
142
|
+
correlationId: 'unknown'
|
|
143
|
+
};
|
|
144
|
+
if (meeting) {
|
|
145
|
+
identifiers.correlationId = meeting.correlationId;
|
|
146
|
+
}
|
|
147
|
+
if (correlationId) {
|
|
148
|
+
identifiers.correlationId = correlationId;
|
|
149
|
+
}
|
|
150
|
+
// @ts-ignore
|
|
151
|
+
if (this.webex.internal) {
|
|
152
|
+
// @ts-ignore
|
|
153
|
+
var device = this.webex.internal.device;
|
|
154
|
+
identifiers.userId = device.userId;
|
|
155
|
+
identifiers.deviceId = device.url;
|
|
156
|
+
identifiers.orgId = device.orgId;
|
|
157
|
+
// @ts-ignore
|
|
158
|
+
identifiers.locusUrl = this.webex.internal.services.get('locus');
|
|
159
|
+
}
|
|
160
|
+
if (meeting !== null && meeting !== void 0 && (_meeting$locusInfo = meeting.locusInfo) !== null && _meeting$locusInfo !== void 0 && _meeting$locusInfo.fullState) {
|
|
161
|
+
identifiers.locusUrl = meeting.locusUrl;
|
|
162
|
+
identifiers.locusId = meeting.locusUrl && meeting.locusUrl.split('/').pop();
|
|
163
|
+
identifiers.locusStartTime = meeting.locusInfo.fullState && meeting.locusInfo.fullState.lastActive;
|
|
164
|
+
}
|
|
165
|
+
if (mediaConnections) {
|
|
166
|
+
var _mediaConnections$, _mediaConnections$2;
|
|
167
|
+
identifiers.mediaAgentAlias = mediaConnections === null || mediaConnections === void 0 ? void 0 : (_mediaConnections$ = mediaConnections[0]) === null || _mediaConnections$ === void 0 ? void 0 : _mediaConnections$.mediaAgentAlias;
|
|
168
|
+
identifiers.mediaAgentGroupId = mediaConnections === null || mediaConnections === void 0 ? void 0 : (_mediaConnections$2 = mediaConnections[0]) === null || _mediaConnections$2 === void 0 ? void 0 : _mediaConnections$2.mediaAgentGroupId;
|
|
169
|
+
}
|
|
170
|
+
if (identifiers.correlationId === undefined) {
|
|
171
|
+
throw new Error('Identifiers initialization failed.');
|
|
172
|
+
}
|
|
173
|
+
return identifiers;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Create diagnostic event, which can hold client event, feature event or MQE event data.
|
|
178
|
+
* This just initiates the shared properties that are required for all the 3 event categories.
|
|
179
|
+
* @param eventData
|
|
180
|
+
* @param options
|
|
181
|
+
* @returns
|
|
182
|
+
*/
|
|
183
|
+
}, {
|
|
184
|
+
key: "prepareDiagnosticEvent",
|
|
185
|
+
value: function prepareDiagnosticEvent(eventData, options) {
|
|
186
|
+
var _this$webex$meetings$7;
|
|
187
|
+
var meetingId = options.meetingId;
|
|
188
|
+
var origin = this.getOrigin(options, meetingId);
|
|
189
|
+
var event = {
|
|
190
|
+
eventId: _uuid.default.v4(),
|
|
191
|
+
version: 1,
|
|
192
|
+
origin: origin,
|
|
193
|
+
originTime: {
|
|
194
|
+
triggered: new Date().toISOString(),
|
|
195
|
+
// is overridden in prepareRequest batcher
|
|
196
|
+
sent: 'not_defined_yet'
|
|
197
|
+
},
|
|
198
|
+
// @ts-ignore
|
|
199
|
+
senderCountryCode: (_this$webex$meetings$7 = this.webex.meetings.geoHintInfo) === null || _this$webex$meetings$7 === void 0 ? void 0 : _this$webex$meetings$7.countryCode,
|
|
200
|
+
event: eventData
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
// sanitize (remove empty properties, CA requires it)
|
|
204
|
+
// but we don't want to sanitize MQE as most of the times
|
|
205
|
+
// values will be 0, [] etc, and they are required.
|
|
206
|
+
if (eventData.name !== 'client.mediaquality.event') {
|
|
207
|
+
(0, _callDiagnosticMetrics.clearEmptyKeysRecursively)(event);
|
|
208
|
+
}
|
|
209
|
+
return event;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* TODO: NOT IMPLEMENTED
|
|
214
|
+
* Submit Feature Event
|
|
215
|
+
* @returns
|
|
216
|
+
*/
|
|
217
|
+
}, {
|
|
218
|
+
key: "submitFeatureEvent",
|
|
219
|
+
value: function submitFeatureEvent() {
|
|
220
|
+
throw Error('Not implemented');
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Submit Media Quality Event
|
|
225
|
+
* @param args - submit params
|
|
226
|
+
* @param arg.name - event key
|
|
227
|
+
* @param arg.payload - additional payload to be merge with the default payload
|
|
228
|
+
* @param arg.options - options
|
|
229
|
+
*/
|
|
230
|
+
}, {
|
|
231
|
+
key: "submitMQE",
|
|
232
|
+
value: function submitMQE(_ref) {
|
|
233
|
+
var name = _ref.name,
|
|
234
|
+
payload = _ref.payload,
|
|
235
|
+
options = _ref.options;
|
|
236
|
+
var meetingId = options.meetingId,
|
|
237
|
+
mediaConnections = options.mediaConnections;
|
|
238
|
+
|
|
239
|
+
// events that will most likely happen in join phase
|
|
240
|
+
if (meetingId) {
|
|
241
|
+
// @ts-ignore
|
|
242
|
+
var meeting = this.webex.meetings.meetingCollection.get(meetingId);
|
|
243
|
+
if (!meeting) {
|
|
244
|
+
console.warn('Attempt to send MQE but no meeting was found...', "event: ".concat(name, ", meetingId: ").concat(meetingId));
|
|
245
|
+
// @ts-ignore
|
|
246
|
+
this.webex.internal.metrics.submitClientMetrics(_config2.CALL_DIAGNOSTIC_EVENT_FAILED_TO_SEND, {
|
|
247
|
+
fields: {
|
|
248
|
+
meetingId: meetingId,
|
|
249
|
+
name: name
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// merge identifiers
|
|
256
|
+
var identifiers = this.getIdentifiers({
|
|
257
|
+
meeting: meeting,
|
|
258
|
+
mediaConnections: meeting.mediaConnections || mediaConnections
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
// create media quality event object
|
|
262
|
+
var clientEventObject = {
|
|
263
|
+
name: name,
|
|
264
|
+
canProceed: true,
|
|
265
|
+
identifiers: identifiers,
|
|
266
|
+
eventData: {
|
|
267
|
+
webClientDomain: window.location.hostname
|
|
268
|
+
},
|
|
269
|
+
intervals: payload.intervals,
|
|
270
|
+
sourceMetadata: {
|
|
271
|
+
applicationSoftwareType: _config.CLIENT_NAME,
|
|
272
|
+
// @ts-ignore
|
|
273
|
+
applicationSoftwareVersion: this.webex.version,
|
|
274
|
+
mediaEngineSoftwareType: getBrowserName() || 'browser',
|
|
275
|
+
mediaEngineSoftwareVersion: getOSVersion() || 'unknown',
|
|
276
|
+
startTime: new Date().toISOString()
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
// merge any new properties, or override existing ones
|
|
281
|
+
clientEventObject = (0, _merge2.default)(clientEventObject, payload);
|
|
282
|
+
|
|
283
|
+
// append media quality event data to the call diagnostic event
|
|
284
|
+
var diagnosticEvent = this.prepareDiagnosticEvent(clientEventObject, options);
|
|
285
|
+
this.submitToCallDiagnostics(diagnosticEvent);
|
|
286
|
+
} else {
|
|
287
|
+
throw new Error('Media quality events cant be sent outside the context of a meeting. Meeting id is required.');
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Return Client Event payload by client error code
|
|
293
|
+
* @param arg - get error arg
|
|
294
|
+
* @param arg.clientErrorCode
|
|
295
|
+
* @param arg.serviceErrorCode
|
|
296
|
+
* @returns
|
|
297
|
+
*/
|
|
298
|
+
}, {
|
|
299
|
+
key: "getErrorPayloadForClientErrorCode",
|
|
300
|
+
value: function getErrorPayloadForClientErrorCode(_ref2) {
|
|
301
|
+
var clientErrorCode = _ref2.clientErrorCode,
|
|
302
|
+
serviceErrorCode = _ref2.serviceErrorCode;
|
|
303
|
+
var error;
|
|
304
|
+
if (clientErrorCode) {
|
|
305
|
+
var partialParsedError = _config2.CLIENT_ERROR_CODE_TO_ERROR_PAYLOAD[clientErrorCode];
|
|
306
|
+
if (partialParsedError) {
|
|
307
|
+
error = (0, _merge2.default)({
|
|
308
|
+
fatal: true,
|
|
309
|
+
shownToUser: false,
|
|
310
|
+
name: 'other',
|
|
311
|
+
category: 'other'
|
|
312
|
+
},
|
|
313
|
+
// default values
|
|
314
|
+
{
|
|
315
|
+
errorCode: clientErrorCode
|
|
316
|
+
}, {
|
|
317
|
+
serviceErrorCode: serviceErrorCode
|
|
318
|
+
}, partialParsedError);
|
|
319
|
+
return error;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return undefined;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Generate error payload for Client Event
|
|
327
|
+
* @param rawError
|
|
328
|
+
*/
|
|
329
|
+
}, {
|
|
330
|
+
key: "generateClientEventErrorPayload",
|
|
331
|
+
value: function generateClientEventErrorPayload(rawError) {
|
|
332
|
+
var _rawError$body, _rawError$body2;
|
|
333
|
+
var serviceErrorCode = (rawError === null || rawError === void 0 ? void 0 : (_rawError$body = rawError.body) === null || _rawError$body === void 0 ? void 0 : _rawError$body.errorCode) || (rawError === null || rawError === void 0 ? void 0 : (_rawError$body2 = rawError.body) === null || _rawError$body2 === void 0 ? void 0 : _rawError$body2.code);
|
|
334
|
+
if (serviceErrorCode) {
|
|
335
|
+
var clientErrorCode = _config2.SERVICE_ERROR_CODES_TO_CLIENT_ERROR_CODES_MAP[serviceErrorCode];
|
|
336
|
+
if (clientErrorCode) {
|
|
337
|
+
return this.getErrorPayloadForClientErrorCode({
|
|
338
|
+
clientErrorCode: clientErrorCode,
|
|
339
|
+
serviceErrorCode: serviceErrorCode
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// by default, if it is locus error, return nre locus err
|
|
344
|
+
if ((0, _callDiagnosticMetrics.isLocusServiceErrorCode)(serviceErrorCode)) {
|
|
345
|
+
return this.getErrorPayloadForClientErrorCode({
|
|
346
|
+
clientErrorCode: _config2.NEW_LOCUS_ERROR_CLIENT_CODE,
|
|
347
|
+
serviceErrorCode: serviceErrorCode
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// otherwise return meeting info
|
|
352
|
+
return this.getErrorPayloadForClientErrorCode({
|
|
353
|
+
clientErrorCode: _config2.MEETING_INFO_LOOKUP_ERROR_CLIENT_CODE,
|
|
354
|
+
serviceErrorCode: serviceErrorCode
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
return undefined;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Create client event object for in meeting events
|
|
362
|
+
* @param arg - create args
|
|
363
|
+
* @param arg.event - event key
|
|
364
|
+
* @param arg.options - options
|
|
365
|
+
* @returns object
|
|
366
|
+
*/
|
|
367
|
+
}, {
|
|
368
|
+
key: "createClientEventObjectInMeeting",
|
|
369
|
+
value: function createClientEventObjectInMeeting(_ref3) {
|
|
370
|
+
var name = _ref3.name,
|
|
371
|
+
options = _ref3.options;
|
|
372
|
+
var meetingId = options.meetingId,
|
|
373
|
+
mediaConnections = options.mediaConnections,
|
|
374
|
+
rawError = options.rawError;
|
|
375
|
+
|
|
376
|
+
// @ts-ignore
|
|
377
|
+
var meeting = this.webex.meetings.meetingCollection.get(meetingId);
|
|
378
|
+
if (!meeting) {
|
|
379
|
+
console.warn('Attempt to send client event but no meeting was found...', "event: ".concat(name, ", meetingId: ").concat(meetingId));
|
|
380
|
+
// @ts-ignore
|
|
381
|
+
this.webex.internal.metrics.submitClientMetrics(_config2.CALL_DIAGNOSTIC_EVENT_FAILED_TO_SEND, {
|
|
382
|
+
fields: {
|
|
383
|
+
meetingId: meetingId,
|
|
384
|
+
name: name
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
return undefined;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// grab identifiers
|
|
391
|
+
var identifiers = this.getIdentifiers({
|
|
392
|
+
meeting: meeting,
|
|
393
|
+
mediaConnections: (meeting === null || meeting === void 0 ? void 0 : meeting.mediaConnections) || mediaConnections
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
// check if we need to generate errors
|
|
397
|
+
var errors = [];
|
|
398
|
+
if (rawError) {
|
|
399
|
+
var generatedError = this.generateClientEventErrorPayload(rawError);
|
|
400
|
+
if (generatedError) {
|
|
401
|
+
errors.push(generatedError);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// create client event object
|
|
406
|
+
var clientEventObject = {
|
|
407
|
+
name: name,
|
|
408
|
+
canProceed: true,
|
|
409
|
+
identifiers: identifiers,
|
|
410
|
+
errors: errors,
|
|
411
|
+
eventData: {
|
|
412
|
+
webClientDomain: window.location.hostname
|
|
413
|
+
},
|
|
414
|
+
userType: meeting.getCurUserType(),
|
|
415
|
+
loginType: this.getCurLoginType()
|
|
416
|
+
};
|
|
417
|
+
return clientEventObject;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Create client event object for pre meeting events
|
|
422
|
+
* @param arg - create args
|
|
423
|
+
* @param arg.event - event key
|
|
424
|
+
* @param arg.options - payload
|
|
425
|
+
* @returns object
|
|
426
|
+
*/
|
|
427
|
+
}, {
|
|
428
|
+
key: "createClientEventObjectPreMeeting",
|
|
429
|
+
value: function createClientEventObjectPreMeeting(_ref4) {
|
|
430
|
+
var name = _ref4.name,
|
|
431
|
+
options = _ref4.options;
|
|
432
|
+
var correlationId = options.correlationId;
|
|
433
|
+
|
|
434
|
+
// grab identifiers
|
|
435
|
+
var identifiers = this.getIdentifiers({
|
|
436
|
+
correlationId: correlationId
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
// create client event object
|
|
440
|
+
var clientEventObject = {
|
|
441
|
+
name: name,
|
|
442
|
+
canProceed: true,
|
|
443
|
+
identifiers: identifiers,
|
|
444
|
+
eventData: {
|
|
445
|
+
webClientDomain: window.location.hostname
|
|
446
|
+
},
|
|
447
|
+
loginType: this.getCurLoginType()
|
|
448
|
+
};
|
|
449
|
+
return clientEventObject;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Prepare Client Event CA event.
|
|
454
|
+
* @param arg - submit params
|
|
455
|
+
* @param arg.event - event key
|
|
456
|
+
* @param arg.payload - additional payload to be merged with default payload
|
|
457
|
+
* @param arg.options - payload
|
|
458
|
+
* @returns {any} options to be with fetch
|
|
459
|
+
* @throws
|
|
460
|
+
*/
|
|
461
|
+
}, {
|
|
462
|
+
key: "prepareClientEvent",
|
|
463
|
+
value: function prepareClientEvent(_ref5) {
|
|
464
|
+
var name = _ref5.name,
|
|
465
|
+
payload = _ref5.payload,
|
|
466
|
+
options = _ref5.options;
|
|
467
|
+
var meetingId = options.meetingId,
|
|
468
|
+
correlationId = options.correlationId;
|
|
469
|
+
var clientEventObject;
|
|
470
|
+
|
|
471
|
+
// events that will most likely happen in join phase
|
|
472
|
+
if (meetingId) {
|
|
473
|
+
clientEventObject = this.createClientEventObjectInMeeting({
|
|
474
|
+
name: name,
|
|
475
|
+
options: options
|
|
476
|
+
});
|
|
477
|
+
} else if (correlationId) {
|
|
478
|
+
// any pre join events or events that are outside the meeting.
|
|
479
|
+
clientEventObject = this.createClientEventObjectPreMeeting({
|
|
480
|
+
name: name,
|
|
481
|
+
options: options
|
|
482
|
+
});
|
|
483
|
+
} else {
|
|
484
|
+
throw new Error('Not implemented');
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
// merge any new properties, or override existing ones
|
|
488
|
+
clientEventObject = (0, _merge2.default)(clientEventObject, payload);
|
|
489
|
+
|
|
490
|
+
// append client event data to the call diagnostic event
|
|
491
|
+
var diagnosticEvent = this.prepareDiagnosticEvent(clientEventObject, options);
|
|
492
|
+
return diagnosticEvent;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Submit Client Event CA event.
|
|
497
|
+
* @param arg - submit params
|
|
498
|
+
* @param arg.event - event key
|
|
499
|
+
* @param arg.payload - additional payload to be merged with default payload
|
|
500
|
+
* @param arg.options - payload
|
|
501
|
+
* @throws
|
|
502
|
+
*/
|
|
503
|
+
}, {
|
|
504
|
+
key: "submitClientEvent",
|
|
505
|
+
value: function submitClientEvent(_ref6) {
|
|
506
|
+
var name = _ref6.name,
|
|
507
|
+
payload = _ref6.payload,
|
|
508
|
+
options = _ref6.options;
|
|
509
|
+
var diagnosticEvent = this.prepareClientEvent({
|
|
510
|
+
name: name,
|
|
511
|
+
payload: payload,
|
|
512
|
+
options: options
|
|
513
|
+
});
|
|
514
|
+
return this.submitToCallDiagnostics(diagnosticEvent);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Prepare the event and send the request to metrics-a service.
|
|
519
|
+
* @param event
|
|
520
|
+
* @returns promise
|
|
521
|
+
*/
|
|
522
|
+
}, {
|
|
523
|
+
key: "submitToCallDiagnostics",
|
|
524
|
+
value: function submitToCallDiagnostics(event) {
|
|
525
|
+
// build metrics-a event type
|
|
526
|
+
var finalEvent = {
|
|
527
|
+
eventPayload: event,
|
|
528
|
+
type: ['diagnostic-event']
|
|
529
|
+
};
|
|
530
|
+
return this.callDiagnosticEventsBatcher.request(finalEvent);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Builds a request options object to later be passed to fetch().
|
|
535
|
+
* @param arg - submit params
|
|
536
|
+
* @param arg.event - event key
|
|
537
|
+
* @param arg.payload - additional payload to be merged with default payload
|
|
538
|
+
* @param arg.options - client event options
|
|
539
|
+
* @returns {Promise<any>}
|
|
540
|
+
* @throws
|
|
541
|
+
*/
|
|
542
|
+
}, {
|
|
543
|
+
key: "buildClientEventFetchRequestOptions",
|
|
544
|
+
value: function () {
|
|
545
|
+
var _buildClientEventFetchRequestOptions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref7) {
|
|
546
|
+
var name, payload, options, clientEvent, diagnosticEvent;
|
|
547
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
548
|
+
while (1) switch (_context.prev = _context.next) {
|
|
549
|
+
case 0:
|
|
550
|
+
name = _ref7.name, payload = _ref7.payload, options = _ref7.options;
|
|
551
|
+
clientEvent = this.prepareClientEvent({
|
|
552
|
+
name: name,
|
|
553
|
+
payload: payload,
|
|
554
|
+
options: options
|
|
555
|
+
}); // build metrics-a event type
|
|
556
|
+
// @ts-ignore
|
|
557
|
+
diagnosticEvent = (0, _callDiagnosticMetrics.prepareDiagnosticMetricItem)(this.webex, {
|
|
558
|
+
eventPayload: clientEvent,
|
|
559
|
+
type: ['diagnostic-event']
|
|
560
|
+
}); // @ts-ignore
|
|
561
|
+
return _context.abrupt("return", this.webex.prepareFetchOptions({
|
|
562
|
+
method: 'POST',
|
|
563
|
+
service: 'metrics',
|
|
564
|
+
resource: 'clientmetrics',
|
|
565
|
+
body: {
|
|
566
|
+
metrics: [diagnosticEvent]
|
|
567
|
+
}
|
|
568
|
+
}));
|
|
569
|
+
case 4:
|
|
570
|
+
case "end":
|
|
571
|
+
return _context.stop();
|
|
572
|
+
}
|
|
573
|
+
}, _callee, this);
|
|
574
|
+
}));
|
|
575
|
+
function buildClientEventFetchRequestOptions(_x) {
|
|
576
|
+
return _buildClientEventFetchRequestOptions.apply(this, arguments);
|
|
577
|
+
}
|
|
578
|
+
return buildClientEventFetchRequestOptions;
|
|
579
|
+
}()
|
|
580
|
+
}]);
|
|
581
|
+
return CallDiagnosticMetrics;
|
|
582
|
+
}(_webexCore.StatelessWebexPlugin);
|
|
583
|
+
exports.default = CallDiagnosticMetrics;
|
|
584
|
+
//# sourceMappingURL=call-diagnostic-metrics.js.map
|