@webex/internal-plugin-metrics 3.5.0-wxcc.1 → 3.6.0

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.
Files changed (55) hide show
  1. package/dist/business-metrics.js +119 -9
  2. package/dist/business-metrics.js.map +1 -1
  3. package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js +1 -1
  4. package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js.map +1 -1
  5. package/dist/call-diagnostic/call-diagnostic-metrics.js +18 -7
  6. package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -1
  7. package/dist/call-diagnostic/call-diagnostic-metrics.util.js +7 -2
  8. package/dist/call-diagnostic/call-diagnostic-metrics.util.js.map +1 -1
  9. package/dist/call-diagnostic/config.js +13 -3
  10. package/dist/call-diagnostic/config.js.map +1 -1
  11. package/dist/call-diagnostic-events-batcher.js +59 -0
  12. package/dist/call-diagnostic-events-batcher.js.map +1 -0
  13. package/dist/index.js +7 -0
  14. package/dist/index.js.map +1 -1
  15. package/dist/metrics.js +1 -1
  16. package/dist/metrics.types.js.map +1 -1
  17. package/dist/new-metrics.js +5 -2
  18. package/dist/new-metrics.js.map +1 -1
  19. package/dist/rtcMetrics/constants.js +11 -0
  20. package/dist/rtcMetrics/constants.js.map +1 -0
  21. package/dist/rtcMetrics/index.js +223 -0
  22. package/dist/rtcMetrics/index.js.map +1 -0
  23. package/dist/types/business-metrics.d.ts +36 -4
  24. package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +6 -1
  25. package/dist/types/call-diagnostic/config.d.ts +3 -0
  26. package/dist/types/index.d.ts +2 -1
  27. package/dist/types/metrics.types.d.ts +17 -2
  28. package/dist/types/new-metrics.d.ts +5 -3
  29. package/dist/types/rtcMetrics/constants.d.ts +4 -0
  30. package/dist/types/rtcMetrics/index.d.ts +80 -0
  31. package/package.json +11 -11
  32. package/src/business-metrics.ts +97 -5
  33. package/src/call-diagnostic/call-diagnostic-metrics-latencies.ts +1 -1
  34. package/src/call-diagnostic/call-diagnostic-metrics.ts +17 -7
  35. package/src/call-diagnostic/call-diagnostic-metrics.util.ts +11 -5
  36. package/src/call-diagnostic/config.ts +12 -0
  37. package/src/index.ts +2 -0
  38. package/src/metrics.types.ts +95 -23
  39. package/src/new-metrics.ts +12 -2
  40. package/src/rtcMetrics/constants.ts +3 -0
  41. package/src/rtcMetrics/index.ts +205 -0
  42. package/test/unit/spec/business/business-metrics.ts +69 -2
  43. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +2 -1
  44. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-latencies.ts +4 -6
  45. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +406 -11
  46. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.util.ts +7 -3
  47. package/test/unit/spec/new-metrics.ts +18 -3
  48. package/test/unit/spec/prelogin-metrics-batcher.ts +3 -1
  49. package/test/unit/spec/rtcMetrics/index.ts +196 -0
  50. package/dist/behavioral/behavioral-metrics.js +0 -199
  51. package/dist/behavioral/behavioral-metrics.js.map +0 -1
  52. package/dist/behavioral/config.js +0 -11
  53. package/dist/behavioral/config.js.map +0 -1
  54. package/dist/types/behavioral/behavioral-metrics.d.ts +0 -63
  55. package/dist/types/behavioral/config.d.ts +0 -1
@@ -20,6 +20,8 @@ describe('internal-plugin-metrics', () => {
20
20
 
21
21
  beforeEach(() => {
22
22
  now = new Date();
23
+ sinon.createSandbox();
24
+ sinon.useFakeTimers(now.getTime());
23
25
 
24
26
  webex = {
25
27
  canAuthorize: true,
@@ -74,7 +76,7 @@ describe('internal-plugin-metrics', () => {
74
76
  });
75
77
 
76
78
  describe('#sendEvent', () => {
77
- it('should send correctly shaped business event (check name building and internal tagged event building)', () => {
79
+ it('should send correctly shaped business event (check name building and internal tagged event building) and default correctly', () => {
78
80
  // For some reasons `jest` isn't available when testing form build server - so can't use `jest.fn()` here...
79
81
  const requestCalls = [];
80
82
  const request = function(arg) { requestCalls.push(arg) }
@@ -86,6 +88,7 @@ describe('internal-plugin-metrics', () => {
86
88
  assert.equal(requestCalls.length, 1)
87
89
  assert.deepEqual(requestCalls[0], {
88
90
  eventPayload: {
91
+ appType: 'Web Client',
89
92
  context: {
90
93
  app: {version: 'webex-version'},
91
94
  device: {id: 'deviceId'},
@@ -113,8 +116,72 @@ describe('internal-plugin-metrics', () => {
113
116
  },
114
117
  type: ['business'],
115
118
  });
116
- assert.isNumber(requestCalls[0].eventPayload.client_timestamp)
119
+ assert.isString(requestCalls[0].eventPayload.client_timestamp)
120
+ assert.equal(requestCalls[0].eventPayload.client_timestamp, now.toISOString())
117
121
  })
122
+
123
+ describe('when table is provided', () => {
124
+ it('should send correctly shaped business event with table: wbx_app_callend_metrics and ignore the key name', () => {
125
+ // For some reasons `jest` isn't available when testing form build server - so can't use `jest.fn()` here...
126
+ const requestCalls = [];
127
+ const request = function(arg) { requestCalls.push(arg) }
128
+
129
+ businessMetrics.clientMetricsBatcher.request = request;
130
+
131
+ assert.equal(requestCalls.length, 0)
132
+ businessMetrics.submitBusinessEvent({ name: "foobar", payload: {bar:"gee"}, table: 'wbxapp_callend_metrics' })
133
+ assert.equal(requestCalls.length, 1)
134
+ assert.deepEqual(requestCalls[0], {
135
+ eventPayload: {
136
+ key: 'callEnd',
137
+ client_timestamp: requestCalls[0].eventPayload.client_timestamp, // This is to bypass time check, which is checked below.
138
+ appType: 'Web Client',
139
+ value: {
140
+ bar: 'gee'
141
+ }
142
+ },
143
+ type: ['business'],
144
+ });
145
+ assert.isString(requestCalls[0].eventPayload.client_timestamp)
146
+ assert.equal(requestCalls[0].eventPayload.client_timestamp, now.toISOString())
147
+ });
148
+
149
+ it('should send correctly shaped business event with table: business_metrics', () => {
150
+ // For some reasons `jest` isn't available when testing form build server - so can't use `jest.fn()` here...
151
+ const requestCalls = [];
152
+ const request = function(arg) { requestCalls.push(arg) }
153
+
154
+ businessMetrics.clientMetricsBatcher.request = request;
155
+
156
+ assert.equal(requestCalls.length, 0)
157
+ businessMetrics.submitBusinessEvent({ name: "foobar", payload: {bar:"gee"}, table: 'business_metrics' })
158
+ assert.equal(requestCalls.length, 1)
159
+ assert.deepEqual(requestCalls[0], {
160
+ eventPayload: {
161
+ key: 'foobar',
162
+ appType: 'Web Client',
163
+ client_timestamp: requestCalls[0].eventPayload.client_timestamp, // This is to bypass time check, which is checked below.
164
+ value: {
165
+ bar: "gee",
166
+ browser: getBrowserName(),
167
+ browserHeight: window.innerHeight,
168
+ browserVersion: getBrowserVersion(),
169
+ browserWidth: window.innerWidth,
170
+ domain: window.location.hostname,
171
+ inIframe: false,
172
+ locale: window.navigator.language,
173
+ os: getOSNameInternal(),
174
+ app: {version: 'webex-version'},
175
+ device: {id: 'deviceId'},
176
+ locale: 'language',
177
+ }
178
+ },
179
+ type: ['business'],
180
+ });
181
+ assert.isString(requestCalls[0].eventPayload.client_timestamp)
182
+ assert.equal(requestCalls[0].eventPayload.client_timestamp, now.toISOString())
183
+ });
184
+ });
118
185
  })
119
186
  });
120
187
  });
@@ -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
- meetingCollection: {
16
- get: (id: string) => {
17
- if (id === 'meeting-id') {
18
- return {id: 'meeting-id', allowMediaInLobby: true};
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
  };