@webex/internal-plugin-metrics 3.5.0-next.1 → 3.5.0-next.10
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/call-diagnostic/call-diagnostic-metrics-latencies.js +1 -1
- package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js.map +1 -1
- package/dist/call-diagnostic/call-diagnostic-metrics.js +15 -9
- package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -1
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js +7 -2
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js.map +1 -1
- package/dist/call-diagnostic/config.js +13 -3
- package/dist/call-diagnostic/config.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/metrics.js +1 -1
- package/dist/metrics.types.js.map +1 -1
- package/dist/new-metrics.js +4 -2
- package/dist/new-metrics.js.map +1 -1
- package/dist/rtcMetrics/constants.js +11 -0
- package/dist/rtcMetrics/constants.js.map +1 -0
- package/dist/rtcMetrics/index.js +202 -0
- package/dist/rtcMetrics/index.js.map +1 -0
- package/dist/types/business-metrics.d.ts +32 -4
- package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +6 -1
- package/dist/types/call-diagnostic/config.d.ts +3 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/metrics.types.d.ts +1 -0
- package/dist/types/new-metrics.d.ts +4 -3
- package/dist/types/rtcMetrics/constants.d.ts +4 -0
- package/dist/types/rtcMetrics/index.d.ts +71 -0
- package/package.json +11 -11
- package/src/business-metrics.ts +92 -4
- package/src/call-diagnostic/call-diagnostic-metrics-latencies.ts +1 -1
- package/src/call-diagnostic/call-diagnostic-metrics.ts +13 -9
- package/src/call-diagnostic/call-diagnostic-metrics.util.ts +11 -5
- package/src/call-diagnostic/config.ts +12 -0
- package/src/index.ts +2 -0
- package/src/metrics.types.ts +2 -0
- package/src/new-metrics.ts +11 -2
- package/src/rtcMetrics/constants.ts +3 -0
- package/src/rtcMetrics/index.ts +186 -0
- package/test/unit/spec/business/business-metrics.ts +63 -1
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +2 -1
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-latencies.ts +4 -6
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +275 -34
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.util.ts +7 -3
- package/test/unit/spec/new-metrics.ts +18 -3
- package/test/unit/spec/prelogin-metrics-batcher.ts +3 -1
- package/test/unit/spec/rtcMetrics/index.ts +155 -0
|
@@ -139,7 +139,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
|
|
|
139
139
|
getIsConvergedArchitectureEnabled({meetingId}: {meetingId?: string}): boolean {
|
|
140
140
|
if (meetingId) {
|
|
141
141
|
// @ts-ignore
|
|
142
|
-
const meeting = this.webex.meetings.
|
|
142
|
+
const meeting = this.webex.meetings.getBasicMeetingInformation(meetingId);
|
|
143
143
|
|
|
144
144
|
return meeting?.meetingInfo?.enableConvergedArchitecture;
|
|
145
145
|
}
|
|
@@ -245,7 +245,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
|
|
|
245
245
|
|
|
246
246
|
if (meetingId) {
|
|
247
247
|
// @ts-ignore
|
|
248
|
-
const meeting = this.webex.meetings.
|
|
248
|
+
const meeting = this.webex.meetings.getBasicMeetingInformation(meetingId);
|
|
249
249
|
if (meeting?.environment) {
|
|
250
250
|
origin.environment = meeting.environment;
|
|
251
251
|
}
|
|
@@ -289,13 +289,14 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
|
|
|
289
289
|
sessionCorrelationId,
|
|
290
290
|
} = options;
|
|
291
291
|
const identifiers: Event['event']['identifiers'] = {
|
|
292
|
-
correlationId: 'unknown',
|
|
293
|
-
sessionCorrelationId: 'unknown',
|
|
292
|
+
correlationId: 'unknown', // concerned with setting this to unknown. This will fail diagnostic events parsing because it's not a uuid pattern
|
|
294
293
|
};
|
|
295
294
|
|
|
296
295
|
if (meeting) {
|
|
297
296
|
identifiers.correlationId = meeting.correlationId;
|
|
298
|
-
|
|
297
|
+
if (meeting.sessionCorrelationId) {
|
|
298
|
+
identifiers.sessionCorrelationId = meeting.sessionCorrelationId;
|
|
299
|
+
}
|
|
299
300
|
}
|
|
300
301
|
|
|
301
302
|
if (sessionCorrelationId) {
|
|
@@ -306,6 +307,8 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
|
|
|
306
307
|
identifiers.correlationId = correlationId;
|
|
307
308
|
}
|
|
308
309
|
|
|
310
|
+
// TODO: should we use patterns.uuid to validate correlationId and session correlation id? they will fail the diagnostic events validation pipeline if improperly formatted
|
|
311
|
+
|
|
309
312
|
if (this.device) {
|
|
310
313
|
const {device} = this;
|
|
311
314
|
const {installationId} = device?.config || {};
|
|
@@ -427,7 +430,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
|
|
|
427
430
|
// events that will most likely happen in join phase
|
|
428
431
|
if (meetingId) {
|
|
429
432
|
// @ts-ignore
|
|
430
|
-
const meeting = this.webex.meetings.
|
|
433
|
+
const meeting = this.webex.meetings.getBasicMeetingInformation(meetingId);
|
|
431
434
|
|
|
432
435
|
if (!meeting) {
|
|
433
436
|
console.warn(
|
|
@@ -628,10 +631,11 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
|
|
|
628
631
|
});
|
|
629
632
|
}
|
|
630
633
|
|
|
631
|
-
// otherwise return unkown error
|
|
634
|
+
// otherwise return unkown error but passing serviceErrorCode and serviceErrorName so that we know the issue
|
|
632
635
|
return this.getErrorPayloadForClientErrorCode({
|
|
633
636
|
clientErrorCode: UNKNOWN_ERROR,
|
|
634
|
-
serviceErrorCode: UNKNOWN_ERROR,
|
|
637
|
+
serviceErrorCode: serviceErrorCode || UNKNOWN_ERROR,
|
|
638
|
+
serviceErrorName: rawError?.name,
|
|
635
639
|
payloadOverrides: rawError.payloadOverrides,
|
|
636
640
|
rawErrorMessage,
|
|
637
641
|
httpStatusCode,
|
|
@@ -663,7 +667,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
|
|
|
663
667
|
} = options;
|
|
664
668
|
|
|
665
669
|
// @ts-ignore
|
|
666
|
-
const meeting = this.webex.meetings.
|
|
670
|
+
const meeting = this.webex.meetings.getBasicMeetingInformation(meetingId);
|
|
667
671
|
|
|
668
672
|
if (!meeting) {
|
|
669
673
|
console.warn(
|
|
@@ -231,13 +231,19 @@ export const getBuildType = (
|
|
|
231
231
|
* @returns {Object} prepared item
|
|
232
232
|
*/
|
|
233
233
|
export const prepareDiagnosticMetricItem = (webex: any, item: any) => {
|
|
234
|
+
const buildType = getBuildType(
|
|
235
|
+
webex,
|
|
236
|
+
item.eventPayload?.event?.eventData?.webClientDomain,
|
|
237
|
+
item.eventPayload?.event?.eventData?.markAsTestEvent
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
// Set upgradeChannel to 'gold' if buildType is 'prod', otherwise to the buildType value
|
|
241
|
+
const upgradeChannel = buildType === 'prod' ? 'gold' : buildType;
|
|
242
|
+
|
|
234
243
|
const origin: Partial<Event['origin']> = {
|
|
235
|
-
buildType
|
|
236
|
-
webex,
|
|
237
|
-
item.eventPayload?.event?.eventData?.webClientDomain,
|
|
238
|
-
item.eventPayload?.event?.eventData?.markAsTestEvent
|
|
239
|
-
),
|
|
244
|
+
buildType,
|
|
240
245
|
networkType: 'unknown',
|
|
246
|
+
upgradeChannel,
|
|
241
247
|
};
|
|
242
248
|
|
|
243
249
|
// check event names and append latencies?
|
|
@@ -129,6 +129,7 @@ export const ERROR_DESCRIPTIONS = {
|
|
|
129
129
|
ICE_AND_REACHABILITY_FAILED: 'ICEAndReachabilityFailed',
|
|
130
130
|
SDP_OFFER_CREATION_ERROR: 'SdpOfferCreationError',
|
|
131
131
|
SDP_OFFER_CREATION_ERROR_MISSING_CODEC: 'SdpOfferCreationErrorMissingCodec',
|
|
132
|
+
WDM_RESTRICTED_REGION: 'WdmRestrictedRegion',
|
|
132
133
|
};
|
|
133
134
|
|
|
134
135
|
export const SERVICE_ERROR_CODES_TO_CLIENT_ERROR_CODES_MAP = {
|
|
@@ -288,6 +289,12 @@ export const SERVICE_ERROR_CODES_TO_CLIENT_ERROR_CODES_MAP = {
|
|
|
288
289
|
100005: 4103, // Depracated because of an issue in the UCF Clients
|
|
289
290
|
// If both email-hash and domain-hash are null or undefined.
|
|
290
291
|
100004: 4103,
|
|
292
|
+
|
|
293
|
+
// ---- WDM ----
|
|
294
|
+
// WDM_BLOCKED_ACCESS_BY_COUNTRY_CODE_BANNED_COUNTRY_ERROR_CODE
|
|
295
|
+
4404002: 13000,
|
|
296
|
+
// WDM_BLOCKED_ACCESS_BY_COUNTRY_CODE_RESTRICTED_COUNTRY_ERROR_CODE
|
|
297
|
+
4404003: 13000,
|
|
291
298
|
};
|
|
292
299
|
|
|
293
300
|
export const CLIENT_ERROR_CODE_TO_ERROR_PAYLOAD: Record<number, Partial<ClientEventError>> = {
|
|
@@ -687,6 +694,11 @@ export const CLIENT_ERROR_CODE_TO_ERROR_PAYLOAD: Record<number, Partial<ClientEv
|
|
|
687
694
|
category: 'expected',
|
|
688
695
|
fatal: true,
|
|
689
696
|
},
|
|
697
|
+
13000: {
|
|
698
|
+
errorDescription: ERROR_DESCRIPTIONS.WDM_RESTRICTED_REGION,
|
|
699
|
+
category: 'expected',
|
|
700
|
+
fatal: true,
|
|
701
|
+
},
|
|
690
702
|
};
|
|
691
703
|
|
|
692
704
|
export const CALL_DIAGNOSTIC_EVENT_FAILED_TO_SEND = 'js_sdk_call_diagnostic_event_failed_to_send';
|
package/src/index.ts
CHANGED
|
@@ -25,6 +25,7 @@ import CallDiagnosticLatencies from './call-diagnostic/call-diagnostic-metrics-l
|
|
|
25
25
|
import BehavioralMetrics from './behavioral-metrics';
|
|
26
26
|
import OperationalMetrics from './operational-metrics';
|
|
27
27
|
import BusinessMetrics from './business-metrics';
|
|
28
|
+
import RtcMetrics from './rtcMetrics';
|
|
28
29
|
|
|
29
30
|
registerInternalPlugin('metrics', Metrics, {
|
|
30
31
|
config,
|
|
@@ -47,6 +48,7 @@ export {
|
|
|
47
48
|
BehavioralMetrics,
|
|
48
49
|
OperationalMetrics,
|
|
49
50
|
BusinessMetrics,
|
|
51
|
+
RtcMetrics,
|
|
50
52
|
};
|
|
51
53
|
export type {
|
|
52
54
|
ClientEvent,
|
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.
|
package/src/new-metrics.ts
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
MediaQualityEvent,
|
|
22
22
|
InternalEvent,
|
|
23
23
|
SubmitClientEventOptions,
|
|
24
|
+
Table,
|
|
24
25
|
} from './metrics.types';
|
|
25
26
|
import CallDiagnosticLatencies from './call-diagnostic/call-diagnostic-metrics-latencies';
|
|
26
27
|
import {setMetricTimings} from './call-diagnostic/call-diagnostic-metrics.util';
|
|
@@ -201,7 +202,15 @@ class Metrics extends WebexPlugin {
|
|
|
201
202
|
* Buisness event
|
|
202
203
|
* @param args
|
|
203
204
|
*/
|
|
204
|
-
submitBusinessEvent({
|
|
205
|
+
submitBusinessEvent({
|
|
206
|
+
name,
|
|
207
|
+
payload,
|
|
208
|
+
table,
|
|
209
|
+
}: {
|
|
210
|
+
name: string;
|
|
211
|
+
payload: EventPayload;
|
|
212
|
+
table?: Table;
|
|
213
|
+
}) {
|
|
205
214
|
if (!this.isReady) {
|
|
206
215
|
// @ts-ignore
|
|
207
216
|
this.webex.logger.log(
|
|
@@ -213,7 +222,7 @@ class Metrics extends WebexPlugin {
|
|
|
213
222
|
|
|
214
223
|
this.lazyBuildBusinessMetrics();
|
|
215
224
|
|
|
216
|
-
return this.businessMetrics.submitBusinessEvent({name, payload});
|
|
225
|
+
return this.businessMetrics.submitBusinessEvent({name, payload, table});
|
|
217
226
|
}
|
|
218
227
|
|
|
219
228
|
/**
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/* eslint-disable class-methods-use-this */
|
|
2
|
+
import uuid from 'uuid';
|
|
3
|
+
import * as CallDiagnosticUtils from '../call-diagnostic/call-diagnostic-metrics.util';
|
|
4
|
+
import RTC_METRICS from './constants';
|
|
5
|
+
|
|
6
|
+
const parseJsonPayload = (payload: any[]): any | null => {
|
|
7
|
+
try {
|
|
8
|
+
if (payload && payload[0]) {
|
|
9
|
+
return JSON.parse(payload[0]);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return null;
|
|
13
|
+
} catch (_) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Rtc Metrics
|
|
20
|
+
*/
|
|
21
|
+
export default class RtcMetrics {
|
|
22
|
+
/**
|
|
23
|
+
* Array of MetricData items to be sent to the metrics service.
|
|
24
|
+
*/
|
|
25
|
+
metricsQueue = [];
|
|
26
|
+
|
|
27
|
+
intervalId: number;
|
|
28
|
+
|
|
29
|
+
webex: any;
|
|
30
|
+
|
|
31
|
+
meetingId: string;
|
|
32
|
+
|
|
33
|
+
correlationId: string;
|
|
34
|
+
|
|
35
|
+
connectionId: string;
|
|
36
|
+
|
|
37
|
+
shouldSendMetricsOnNextStatsReport: boolean;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Initialize the interval.
|
|
41
|
+
*
|
|
42
|
+
* @param {object} webex - The main `webex` object.
|
|
43
|
+
* @param {string} meetingId - The meeting id.
|
|
44
|
+
* @param {string} correlationId - The correlation id.
|
|
45
|
+
*/
|
|
46
|
+
constructor(webex, meetingId, correlationId) {
|
|
47
|
+
// `window` is used to prevent typescript from returning a NodeJS.Timer.
|
|
48
|
+
this.intervalId = window.setInterval(this.sendMetricsInQueue.bind(this), 30 * 1000);
|
|
49
|
+
this.meetingId = meetingId;
|
|
50
|
+
this.webex = webex;
|
|
51
|
+
this.correlationId = correlationId;
|
|
52
|
+
this.resetConnection();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Check to see if the metrics queue has any items.
|
|
57
|
+
*
|
|
58
|
+
* @returns {void}
|
|
59
|
+
*/
|
|
60
|
+
public sendMetricsInQueue() {
|
|
61
|
+
if (this.metricsQueue.length) {
|
|
62
|
+
this.sendMetrics();
|
|
63
|
+
this.metricsQueue = [];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Forces sending metrics when we get the next stats-report
|
|
69
|
+
*
|
|
70
|
+
* This is useful for cases when something important happens that affects the media connection,
|
|
71
|
+
* for example when we move from lobby into the meeting.
|
|
72
|
+
*
|
|
73
|
+
* @returns {void}
|
|
74
|
+
*/
|
|
75
|
+
public sendNextMetrics() {
|
|
76
|
+
this.shouldSendMetricsOnNextStatsReport = true;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Add metrics items to the metrics queue.
|
|
81
|
+
*
|
|
82
|
+
* @param {object} data - An object with a payload array of metrics items.
|
|
83
|
+
*
|
|
84
|
+
* @returns {void}
|
|
85
|
+
*/
|
|
86
|
+
addMetrics(data) {
|
|
87
|
+
if (data.payload.length) {
|
|
88
|
+
if (data.name === 'stats-report') {
|
|
89
|
+
data.payload = data.payload.map(this.anonymizeIp);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
this.metricsQueue.push(data);
|
|
93
|
+
|
|
94
|
+
if (this.shouldSendMetricsOnNextStatsReport && data.name === 'stats-report') {
|
|
95
|
+
// this is the first useful set of data (WCME gives it to us after 5s), send it out immediately
|
|
96
|
+
// in case the user is unhappy and closes the browser early
|
|
97
|
+
this.sendMetricsInQueue();
|
|
98
|
+
this.shouldSendMetricsOnNextStatsReport = false;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
// If a connection fails, send the rest of the metrics in queue and get a new connection id.
|
|
103
|
+
const parsedPayload = parseJsonPayload(data.payload);
|
|
104
|
+
if (
|
|
105
|
+
data.name === 'onconnectionstatechange' &&
|
|
106
|
+
parsedPayload &&
|
|
107
|
+
parsedPayload.value === 'failed'
|
|
108
|
+
) {
|
|
109
|
+
this.sendMetricsInQueue();
|
|
110
|
+
this.resetConnection();
|
|
111
|
+
}
|
|
112
|
+
} catch (e) {
|
|
113
|
+
console.error(e);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Clear the metrics interval.
|
|
120
|
+
*
|
|
121
|
+
* @returns {void}
|
|
122
|
+
*/
|
|
123
|
+
closeMetrics() {
|
|
124
|
+
this.sendMetricsInQueue();
|
|
125
|
+
clearInterval(this.intervalId);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Anonymize IP addresses.
|
|
130
|
+
*
|
|
131
|
+
* @param {array} stats - An RTCStatsReport organized into an array of strings.
|
|
132
|
+
* @returns {string}
|
|
133
|
+
*/
|
|
134
|
+
anonymizeIp(stats: string): string {
|
|
135
|
+
const data = JSON.parse(stats);
|
|
136
|
+
// on local and remote candidates, anonymize the last 4 bits.
|
|
137
|
+
if (data.type === 'local-candidate' || data.type === 'remote-candidate') {
|
|
138
|
+
data.ip = CallDiagnosticUtils.anonymizeIPAddress(data.ip) || undefined;
|
|
139
|
+
data.address = CallDiagnosticUtils.anonymizeIPAddress(data.address) || undefined;
|
|
140
|
+
data.relatedAddress =
|
|
141
|
+
CallDiagnosticUtils.anonymizeIPAddress(data.relatedAddress) || undefined;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return JSON.stringify(data);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Set a new connection id.
|
|
149
|
+
*
|
|
150
|
+
* @returns {void}
|
|
151
|
+
*/
|
|
152
|
+
private resetConnection() {
|
|
153
|
+
this.connectionId = uuid.v4();
|
|
154
|
+
this.shouldSendMetricsOnNextStatsReport = true;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Send metrics to the metrics service.
|
|
159
|
+
*
|
|
160
|
+
* @returns {void}
|
|
161
|
+
*/
|
|
162
|
+
private sendMetrics() {
|
|
163
|
+
this.webex.request({
|
|
164
|
+
method: 'POST',
|
|
165
|
+
service: 'unifiedTelemetry',
|
|
166
|
+
resource: 'metric/v2',
|
|
167
|
+
headers: {
|
|
168
|
+
type: 'webrtcMedia',
|
|
169
|
+
appId: RTC_METRICS.APP_ID,
|
|
170
|
+
},
|
|
171
|
+
body: {
|
|
172
|
+
metrics: [
|
|
173
|
+
{
|
|
174
|
+
type: 'webrtc',
|
|
175
|
+
version: '1.1.0',
|
|
176
|
+
userId: this.webex.internal.device.userId,
|
|
177
|
+
meetingId: this.meetingId,
|
|
178
|
+
correlationId: this.correlationId,
|
|
179
|
+
connectionId: this.connectionId,
|
|
180
|
+
data: this.metricsQueue,
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
@@ -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
|
});
|
|
@@ -441,7 +441,7 @@ describe('plugin-metrics', () => {
|
|
|
441
441
|
// item also gets assigned a delay property but the key is a Symbol and haven't been able to test that..
|
|
442
442
|
assert.deepEqual(calls.args[0].eventPayload, {
|
|
443
443
|
event: 'my.event',
|
|
444
|
-
origin: {buildType: 'test', networkType: 'unknown'},
|
|
444
|
+
origin: {buildType: 'test', networkType: 'unknown', upgradeChannel: 'test'},
|
|
445
445
|
});
|
|
446
446
|
|
|
447
447
|
assert.deepEqual(calls.args[0].type, ['diagnostic-event']);
|
|
@@ -455,6 +455,7 @@ describe('plugin-metrics', () => {
|
|
|
455
455
|
origin: {
|
|
456
456
|
buildType: 'test',
|
|
457
457
|
networkType: 'unknown',
|
|
458
|
+
upgradeChannel: 'test',
|
|
458
459
|
},
|
|
459
460
|
});
|
|
460
461
|
assert.deepEqual(prepareDiagnosticMetricItemCalls[0].args[1].type, ['diagnostic-event']);
|
|
@@ -12,12 +12,10 @@ describe('internal-plugin-metrics', () => {
|
|
|
12
12
|
sinon.useFakeTimers(now.getTime());
|
|
13
13
|
const webex = {
|
|
14
14
|
meetings: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
},
|
|
15
|
+
getBasicMeetingInformation: (id: string) => {
|
|
16
|
+
if (id === 'meeting-id') {
|
|
17
|
+
return {id: 'meeting-id', allowMediaInLobby: true};
|
|
18
|
+
}
|
|
21
19
|
},
|
|
22
20
|
},
|
|
23
21
|
};
|