@webex/internal-plugin-metrics 3.5.0-next.7 → 3.5.0-next.9
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/business-metrics.js +114 -7
- package/dist/business-metrics.js.map +1 -1
- package/dist/metrics.js +1 -1
- package/dist/metrics.types.js.map +1 -1
- package/dist/types/business-metrics.d.ts +32 -4
- package/dist/types/metrics.types.d.ts +1 -0
- package/dist/types/new-metrics.d.ts +1 -1
- package/package.json +11 -11
- package/src/business-metrics.ts +92 -4
- package/src/metrics.types.ts +2 -0
- package/test/unit/spec/business/business-metrics.ts +63 -1
package/dist/business-metrics.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Reflect$construct = require("@babel/runtime-corejs2/core-js/reflect/construct");
|
|
4
|
+
var _Object$keys = require("@babel/runtime-corejs2/core-js/object/keys");
|
|
5
|
+
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
|
|
6
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
|
|
7
|
+
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
|
|
8
|
+
var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
|
|
4
9
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
5
10
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
6
11
|
_Object$defineProperty(exports, "__esModule", {
|
|
@@ -8,12 +13,15 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
8
13
|
});
|
|
9
14
|
exports.default = void 0;
|
|
10
15
|
var _now = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/date/now"));
|
|
16
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
11
17
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
|
|
12
18
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
|
|
13
19
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/inherits"));
|
|
14
20
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/possibleConstructorReturn"));
|
|
15
21
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/getPrototypeOf"));
|
|
16
22
|
var _genericMetrics = _interopRequireDefault(require("./generic-metrics"));
|
|
23
|
+
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
24
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17
25
|
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); }; }
|
|
18
26
|
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; } }
|
|
19
27
|
/**
|
|
@@ -29,33 +37,132 @@ var BusinessMetrics = exports.default = /*#__PURE__*/function (_GenericMetrics)
|
|
|
29
37
|
return _super.apply(this, arguments);
|
|
30
38
|
}
|
|
31
39
|
(0, _createClass2.default)(BusinessMetrics, [{
|
|
32
|
-
key: "
|
|
40
|
+
key: "submitCallEndEvent",
|
|
33
41
|
value:
|
|
34
42
|
/**
|
|
35
|
-
*
|
|
43
|
+
* unfortunately, the pinot team does not allow changes to the schema of wbxapp_callend_metrics
|
|
44
|
+
* so we have to shim this layer specifically for this
|
|
45
|
+
* @param {EventPayload} payload payload of the metric
|
|
46
|
+
* @returns {Promise<any>}
|
|
47
|
+
*/
|
|
48
|
+
function submitCallEndEvent(_ref) {
|
|
49
|
+
var payload = _ref.payload;
|
|
50
|
+
var event = {
|
|
51
|
+
type: ['business'],
|
|
52
|
+
eventPayload: {
|
|
53
|
+
key: 'callEnd',
|
|
54
|
+
client_timestamp: (0, _now.default)(),
|
|
55
|
+
appType: 'Web Client',
|
|
56
|
+
value: _objectSpread({}, payload)
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
return this.submitEvent({
|
|
60
|
+
kind: 'buisness-events:wbxapp_callend_metrics -> ',
|
|
61
|
+
name: 'wbxapp_callend_metrics',
|
|
62
|
+
event: event
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Submit a buisness metric to our metrics endpoint, going to the default business_ucf table
|
|
68
|
+
* all event payload keys are converted into a hex string value
|
|
69
|
+
* unfortunately, the pinot team does not allow changes to the schema of business_metrics
|
|
70
|
+
* so we have to shim this layer specifically for this
|
|
71
|
+
* @param {string} name of the metric
|
|
72
|
+
* @param {EventPayload} payload payload of the metric
|
|
73
|
+
* @returns {Promise<any>}
|
|
74
|
+
*/
|
|
75
|
+
}, {
|
|
76
|
+
key: "submitBusinessMetricsEvent",
|
|
77
|
+
value: function submitBusinessMetricsEvent(_ref2) {
|
|
78
|
+
var name = _ref2.name,
|
|
79
|
+
payload = _ref2.payload;
|
|
80
|
+
var event = {
|
|
81
|
+
type: ['business'],
|
|
82
|
+
eventPayload: {
|
|
83
|
+
key: name,
|
|
84
|
+
client_timestamp: (0, _now.default)(),
|
|
85
|
+
appType: 'Web Client',
|
|
86
|
+
value: _objectSpread(_objectSpread(_objectSpread({}, this.getContext()), this.getBrowserDetails()), payload)
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
return this.submitEvent({
|
|
90
|
+
kind: 'buisness-events:business_metrics -> ',
|
|
91
|
+
name: name,
|
|
92
|
+
event: event
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Submit a buisness metric to our metrics endpoint, going to the default business_ucf table
|
|
98
|
+
* all event payload keys are converted into a hex string value
|
|
36
99
|
* @param {string} name of the metric
|
|
37
100
|
* @param {EventPayload} user payload of the metric
|
|
38
101
|
* @returns {Promise<any>}
|
|
39
102
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
103
|
+
}, {
|
|
104
|
+
key: "submitDefaultEvent",
|
|
105
|
+
value: function submitDefaultEvent(_ref3) {
|
|
106
|
+
var name = _ref3.name,
|
|
107
|
+
payload = _ref3.payload;
|
|
43
108
|
var event = {
|
|
44
109
|
type: ['business'],
|
|
45
110
|
eventPayload: {
|
|
46
111
|
key: name,
|
|
112
|
+
appType: 'Web Client',
|
|
47
113
|
client_timestamp: (0, _now.default)(),
|
|
48
114
|
context: this.getContext(),
|
|
49
115
|
browserDetails: this.getBrowserDetails(),
|
|
50
116
|
value: payload
|
|
51
117
|
}
|
|
52
118
|
};
|
|
53
|
-
this.submitEvent({
|
|
54
|
-
kind: 'buisness-events -> ',
|
|
119
|
+
return this.submitEvent({
|
|
120
|
+
kind: 'buisness-events:default -> ',
|
|
55
121
|
name: name,
|
|
56
122
|
event: event
|
|
57
123
|
});
|
|
58
124
|
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Submit a buisness metric to our metrics endpoint.
|
|
128
|
+
* routes to the correct table with the correct schema payload by table
|
|
129
|
+
* @param {string} name of the metric, ignored if going to wbxapp_callend_metrics
|
|
130
|
+
* @param {EventPayload} payload user payload of the metric
|
|
131
|
+
* @param {Table} table optional - to submit the metric to and adapt the sent schema
|
|
132
|
+
* @returns {Promise<any>}
|
|
133
|
+
*/
|
|
134
|
+
}, {
|
|
135
|
+
key: "submitBusinessEvent",
|
|
136
|
+
value: function submitBusinessEvent(_ref4) {
|
|
137
|
+
var name = _ref4.name,
|
|
138
|
+
payload = _ref4.payload,
|
|
139
|
+
table = _ref4.table;
|
|
140
|
+
if (!table) {
|
|
141
|
+
table = 'default';
|
|
142
|
+
}
|
|
143
|
+
switch (table) {
|
|
144
|
+
case 'wbxapp_callend_metrics':
|
|
145
|
+
return this.submitCallEndEvent({
|
|
146
|
+
payload: payload
|
|
147
|
+
});
|
|
148
|
+
case 'business_metrics':
|
|
149
|
+
return this.submitBusinessMetricsEvent({
|
|
150
|
+
name: name,
|
|
151
|
+
payload: payload
|
|
152
|
+
});
|
|
153
|
+
case 'business_ucf':
|
|
154
|
+
return this.submitDefaultEvent({
|
|
155
|
+
name: name,
|
|
156
|
+
payload: payload
|
|
157
|
+
});
|
|
158
|
+
case 'default':
|
|
159
|
+
default:
|
|
160
|
+
return this.submitDefaultEvent({
|
|
161
|
+
name: name,
|
|
162
|
+
payload: payload
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
59
166
|
}]);
|
|
60
167
|
return BusinessMetrics;
|
|
61
168
|
}(_genericMetrics.default);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_genericMetrics","_interopRequireDefault","require","_createSuper","Derived","hasNativeReflectConstruct","_isNativeReflectConstruct","_createSuperInternal","Super","_getPrototypeOf2","
|
|
1
|
+
{"version":3,"names":["_genericMetrics","_interopRequireDefault","require","ownKeys","e","r","t","_Object$keys","_Object$getOwnPropertySymbols","o","filter","_Object$getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","Object","forEach","_defineProperty2","default","_Object$getOwnPropertyDescriptors","_Object$defineProperties","_Object$defineProperty","_createSuper","Derived","hasNativeReflectConstruct","_isNativeReflectConstruct","_createSuperInternal","Super","_getPrototypeOf2","result","NewTarget","constructor","_Reflect$construct","_possibleConstructorReturn2","Reflect","sham","Proxy","Boolean","prototype","valueOf","call","BusinessMetrics","exports","_GenericMetrics","_inherits2","_super","_classCallCheck2","_createClass2","key","value","submitCallEndEvent","_ref","payload","event","type","eventPayload","client_timestamp","_now","appType","submitEvent","kind","name","submitBusinessMetricsEvent","_ref2","getContext","getBrowserDetails","submitDefaultEvent","_ref3","context","browserDetails","submitBusinessEvent","_ref4","table","GenericMetrics"],"sources":["business-metrics.ts"],"sourcesContent":["import GenericMetrics from './generic-metrics';\nimport {EventPayload, Table} from './metrics.types';\n\n/**\n * @description Util class to handle Buisness Metrics\n * @export\n * @class BusinessMetrics\n */\nexport default class BusinessMetrics extends GenericMetrics {\n /**\n * unfortunately, the pinot team does not allow changes to the schema of wbxapp_callend_metrics\n * so we have to shim this layer specifically for this\n * @param {EventPayload} payload payload of the metric\n * @returns {Promise<any>}\n */\n private submitCallEndEvent({payload}: {payload: EventPayload}) {\n const event = {\n type: ['business'],\n eventPayload: {\n key: 'callEnd',\n client_timestamp: Date.now(),\n appType: 'Web Client',\n value: {\n ...payload,\n },\n },\n };\n\n return this.submitEvent({\n kind: 'buisness-events:wbxapp_callend_metrics -> ',\n name: 'wbxapp_callend_metrics',\n event,\n });\n }\n\n /**\n * Submit a buisness metric to our metrics endpoint, going to the default business_ucf table\n * all event payload keys are converted into a hex string value\n * unfortunately, the pinot team does not allow changes to the schema of business_metrics\n * so we have to shim this layer specifically for this\n * @param {string} name of the metric\n * @param {EventPayload} payload payload of the metric\n * @returns {Promise<any>}\n */\n private submitBusinessMetricsEvent({name, payload}: {name: string; payload: EventPayload}) {\n const event = {\n type: ['business'],\n eventPayload: {\n key: name,\n client_timestamp: Date.now(),\n appType: 'Web Client',\n value: {\n ...this.getContext(),\n ...this.getBrowserDetails(),\n ...payload,\n },\n },\n };\n\n return this.submitEvent({kind: 'buisness-events:business_metrics -> ', name, event});\n }\n\n /**\n * Submit a buisness metric to our metrics endpoint, going to the default business_ucf table\n * all event payload keys are converted into a hex string value\n * @param {string} name of the metric\n * @param {EventPayload} user payload of the metric\n * @returns {Promise<any>}\n */\n private submitDefaultEvent({name, payload}: {name: string; payload: EventPayload}) {\n const event = {\n type: ['business'],\n eventPayload: {\n key: name,\n appType: 'Web Client',\n client_timestamp: Date.now(),\n context: this.getContext(),\n browserDetails: this.getBrowserDetails(),\n value: payload,\n },\n };\n\n return this.submitEvent({kind: 'buisness-events:default -> ', name, event});\n }\n\n /**\n * Submit a buisness metric to our metrics endpoint.\n * routes to the correct table with the correct schema payload by table\n * @param {string} name of the metric, ignored if going to wbxapp_callend_metrics\n * @param {EventPayload} payload user payload of the metric\n * @param {Table} table optional - to submit the metric to and adapt the sent schema\n * @returns {Promise<any>}\n */\n public submitBusinessEvent({\n name,\n payload,\n table,\n }: {\n name: string;\n payload: EventPayload;\n table?: Table;\n }): Promise<void> {\n if (!table) {\n table = 'default';\n }\n switch (table) {\n case 'wbxapp_callend_metrics':\n return this.submitCallEndEvent({payload});\n case 'business_metrics':\n return this.submitBusinessMetricsEvent({name, payload});\n case 'business_ucf':\n return this.submitDefaultEvent({name, payload});\n case 'default':\n default:\n return this.submitDefaultEvent({name, payload});\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA+C,SAAAC,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,YAAA,CAAAH,CAAA,OAAAI,6BAAA,QAAAC,CAAA,GAAAD,6BAAA,CAAAJ,CAAA,GAAAC,CAAA,K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ACJT,OAAO,GAAAmB,KAAA,CAAPnB,OAAO;QACPoB,KAAK,GAAAD,KAAA,CAALC,KAAK;MAML,IAAI,CAACA,KAAK,EAAE;QACVA,KAAK,GAAG,SAAS;MACnB;MACA,QAAQA,KAAK;QACX,KAAK,wBAAwB;UAC3B,OAAO,IAAI,CAACtB,kBAAkB,CAAC;YAACE,OAAO,EAAPA;UAAO,CAAC,CAAC;QAC3C,KAAK,kBAAkB;UACrB,OAAO,IAAI,CAACU,0BAA0B,CAAC;YAACD,IAAI,EAAJA,IAAI;YAAET,OAAO,EAAPA;UAAO,CAAC,CAAC;QACzD,KAAK,cAAc;UACjB,OAAO,IAAI,CAACc,kBAAkB,CAAC;YAACL,IAAI,EAAJA,IAAI;YAAET,OAAO,EAAPA;UAAO,CAAC,CAAC;QACjD,KAAK,SAAS;QACd;UACE,OAAO,IAAI,CAACc,kBAAkB,CAAC;YAACL,IAAI,EAAJA,IAAI;YAAET,OAAO,EAAPA;UAAO,CAAC,CAAC;MACnD;IACF;EAAC;EAAA,OAAAX,eAAA;AAAA,EA5G0CgC,uBAAc"}
|
package/dist/metrics.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["metrics.types.ts"],"sourcesContent":["import {\n ClientEvent as RawClientEvent,\n Event as RawEvent,\n MediaQualityEvent as RawMediaQualityEvent,\n} from '@webex/event-dictionary-ts';\n\nexport type Event = Omit<RawEvent, 'event'> & {event: RawClientEvent | RawMediaQualityEvent};\n\nexport type ClientEventError = NonNullable<RawClientEvent['errors']>[0];\n\nexport type EnvironmentType = NonNullable<RawEvent['origin']['environment']>;\n\nexport type NewEnvironmentType = NonNullable<RawEvent['origin']['newEnvironment']>;\n\nexport type ClientLaunchMethodType = NonNullable<\n RawEvent['origin']['clientInfo']\n>['clientLaunchMethod'];\n\nexport type BrowserLaunchMethodType = NonNullable<\n RawEvent['origin']['clientInfo']\n>['browserLaunchMethod'];\n\nexport type MetricEventProduct = 'webex' | 'wxcc_desktop';\n\nexport type MetricEventAgent = 'user' | 'browser' | 'system' | 'sdk' | 'redux' | 'service';\n\nexport type MetricEventVerb =\n | 'create'\n | 'get'\n | 'fetch'\n | 'update'\n | 'list'\n | 'delete'\n | 'select'\n | 'view'\n | 'set'\n | 'toggle'\n | 'load'\n | 'reload'\n | 'click'\n | 'hover'\n | 'register'\n | 'unregister'\n | 'enable'\n | 'disable'\n | 'use'\n | 'complete'\n | 'submit'\n | 'apply'\n | 'cancel'\n | 'abort'\n | 'sync'\n | 'login'\n | 'logout'\n | 'answer'\n | 'activate'\n | 'deactivate';\n\nexport type SubmitClientEventOptions = {\n meetingId?: string;\n mediaConnections?: any[];\n rawError?: any;\n correlationId?: string;\n sessionCorrelationId?: string;\n preLoginId?: string;\n environment?: EnvironmentType;\n newEnvironmentType?: NewEnvironmentType;\n clientLaunchMethod?: ClientLaunchMethodType;\n browserLaunchMethod?: BrowserLaunchMethodType;\n webexConferenceIdStr?: string;\n globalMeetingId?: string;\n};\n\nexport type SubmitMQEOptions = {\n meetingId: string;\n mediaConnections?: any[];\n networkType?: Event['origin']['networkType'];\n webexConferenceIdStr?: string;\n globalMeetingId?: string;\n};\n\nexport type InternalEvent = {\n name:\n | 'internal.client.meetinginfo.request'\n | 'internal.client.meetinginfo.response'\n | 'internal.register.device.request'\n | 'internal.register.device.response'\n | 'internal.reset.join.latencies'\n | 'internal.client.meeting.click.joinbutton'\n | 'internal.host.meeting.participant.admitted'\n | 'internal.client.meeting.interstitial-window.showed'\n | 'internal.client.interstitial-window.click.joinbutton'\n | 'internal.client.add-media.turn-discovery.start'\n | 'internal.client.add-media.turn-discovery.end';\n\n payload?: never;\n options?: never;\n};\n\nexport interface ClientEvent {\n name: RawClientEvent['name'];\n payload?: RawClientEvent;\n options?: SubmitClientEventOptions;\n}\n\nexport interface DeviceContext {\n app: {version: string};\n device: {id: string};\n locale: string;\n os: {\n name: string;\n version: string;\n };\n}\n\nexport type MetricType = 'behavioral' | 'operational' | 'business';\n\ntype InternalEventPayload = string | number | boolean;\nexport type EventPayload = Record<string, InternalEventPayload>;\nexport type BehavioralEventPayload = EventPayload; // for compatibilty, can be remove after wxcc-desktop did change their imports.\n\nexport interface BusinessEventPayload {\n metricName: string;\n timestamp: number;\n context: DeviceContext;\n browserDetails: EventPayload;\n value: EventPayload;\n}\n\nexport interface BusinessEvent {\n type: string[];\n eventPayload: BusinessEventPayload;\n}\n\nexport interface TaggedEvent {\n context: DeviceContext;\n metricName: string;\n tags: EventPayload;\n timestamp: number;\n type: [MetricType];\n}\n\nexport type BehavioralEvent = TaggedEvent;\nexport type OperationalEvent = TaggedEvent;\n\nexport interface FeatureEvent {\n // TODO: not implemented\n name: never;\n payload?: never;\n options?: never;\n}\n\nexport interface MediaQualityEvent {\n name: RawMediaQualityEvent['name'];\n payload?: RawMediaQualityEvent;\n options: SubmitMQEOptions;\n}\n\nexport type RecursivePartial<T> = {\n [P in keyof T]?: T[P] extends (infer U)[]\n ? RecursivePartial<U>[]\n : T[P] extends object\n ? RecursivePartial<T[P]>\n : T[P];\n};\n\nexport type MetricEventNames =\n | InternalEvent['name']\n | ClientEvent['name']\n | BehavioralEvent['metricName']\n | OperationalEvent['metricName']\n | BusinessEvent['eventPayload']['metricName']\n | FeatureEvent['name']\n | MediaQualityEvent['name'];\n\nexport type ClientInfo = NonNullable<RawEvent['origin']['clientInfo']>;\nexport type ClientType = NonNullable<RawEvent['origin']['clientInfo']>['clientType'];\nexport type SubClientType = NonNullable<RawEvent['origin']['clientInfo']>['subClientType'];\nexport type NetworkType = NonNullable<RawEvent['origin']>['networkType'];\n\nexport type ClientSubServiceType = ClientEvent['payload']['webexSubServiceType'];\nexport type ClientEventPayload = RecursivePartial<ClientEvent['payload']>;\nexport type ClientEventLeaveReason = ClientEvent['payload']['leaveReason'];\nexport type ClientEventPayloadError = ClientEvent['payload']['errors'];\n\nexport type MediaQualityEventAudioSetupDelayPayload = NonNullable<\n MediaQualityEvent['payload']\n>['audioSetupDelay'];\nexport type MediaQualityEventVideoSetupDelayPayload = NonNullable<\n MediaQualityEvent['payload']\n>['videoSetupDelay'];\n\nexport type SubmitMQEPayload = RecursivePartial<MediaQualityEvent['payload']> & {\n intervals: NonNullable<MediaQualityEvent['payload']>['intervals'];\n};\n\nexport type SubmitInternalEvent = (args: {\n name: InternalEvent['name'];\n payload?: RecursivePartial<InternalEvent['payload']>;\n options?: any;\n}) => void;\n\nexport type SubmitBehavioralEvent = (args: {\n product: MetricEventProduct;\n agent: MetricEventAgent;\n target: string;\n verb: MetricEventVerb;\n payload?: EventPayload;\n}) => void;\n\nexport type SubmitClientEvent = (args: {\n name: ClientEvent['name'];\n payload?: RecursivePartial<ClientEvent['payload']>;\n options?: SubmitClientEventOptions;\n}) => Promise<any>;\n\nexport type SubmitOperationalEvent = (args: {\n name: OperationalEvent['metricName'];\n payload: EventPayload;\n}) => void;\n\nexport type SubmitMQE = (args: {\n name: MediaQualityEvent['name'];\n payload: SubmitMQEPayload;\n options: any;\n}) => void;\n\nexport type BuildClientEventFetchRequestOptions = (args: {\n name: ClientEvent['name'];\n payload?: RecursivePartial<ClientEvent['payload']>;\n options?: SubmitClientEventOptions;\n}) => Promise<any>;\n\nexport type PreComputedLatencies =\n | 'internal.client.pageJMT'\n | 'internal.download.time'\n | 'internal.get.cluster.time'\n | 'internal.click.to.interstitial'\n | 'internal.refresh.captcha.time'\n | 'internal.exchange.ci.token.time'\n | 'internal.get.u2c.time'\n | 'internal.call.init.join.req'\n | 'internal.other.app.api.time'\n | 'internal.api.fetch.intelligence.models';\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["metrics.types.ts"],"sourcesContent":["import {\n ClientEvent as RawClientEvent,\n Event as RawEvent,\n MediaQualityEvent as RawMediaQualityEvent,\n} from '@webex/event-dictionary-ts';\n\nexport type Event = Omit<RawEvent, 'event'> & {event: RawClientEvent | RawMediaQualityEvent};\n\nexport type ClientEventError = NonNullable<RawClientEvent['errors']>[0];\n\nexport type EnvironmentType = NonNullable<RawEvent['origin']['environment']>;\n\nexport type NewEnvironmentType = NonNullable<RawEvent['origin']['newEnvironment']>;\n\nexport type ClientLaunchMethodType = NonNullable<\n RawEvent['origin']['clientInfo']\n>['clientLaunchMethod'];\n\nexport type BrowserLaunchMethodType = NonNullable<\n RawEvent['origin']['clientInfo']\n>['browserLaunchMethod'];\n\nexport type MetricEventProduct = 'webex' | 'wxcc_desktop';\n\nexport type MetricEventAgent = 'user' | 'browser' | 'system' | 'sdk' | 'redux' | 'service';\n\nexport type MetricEventVerb =\n | 'create'\n | 'get'\n | 'fetch'\n | 'update'\n | 'list'\n | 'delete'\n | 'select'\n | 'view'\n | 'set'\n | 'toggle'\n | 'load'\n | 'reload'\n | 'click'\n | 'hover'\n | 'register'\n | 'unregister'\n | 'enable'\n | 'disable'\n | 'use'\n | 'complete'\n | 'submit'\n | 'apply'\n | 'cancel'\n | 'abort'\n | 'sync'\n | 'login'\n | 'logout'\n | 'answer'\n | 'activate'\n | 'deactivate';\n\nexport type SubmitClientEventOptions = {\n meetingId?: string;\n mediaConnections?: any[];\n rawError?: any;\n correlationId?: string;\n sessionCorrelationId?: string;\n preLoginId?: string;\n environment?: EnvironmentType;\n newEnvironmentType?: NewEnvironmentType;\n clientLaunchMethod?: ClientLaunchMethodType;\n browserLaunchMethod?: BrowserLaunchMethodType;\n webexConferenceIdStr?: string;\n globalMeetingId?: string;\n};\n\nexport type SubmitMQEOptions = {\n meetingId: string;\n mediaConnections?: any[];\n networkType?: Event['origin']['networkType'];\n webexConferenceIdStr?: string;\n globalMeetingId?: string;\n};\n\nexport type InternalEvent = {\n name:\n | 'internal.client.meetinginfo.request'\n | 'internal.client.meetinginfo.response'\n | 'internal.register.device.request'\n | 'internal.register.device.response'\n | 'internal.reset.join.latencies'\n | 'internal.client.meeting.click.joinbutton'\n | 'internal.host.meeting.participant.admitted'\n | 'internal.client.meeting.interstitial-window.showed'\n | 'internal.client.interstitial-window.click.joinbutton'\n | 'internal.client.add-media.turn-discovery.start'\n | 'internal.client.add-media.turn-discovery.end';\n\n payload?: never;\n options?: never;\n};\n\nexport interface ClientEvent {\n name: RawClientEvent['name'];\n payload?: RawClientEvent;\n options?: SubmitClientEventOptions;\n}\n\nexport interface DeviceContext {\n app: {version: string};\n device: {id: string};\n locale: string;\n os: {\n name: string;\n version: string;\n };\n}\n\nexport type MetricType = 'behavioral' | 'operational' | 'business';\n\nexport type Table = 'wbxapp_callend_metrics' | 'business_metrics' | 'business_ucf' | 'default';\n\ntype InternalEventPayload = string | number | boolean;\nexport type EventPayload = Record<string, InternalEventPayload>;\nexport type BehavioralEventPayload = EventPayload; // for compatibilty, can be remove after wxcc-desktop did change their imports.\n\nexport interface BusinessEventPayload {\n metricName: string;\n timestamp: number;\n context: DeviceContext;\n browserDetails: EventPayload;\n value: EventPayload;\n}\n\nexport interface BusinessEvent {\n type: string[];\n eventPayload: BusinessEventPayload;\n}\n\nexport interface TaggedEvent {\n context: DeviceContext;\n metricName: string;\n tags: EventPayload;\n timestamp: number;\n type: [MetricType];\n}\n\nexport type BehavioralEvent = TaggedEvent;\nexport type OperationalEvent = TaggedEvent;\n\nexport interface FeatureEvent {\n // TODO: not implemented\n name: never;\n payload?: never;\n options?: never;\n}\n\nexport interface MediaQualityEvent {\n name: RawMediaQualityEvent['name'];\n payload?: RawMediaQualityEvent;\n options: SubmitMQEOptions;\n}\n\nexport type RecursivePartial<T> = {\n [P in keyof T]?: T[P] extends (infer U)[]\n ? RecursivePartial<U>[]\n : T[P] extends object\n ? RecursivePartial<T[P]>\n : T[P];\n};\n\nexport type MetricEventNames =\n | InternalEvent['name']\n | ClientEvent['name']\n | BehavioralEvent['metricName']\n | OperationalEvent['metricName']\n | BusinessEvent['eventPayload']['metricName']\n | FeatureEvent['name']\n | MediaQualityEvent['name'];\n\nexport type ClientInfo = NonNullable<RawEvent['origin']['clientInfo']>;\nexport type ClientType = NonNullable<RawEvent['origin']['clientInfo']>['clientType'];\nexport type SubClientType = NonNullable<RawEvent['origin']['clientInfo']>['subClientType'];\nexport type NetworkType = NonNullable<RawEvent['origin']>['networkType'];\n\nexport type ClientSubServiceType = ClientEvent['payload']['webexSubServiceType'];\nexport type ClientEventPayload = RecursivePartial<ClientEvent['payload']>;\nexport type ClientEventLeaveReason = ClientEvent['payload']['leaveReason'];\nexport type ClientEventPayloadError = ClientEvent['payload']['errors'];\n\nexport type MediaQualityEventAudioSetupDelayPayload = NonNullable<\n MediaQualityEvent['payload']\n>['audioSetupDelay'];\nexport type MediaQualityEventVideoSetupDelayPayload = NonNullable<\n MediaQualityEvent['payload']\n>['videoSetupDelay'];\n\nexport type SubmitMQEPayload = RecursivePartial<MediaQualityEvent['payload']> & {\n intervals: NonNullable<MediaQualityEvent['payload']>['intervals'];\n};\n\nexport type SubmitInternalEvent = (args: {\n name: InternalEvent['name'];\n payload?: RecursivePartial<InternalEvent['payload']>;\n options?: any;\n}) => void;\n\nexport type SubmitBehavioralEvent = (args: {\n product: MetricEventProduct;\n agent: MetricEventAgent;\n target: string;\n verb: MetricEventVerb;\n payload?: EventPayload;\n}) => void;\n\nexport type SubmitClientEvent = (args: {\n name: ClientEvent['name'];\n payload?: RecursivePartial<ClientEvent['payload']>;\n options?: SubmitClientEventOptions;\n}) => Promise<any>;\n\nexport type SubmitOperationalEvent = (args: {\n name: OperationalEvent['metricName'];\n payload: EventPayload;\n}) => void;\n\nexport type SubmitMQE = (args: {\n name: MediaQualityEvent['name'];\n payload: SubmitMQEPayload;\n options: any;\n}) => void;\n\nexport type BuildClientEventFetchRequestOptions = (args: {\n name: ClientEvent['name'];\n payload?: RecursivePartial<ClientEvent['payload']>;\n options?: SubmitClientEventOptions;\n}) => Promise<any>;\n\nexport type PreComputedLatencies =\n | 'internal.client.pageJMT'\n | 'internal.download.time'\n | 'internal.get.cluster.time'\n | 'internal.click.to.interstitial'\n | 'internal.refresh.captcha.time'\n | 'internal.exchange.ci.token.time'\n | 'internal.get.u2c.time'\n | 'internal.call.init.join.req'\n | 'internal.other.app.api.time'\n | 'internal.api.fetch.intelligence.models';\n"],"mappings":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import GenericMetrics from './generic-metrics';
|
|
2
|
-
import { EventPayload } from './metrics.types';
|
|
2
|
+
import { EventPayload, Table } from './metrics.types';
|
|
3
3
|
/**
|
|
4
4
|
* @description Util class to handle Buisness Metrics
|
|
5
5
|
* @export
|
|
@@ -7,13 +7,41 @@ import { EventPayload } from './metrics.types';
|
|
|
7
7
|
*/
|
|
8
8
|
export default class BusinessMetrics extends GenericMetrics {
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* unfortunately, the pinot team does not allow changes to the schema of wbxapp_callend_metrics
|
|
11
|
+
* so we have to shim this layer specifically for this
|
|
12
|
+
* @param {EventPayload} payload payload of the metric
|
|
13
|
+
* @returns {Promise<any>}
|
|
14
|
+
*/
|
|
15
|
+
private submitCallEndEvent;
|
|
16
|
+
/**
|
|
17
|
+
* Submit a buisness metric to our metrics endpoint, going to the default business_ucf table
|
|
18
|
+
* all event payload keys are converted into a hex string value
|
|
19
|
+
* unfortunately, the pinot team does not allow changes to the schema of business_metrics
|
|
20
|
+
* so we have to shim this layer specifically for this
|
|
21
|
+
* @param {string} name of the metric
|
|
22
|
+
* @param {EventPayload} payload payload of the metric
|
|
23
|
+
* @returns {Promise<any>}
|
|
24
|
+
*/
|
|
25
|
+
private submitBusinessMetricsEvent;
|
|
26
|
+
/**
|
|
27
|
+
* Submit a buisness metric to our metrics endpoint, going to the default business_ucf table
|
|
28
|
+
* all event payload keys are converted into a hex string value
|
|
11
29
|
* @param {string} name of the metric
|
|
12
30
|
* @param {EventPayload} user payload of the metric
|
|
13
31
|
* @returns {Promise<any>}
|
|
14
32
|
*/
|
|
15
|
-
|
|
33
|
+
private submitDefaultEvent;
|
|
34
|
+
/**
|
|
35
|
+
* Submit a buisness metric to our metrics endpoint.
|
|
36
|
+
* routes to the correct table with the correct schema payload by table
|
|
37
|
+
* @param {string} name of the metric, ignored if going to wbxapp_callend_metrics
|
|
38
|
+
* @param {EventPayload} payload user payload of the metric
|
|
39
|
+
* @param {Table} table optional - to submit the metric to and adapt the sent schema
|
|
40
|
+
* @returns {Promise<any>}
|
|
41
|
+
*/
|
|
42
|
+
submitBusinessEvent({ name, payload, table, }: {
|
|
16
43
|
name: string;
|
|
17
44
|
payload: EventPayload;
|
|
18
|
-
|
|
45
|
+
table?: Table;
|
|
46
|
+
}): Promise<void>;
|
|
19
47
|
}
|
|
@@ -55,6 +55,7 @@ export interface DeviceContext {
|
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
export type MetricType = 'behavioral' | 'operational' | 'business';
|
|
58
|
+
export type Table = 'wbxapp_callend_metrics' | 'business_metrics' | 'business_ucf' | 'default';
|
|
58
59
|
type InternalEventPayload = string | number | boolean;
|
|
59
60
|
export type EventPayload = Record<string, InternalEventPayload>;
|
|
60
61
|
export type BehavioralEventPayload = EventPayload;
|
package/package.json
CHANGED
|
@@ -26,22 +26,22 @@
|
|
|
26
26
|
"@webex/eslint-config-legacy": "0.0.0",
|
|
27
27
|
"@webex/jest-config-legacy": "0.0.0",
|
|
28
28
|
"@webex/legacy-tools": "0.0.0",
|
|
29
|
-
"@webex/test-helper-chai": "3.5.0-next.
|
|
30
|
-
"@webex/test-helper-mocha": "3.5.0-next.
|
|
31
|
-
"@webex/test-helper-mock-webex": "3.5.0-next.
|
|
32
|
-
"@webex/test-helper-test-users": "3.5.0-next.
|
|
29
|
+
"@webex/test-helper-chai": "3.5.0-next.9",
|
|
30
|
+
"@webex/test-helper-mocha": "3.5.0-next.9",
|
|
31
|
+
"@webex/test-helper-mock-webex": "3.5.0-next.9",
|
|
32
|
+
"@webex/test-helper-test-users": "3.5.0-next.9",
|
|
33
33
|
"eslint": "^8.24.0",
|
|
34
34
|
"prettier": "^2.7.1",
|
|
35
35
|
"sinon": "^9.2.4"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@webex/common": "3.5.0-next.
|
|
39
|
-
"@webex/common-timers": "3.5.0-next.
|
|
38
|
+
"@webex/common": "3.5.0-next.9",
|
|
39
|
+
"@webex/common-timers": "3.5.0-next.9",
|
|
40
40
|
"@webex/event-dictionary-ts": "^1.0.1546",
|
|
41
|
-
"@webex/internal-plugin-metrics": "3.5.0-next.
|
|
42
|
-
"@webex/test-helper-chai": "3.5.0-next.
|
|
43
|
-
"@webex/test-helper-mock-webex": "3.5.0-next.
|
|
44
|
-
"@webex/webex-core": "3.5.0-next.
|
|
41
|
+
"@webex/internal-plugin-metrics": "3.5.0-next.9",
|
|
42
|
+
"@webex/test-helper-chai": "3.5.0-next.9",
|
|
43
|
+
"@webex/test-helper-mock-webex": "3.5.0-next.9",
|
|
44
|
+
"@webex/webex-core": "3.5.0-next.9",
|
|
45
45
|
"ip-anonymize": "^0.1.0",
|
|
46
46
|
"lodash": "^4.17.21",
|
|
47
47
|
"uuid": "^3.3.2"
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"test:style": "eslint ./src/**/*.*",
|
|
55
55
|
"test:unit": "webex-legacy-tools test --unit --runner mocha"
|
|
56
56
|
},
|
|
57
|
-
"version": "3.5.0-next.
|
|
57
|
+
"version": "3.5.0-next.9"
|
|
58
58
|
}
|
package/src/business-metrics.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import GenericMetrics from './generic-metrics';
|
|
2
|
-
import {EventPayload} from './metrics.types';
|
|
2
|
+
import {EventPayload, Table} from './metrics.types';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @description Util class to handle Buisness Metrics
|
|
@@ -8,16 +8,71 @@ import {EventPayload} from './metrics.types';
|
|
|
8
8
|
*/
|
|
9
9
|
export default class BusinessMetrics extends GenericMetrics {
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* unfortunately, the pinot team does not allow changes to the schema of wbxapp_callend_metrics
|
|
12
|
+
* so we have to shim this layer specifically for this
|
|
13
|
+
* @param {EventPayload} payload payload of the metric
|
|
14
|
+
* @returns {Promise<any>}
|
|
15
|
+
*/
|
|
16
|
+
private submitCallEndEvent({payload}: {payload: EventPayload}) {
|
|
17
|
+
const event = {
|
|
18
|
+
type: ['business'],
|
|
19
|
+
eventPayload: {
|
|
20
|
+
key: 'callEnd',
|
|
21
|
+
client_timestamp: Date.now(),
|
|
22
|
+
appType: 'Web Client',
|
|
23
|
+
value: {
|
|
24
|
+
...payload,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return this.submitEvent({
|
|
30
|
+
kind: 'buisness-events:wbxapp_callend_metrics -> ',
|
|
31
|
+
name: 'wbxapp_callend_metrics',
|
|
32
|
+
event,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Submit a buisness metric to our metrics endpoint, going to the default business_ucf table
|
|
38
|
+
* all event payload keys are converted into a hex string value
|
|
39
|
+
* unfortunately, the pinot team does not allow changes to the schema of business_metrics
|
|
40
|
+
* so we have to shim this layer specifically for this
|
|
41
|
+
* @param {string} name of the metric
|
|
42
|
+
* @param {EventPayload} payload payload of the metric
|
|
43
|
+
* @returns {Promise<any>}
|
|
44
|
+
*/
|
|
45
|
+
private submitBusinessMetricsEvent({name, payload}: {name: string; payload: EventPayload}) {
|
|
46
|
+
const event = {
|
|
47
|
+
type: ['business'],
|
|
48
|
+
eventPayload: {
|
|
49
|
+
key: name,
|
|
50
|
+
client_timestamp: Date.now(),
|
|
51
|
+
appType: 'Web Client',
|
|
52
|
+
value: {
|
|
53
|
+
...this.getContext(),
|
|
54
|
+
...this.getBrowserDetails(),
|
|
55
|
+
...payload,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return this.submitEvent({kind: 'buisness-events:business_metrics -> ', name, event});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Submit a buisness metric to our metrics endpoint, going to the default business_ucf table
|
|
65
|
+
* all event payload keys are converted into a hex string value
|
|
12
66
|
* @param {string} name of the metric
|
|
13
67
|
* @param {EventPayload} user payload of the metric
|
|
14
68
|
* @returns {Promise<any>}
|
|
15
69
|
*/
|
|
16
|
-
|
|
70
|
+
private submitDefaultEvent({name, payload}: {name: string; payload: EventPayload}) {
|
|
17
71
|
const event = {
|
|
18
72
|
type: ['business'],
|
|
19
73
|
eventPayload: {
|
|
20
74
|
key: name,
|
|
75
|
+
appType: 'Web Client',
|
|
21
76
|
client_timestamp: Date.now(),
|
|
22
77
|
context: this.getContext(),
|
|
23
78
|
browserDetails: this.getBrowserDetails(),
|
|
@@ -25,6 +80,39 @@ export default class BusinessMetrics extends GenericMetrics {
|
|
|
25
80
|
},
|
|
26
81
|
};
|
|
27
82
|
|
|
28
|
-
this.submitEvent({kind: 'buisness-events -> ', name, event});
|
|
83
|
+
return this.submitEvent({kind: 'buisness-events:default -> ', name, event});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Submit a buisness metric to our metrics endpoint.
|
|
88
|
+
* routes to the correct table with the correct schema payload by table
|
|
89
|
+
* @param {string} name of the metric, ignored if going to wbxapp_callend_metrics
|
|
90
|
+
* @param {EventPayload} payload user payload of the metric
|
|
91
|
+
* @param {Table} table optional - to submit the metric to and adapt the sent schema
|
|
92
|
+
* @returns {Promise<any>}
|
|
93
|
+
*/
|
|
94
|
+
public submitBusinessEvent({
|
|
95
|
+
name,
|
|
96
|
+
payload,
|
|
97
|
+
table,
|
|
98
|
+
}: {
|
|
99
|
+
name: string;
|
|
100
|
+
payload: EventPayload;
|
|
101
|
+
table?: Table;
|
|
102
|
+
}): Promise<void> {
|
|
103
|
+
if (!table) {
|
|
104
|
+
table = 'default';
|
|
105
|
+
}
|
|
106
|
+
switch (table) {
|
|
107
|
+
case 'wbxapp_callend_metrics':
|
|
108
|
+
return this.submitCallEndEvent({payload});
|
|
109
|
+
case 'business_metrics':
|
|
110
|
+
return this.submitBusinessMetricsEvent({name, payload});
|
|
111
|
+
case 'business_ucf':
|
|
112
|
+
return this.submitDefaultEvent({name, payload});
|
|
113
|
+
case 'default':
|
|
114
|
+
default:
|
|
115
|
+
return this.submitDefaultEvent({name, payload});
|
|
116
|
+
}
|
|
29
117
|
}
|
|
30
118
|
}
|
package/src/metrics.types.ts
CHANGED
|
@@ -115,6 +115,8 @@ export interface DeviceContext {
|
|
|
115
115
|
|
|
116
116
|
export type MetricType = 'behavioral' | 'operational' | 'business';
|
|
117
117
|
|
|
118
|
+
export type Table = 'wbxapp_callend_metrics' | 'business_metrics' | 'business_ucf' | 'default';
|
|
119
|
+
|
|
118
120
|
type InternalEventPayload = string | number | boolean;
|
|
119
121
|
export type EventPayload = Record<string, InternalEventPayload>;
|
|
120
122
|
export type BehavioralEventPayload = EventPayload; // for compatibilty, can be remove after wxcc-desktop did change their imports.
|
|
@@ -74,7 +74,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
describe('#sendEvent', () => {
|
|
77
|
-
it('should send correctly shaped business event (check name building and internal tagged event building)', () => {
|
|
77
|
+
it('should send correctly shaped business event (check name building and internal tagged event building) and default correctly', () => {
|
|
78
78
|
// For some reasons `jest` isn't available when testing form build server - so can't use `jest.fn()` here...
|
|
79
79
|
const requestCalls = [];
|
|
80
80
|
const request = function(arg) { requestCalls.push(arg) }
|
|
@@ -86,6 +86,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
86
86
|
assert.equal(requestCalls.length, 1)
|
|
87
87
|
assert.deepEqual(requestCalls[0], {
|
|
88
88
|
eventPayload: {
|
|
89
|
+
appType: 'Web Client',
|
|
89
90
|
context: {
|
|
90
91
|
app: {version: 'webex-version'},
|
|
91
92
|
device: {id: 'deviceId'},
|
|
@@ -115,6 +116,67 @@ describe('internal-plugin-metrics', () => {
|
|
|
115
116
|
});
|
|
116
117
|
assert.isNumber(requestCalls[0].eventPayload.client_timestamp)
|
|
117
118
|
})
|
|
119
|
+
|
|
120
|
+
describe('when table is provided', () => {
|
|
121
|
+
it('should send correctly shaped business event with table: wbx_app_callend_metrics and ignore the key name', () => {
|
|
122
|
+
// For some reasons `jest` isn't available when testing form build server - so can't use `jest.fn()` here...
|
|
123
|
+
const requestCalls = [];
|
|
124
|
+
const request = function(arg) { requestCalls.push(arg) }
|
|
125
|
+
|
|
126
|
+
businessMetrics.clientMetricsBatcher.request = request;
|
|
127
|
+
|
|
128
|
+
assert.equal(requestCalls.length, 0)
|
|
129
|
+
businessMetrics.submitBusinessEvent({ name: "foobar", payload: {bar:"gee"}, table: 'wbxapp_callend_metrics' })
|
|
130
|
+
assert.equal(requestCalls.length, 1)
|
|
131
|
+
assert.deepEqual(requestCalls[0], {
|
|
132
|
+
eventPayload: {
|
|
133
|
+
key: 'callEnd',
|
|
134
|
+
client_timestamp: requestCalls[0].eventPayload.client_timestamp, // This is to bypass time check, which is checked below.
|
|
135
|
+
appType: 'Web Client',
|
|
136
|
+
value: {
|
|
137
|
+
bar: 'gee'
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
type: ['business'],
|
|
141
|
+
});
|
|
142
|
+
assert.isNumber(requestCalls[0].eventPayload.client_timestamp)
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('should send correctly shaped business event with table: business_metrics', () => {
|
|
146
|
+
// For some reasons `jest` isn't available when testing form build server - so can't use `jest.fn()` here...
|
|
147
|
+
const requestCalls = [];
|
|
148
|
+
const request = function(arg) { requestCalls.push(arg) }
|
|
149
|
+
|
|
150
|
+
businessMetrics.clientMetricsBatcher.request = request;
|
|
151
|
+
|
|
152
|
+
assert.equal(requestCalls.length, 0)
|
|
153
|
+
businessMetrics.submitBusinessEvent({ name: "foobar", payload: {bar:"gee"}, table: 'business_metrics' })
|
|
154
|
+
assert.equal(requestCalls.length, 1)
|
|
155
|
+
assert.deepEqual(requestCalls[0], {
|
|
156
|
+
eventPayload: {
|
|
157
|
+
key: 'foobar',
|
|
158
|
+
appType: 'Web Client',
|
|
159
|
+
client_timestamp: requestCalls[0].eventPayload.client_timestamp, // This is to bypass time check, which is checked below.
|
|
160
|
+
value: {
|
|
161
|
+
bar: "gee",
|
|
162
|
+
browser: getBrowserName(),
|
|
163
|
+
browserHeight: window.innerHeight,
|
|
164
|
+
browserVersion: getBrowserVersion(),
|
|
165
|
+
browserWidth: window.innerWidth,
|
|
166
|
+
domain: window.location.hostname,
|
|
167
|
+
inIframe: false,
|
|
168
|
+
locale: window.navigator.language,
|
|
169
|
+
os: getOSNameInternal(),
|
|
170
|
+
app: {version: 'webex-version'},
|
|
171
|
+
device: {id: 'deviceId'},
|
|
172
|
+
locale: 'language',
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
type: ['business'],
|
|
176
|
+
});
|
|
177
|
+
assert.isNumber(requestCalls[0].eventPayload.client_timestamp)
|
|
178
|
+
});
|
|
179
|
+
});
|
|
118
180
|
})
|
|
119
181
|
});
|
|
120
182
|
});
|