@webex/internal-plugin-metrics 3.8.1-web-workers-keepalive.1 → 3.9.0-multipleLLM.1

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.
@@ -17,7 +17,7 @@ describe('internal-plugin-metrics', () => {
17
17
  let webex;
18
18
  let clock;
19
19
  let now;
20
-
20
+ const deviceManagerStub = {getPairedDevice: sinon.stub()};
21
21
  const preLoginId = 'my_prelogin_id';
22
22
 
23
23
  beforeEach(() => {
@@ -30,6 +30,7 @@ describe('internal-plugin-metrics', () => {
30
30
  newMetrics: NewMetrics,
31
31
  },
32
32
  });
33
+ webex.devicemanager = deviceManagerStub;
33
34
 
34
35
  webex.request = (options) =>
35
36
  Promise.resolve({body: {items: []}, waitForServiceTimeout: 15, options});
@@ -217,9 +218,7 @@ describe('internal-plugin-metrics', () => {
217
218
  });
218
219
 
219
220
  assert.deepEqual(calls.args[0].type, ['diagnostic-event']);
220
-
221
221
  const prepareDiagnosticMetricItemCalls = prepareDiagnosticMetricItemSpy.getCalls();
222
-
223
222
  // second argument (item) also gets assigned a delay property but the key is a Symbol and haven't been able to test that..
224
223
  assert.deepEqual(prepareDiagnosticMetricItemCalls[0].args[0], webex);
225
224
  assert.deepEqual(prepareDiagnosticMetricItemCalls[0].args[1].eventPayload, {
@@ -232,6 +231,75 @@ describe('internal-plugin-metrics', () => {
232
231
  });
233
232
  assert.deepEqual(prepareDiagnosticMetricItemCalls[0].args[1].type, ['diagnostic-event']);
234
233
  });
234
+ it('adds the paired device to the metric payload if paired', async () => {
235
+ webex.internal.newMetrics.callDiagnosticMetrics.preLoginMetricsBatcher.prepareRequest = (
236
+ q
237
+ ) => Promise.resolve(q);
238
+ webex.devicemanager.getPairedDevice = sinon.stub().returns({
239
+ deviceInfo: {
240
+ id: 'my_device_id',
241
+ },
242
+ url: 'my_url',
243
+ mode: 'personal',
244
+ devices: [{productName: 'my_product_name'}],
245
+ });
246
+ webex.devicemanager.getPairedMethod = sinon.stub().returns("Manual");
247
+
248
+ const prepareItemSpy = sinon.spy(
249
+ webex.internal.newMetrics.callDiagnosticMetrics.preLoginMetricsBatcher,
250
+ 'prepareItem'
251
+ );
252
+ const prepareDiagnosticMetricItemSpy = sinon.spy(
253
+ CallDiagnosticUtils,
254
+ 'prepareDiagnosticMetricItem'
255
+ );
256
+
257
+ const promise =
258
+ webex.internal.newMetrics.callDiagnosticMetrics.submitToCallDiagnosticsPreLogin(
259
+ {
260
+ event: {name: 'client.interstitial-window.launched'},
261
+ },
262
+ preLoginId
263
+ );
264
+
265
+ await flushPromises();
266
+
267
+ clock.tick(config.metrics.batcherWait);
268
+
269
+ await promise;
270
+
271
+ const calls = prepareItemSpy.getCalls()[0];
272
+
273
+ assert.deepEqual(calls.args[0].eventPayload, {
274
+ event: {
275
+ joinTimes: {
276
+ meetingInfoReqResp: undefined,
277
+ clickToInterstitial: undefined,
278
+ clickToInterstitialWithUserDelay: undefined,
279
+ refreshCaptchaServiceReqResp: undefined,
280
+ downloadIntelligenceModelsReqResp: undefined,
281
+ },
282
+ name: 'client.interstitial-window.launched',
283
+ pairedDevice: {
284
+ deviceId: 'my_device_id',
285
+ deviceURL: 'my_url',
286
+ devicePairingType: 'Manual',
287
+ productName: 'my_product_name',
288
+ isPersonalDevice: true,
289
+ },
290
+ pairingState: 'paired',
291
+ },
292
+ origin: {
293
+ buildType: 'test',
294
+ networkType: 'unknown',
295
+ upgradeChannel: 'test',
296
+ },
297
+ });
298
+
299
+ assert.deepEqual(calls.args[0].type, ['diagnostic-event']);
300
+ assert.calledOnce(webex.devicemanager.getPairedDevice);
301
+
302
+ });
235
303
  });
236
304
 
237
305
  describe('savePreLoginId', () => {