@webex/calling 3.12.0-mobius-socket.16 → 3.12.0-mobius-socket.18

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.
@@ -312,9 +312,13 @@ describe('CALLING: Metric tests', function () {
312
312
  });
313
313
  });
314
314
  describe('Voicemail metric tests', function () {
315
+ var originalProcess = global.process;
315
316
  beforeAll(function () {
316
317
  return metricManager.setDeviceInfo(mockDeviceInfo);
317
318
  });
319
+ afterEach(function () {
320
+ global.process = originalProcess;
321
+ });
318
322
  it('submit voicemail success metric', function () {
319
323
  var expectedData1 = {
320
324
  tags: {
@@ -367,6 +371,44 @@ describe('CALLING: Metric tests', function () {
367
371
  metricManager.submitVoicemailMetric(_types.METRIC_EVENT.VOICEMAIL_ERROR, _types.VOICEMAIL_ACTION.DELETE, _types.METRIC_TYPE.BEHAVIORAL, 'messageId', errorMessage, 401);
368
372
  expect(submitClientMetricSpy).toBeCalledOnceWith(_types.METRIC_EVENT.VOICEMAIL_ERROR, expectedData2);
369
373
  });
374
+ it('submit voicemail metric with undefined process object', function () {
375
+ // Mock process as undefined (browser environment)
376
+ global.process = undefined;
377
+ var expectedData = {
378
+ tags: {
379
+ action: _types.VOICEMAIL_ACTION.GET_VOICEMAILS,
380
+ device_id: mockDeviceInfo.device.deviceId
381
+ },
382
+ fields: {
383
+ device_url: mockDeviceInfo.device.clientDeviceUri,
384
+ calling_sdk_version: _constants.VERSION
385
+ },
386
+ type: _types.METRIC_TYPE.BEHAVIORAL
387
+ };
388
+ metricManager.submitVoicemailMetric(_types.METRIC_EVENT.VOICEMAIL, _types.VOICEMAIL_ACTION.GET_VOICEMAILS, _types.METRIC_TYPE.BEHAVIORAL);
389
+ expect(submitClientMetricSpy).toBeCalledOnceWith(_types.METRIC_EVENT.VOICEMAIL, expectedData);
390
+ });
391
+ it('submit voicemail error metric with undefined process object', function () {
392
+ // Mock process as undefined (browser environment)
393
+ global.process = undefined;
394
+ var errorMessage = 'Network error';
395
+ var expectedData = {
396
+ tags: {
397
+ action: _types.VOICEMAIL_ACTION.MARK_READ,
398
+ device_id: mockDeviceInfo.device.deviceId,
399
+ message_id: 'msg-123',
400
+ error: errorMessage,
401
+ status_code: 500
402
+ },
403
+ fields: {
404
+ device_url: mockDeviceInfo.device.clientDeviceUri,
405
+ calling_sdk_version: _constants.VERSION
406
+ },
407
+ type: _types.METRIC_TYPE.BEHAVIORAL
408
+ };
409
+ metricManager.submitVoicemailMetric(_types.METRIC_EVENT.VOICEMAIL_ERROR, _types.VOICEMAIL_ACTION.MARK_READ, _types.METRIC_TYPE.BEHAVIORAL, 'msg-123', errorMessage, 500);
410
+ expect(submitClientMetricSpy).toBeCalledOnceWith(_types.METRIC_EVENT.VOICEMAIL_ERROR, expectedData);
411
+ });
370
412
  it('submit unknown voicemail metric', function () {
371
413
  var logSpy = jest.spyOn(_Logger.default, 'warn');
372
414
  metricManager.submitVoicemailMetric('invalidMetricName', _types.VOICEMAIL_ACTION.GET_VOICEMAILS, _types.METRIC_TYPE.BEHAVIORAL);
@@ -399,6 +441,320 @@ describe('CALLING: Metric tests', function () {
399
441
  expect(submitClientMetricSpy).toBeCalledOnceWith(_types.METRIC_EVENT.BNR_ENABLED, expectedData);
400
442
  });
401
443
  });
444
+ describe('Connection metric tests', function () {
445
+ beforeAll(function () {
446
+ return metricManager.setDeviceInfo(mockDeviceInfo);
447
+ });
448
+ it('submit connection metric for network flap', function () {
449
+ var downTimestamp = '2026-05-04T10:00:00.000Z';
450
+ var upTimestamp = '2026-05-04T10:05:00.000Z';
451
+ var expectedData = {
452
+ tags: {
453
+ metricAction: 'network_flap',
454
+ device_id: mockDeviceInfo.device.deviceId,
455
+ service_indicator: _types3.ServiceIndicator.CALLING
456
+ },
457
+ fields: {
458
+ device_url: mockDeviceInfo.device.clientDeviceUri,
459
+ mobius_url: mockDeviceInfo.device.uri,
460
+ calling_sdk_version: MOCK_VERSION_NUMBER,
461
+ downTimestamp: downTimestamp,
462
+ upTimestamp: upTimestamp
463
+ },
464
+ type: _types.METRIC_TYPE.BEHAVIORAL
465
+ };
466
+ metricManager.submitConnectionMetrics(_types.METRIC_EVENT.CONNECTION_ERROR, _types.CONNECTION_ACTION.NETWORK_FLAP, _types.METRIC_TYPE.BEHAVIORAL, downTimestamp, upTimestamp);
467
+ expect(submitClientMetricSpy).toBeCalledOnceWith(_types.METRIC_EVENT.CONNECTION_ERROR, expectedData);
468
+ });
469
+ it('submit connection metric for mercury down', function () {
470
+ var downTimestamp = '2026-05-04T10:10:00.000Z';
471
+ var upTimestamp = '2026-05-04T10:15:00.000Z';
472
+ var expectedData = {
473
+ tags: {
474
+ metricAction: 'mercury_down',
475
+ device_id: mockDeviceInfo.device.deviceId,
476
+ service_indicator: _types3.ServiceIndicator.CALLING
477
+ },
478
+ fields: {
479
+ device_url: mockDeviceInfo.device.clientDeviceUri,
480
+ mobius_url: mockDeviceInfo.device.uri,
481
+ calling_sdk_version: MOCK_VERSION_NUMBER,
482
+ downTimestamp: downTimestamp,
483
+ upTimestamp: upTimestamp
484
+ },
485
+ type: _types.METRIC_TYPE.OPERATIONAL
486
+ };
487
+ metricManager.submitConnectionMetrics(_types.METRIC_EVENT.CONNECTION_ERROR, _types.CONNECTION_ACTION.MERCURY_DOWN, _types.METRIC_TYPE.OPERATIONAL, downTimestamp, upTimestamp);
488
+ expect(submitClientMetricSpy).toBeCalledOnceWith(_types.METRIC_EVENT.CONNECTION_ERROR, expectedData);
489
+ });
490
+ });
491
+ describe('Region Info metric tests', function () {
492
+ beforeAll(function () {
493
+ return metricManager.setDeviceInfo(mockDeviceInfo);
494
+ });
495
+ it('submit region info metric with all parameters', function () {
496
+ var trackingId = 'track-region-123';
497
+ var mobiusHost = 'mobius-us-east.webex.com';
498
+ var clientRegion = 'US-EAST';
499
+ var countryCode = 'US';
500
+ var expectedData = {
501
+ tags: {
502
+ action: 'region-info',
503
+ device_id: mockDeviceInfo.device.deviceId,
504
+ service_indicator: _types3.ServiceIndicator.CALLING
505
+ },
506
+ fields: {
507
+ device_url: mockDeviceInfo.device.clientDeviceUri,
508
+ mobius_url: mockDeviceInfo.device.uri,
509
+ calling_sdk_version: MOCK_VERSION_NUMBER,
510
+ mobius_host: mobiusHost,
511
+ client_region: clientRegion,
512
+ country_code: countryCode,
513
+ tracking_id: trackingId
514
+ },
515
+ type: _types.METRIC_TYPE.BEHAVIORAL
516
+ };
517
+ metricManager.submitRegionInfoMetric(_types.METRIC_EVENT.MOBIUS_DISCOVERY, 'region-info', _types.METRIC_TYPE.BEHAVIORAL, mobiusHost, clientRegion, countryCode, trackingId);
518
+ expect(submitClientMetricSpy).toBeCalledOnceWith(_types.METRIC_EVENT.MOBIUS_DISCOVERY, expectedData);
519
+ });
520
+ it('submit region info metric without tracking ID', function () {
521
+ var mobiusHost = 'mobius-eu-west.webex.com';
522
+ var clientRegion = 'EU-WEST';
523
+ var countryCode = 'GB';
524
+ var expectedData = {
525
+ tags: {
526
+ action: 'region-info',
527
+ device_id: mockDeviceInfo.device.deviceId,
528
+ service_indicator: _types3.ServiceIndicator.CALLING
529
+ },
530
+ fields: {
531
+ device_url: mockDeviceInfo.device.clientDeviceUri,
532
+ mobius_url: mockDeviceInfo.device.uri,
533
+ calling_sdk_version: MOCK_VERSION_NUMBER,
534
+ mobius_host: mobiusHost,
535
+ client_region: clientRegion,
536
+ country_code: countryCode,
537
+ tracking_id: undefined
538
+ },
539
+ type: _types.METRIC_TYPE.OPERATIONAL
540
+ };
541
+ metricManager.submitRegionInfoMetric(_types.METRIC_EVENT.MOBIUS_DISCOVERY, 'region-info', _types.METRIC_TYPE.OPERATIONAL, mobiusHost, clientRegion, countryCode, undefined);
542
+ expect(submitClientMetricSpy).toBeCalledOnceWith(_types.METRIC_EVENT.MOBIUS_DISCOVERY, expectedData);
543
+ });
544
+ });
545
+ describe('Mobius Servers metric tests', function () {
546
+ beforeAll(function () {
547
+ return metricManager.setDeviceInfo(mockDeviceInfo);
548
+ });
549
+ it('submit mobius servers metric with primary and backup servers', function () {
550
+ var trackingId = 'track-servers-456';
551
+ var mobiusServers = {
552
+ primary: {
553
+ region: 'US-EAST',
554
+ uris: ['wss://mobius-us-east-1.webex.com/api/v1', 'wss://mobius-us-east-2.webex.com/api/v1']
555
+ },
556
+ backup: {
557
+ region: 'US-WEST',
558
+ uris: ['wss://mobius-us-west-1.webex.com/api/v1']
559
+ }
560
+ };
561
+ var expectedData = {
562
+ tags: {
563
+ action: 'mobius-servers',
564
+ device_id: mockDeviceInfo.device.deviceId,
565
+ service_indicator: _types3.ServiceIndicator.CALLING
566
+ },
567
+ fields: {
568
+ device_url: mockDeviceInfo.device.clientDeviceUri,
569
+ mobius_url: mockDeviceInfo.device.uri,
570
+ calling_sdk_version: MOCK_VERSION_NUMBER,
571
+ primary_mobius_servers_region: 'US-EAST',
572
+ primary_mobius_servers_uris: 'wss://mobius-us-east-1.webex.com/api/v1,wss://mobius-us-east-2.webex.com/api/v1',
573
+ backup_mobius_servers_region: 'US-WEST',
574
+ backup_mobius_servers_uris: 'wss://mobius-us-west-1.webex.com/api/v1',
575
+ tracking_id: trackingId
576
+ },
577
+ type: _types.METRIC_TYPE.BEHAVIORAL
578
+ };
579
+ metricManager.submitMobiusServersMetric(_types.METRIC_EVENT.MOBIUS_DISCOVERY, 'mobius-servers', _types.METRIC_TYPE.BEHAVIORAL, mobiusServers, trackingId);
580
+ expect(submitClientMetricSpy).toBeCalledOnceWith(_types.METRIC_EVENT.MOBIUS_DISCOVERY, expectedData);
581
+ });
582
+ it('submit mobius servers metric without tracking ID', function () {
583
+ var mobiusServers = {
584
+ primary: {
585
+ region: 'EU-CENTRAL',
586
+ uris: ['wss://mobius-eu-central.webex.com/api/v1']
587
+ },
588
+ backup: {
589
+ region: 'EU-WEST',
590
+ uris: ['wss://mobius-eu-west.webex.com/api/v1', 'wss://mobius-eu-west-2.webex.com/api/v1']
591
+ }
592
+ };
593
+ var expectedData = {
594
+ tags: {
595
+ action: 'mobius-servers',
596
+ device_id: mockDeviceInfo.device.deviceId,
597
+ service_indicator: _types3.ServiceIndicator.CALLING
598
+ },
599
+ fields: {
600
+ device_url: mockDeviceInfo.device.clientDeviceUri,
601
+ mobius_url: mockDeviceInfo.device.uri,
602
+ calling_sdk_version: MOCK_VERSION_NUMBER,
603
+ primary_mobius_servers_region: 'EU-CENTRAL',
604
+ primary_mobius_servers_uris: 'wss://mobius-eu-central.webex.com/api/v1',
605
+ backup_mobius_servers_region: 'EU-WEST',
606
+ backup_mobius_servers_uris: 'wss://mobius-eu-west.webex.com/api/v1,wss://mobius-eu-west-2.webex.com/api/v1',
607
+ tracking_id: undefined
608
+ },
609
+ type: _types.METRIC_TYPE.OPERATIONAL
610
+ };
611
+ metricManager.submitMobiusServersMetric(_types.METRIC_EVENT.MOBIUS_DISCOVERY, 'mobius-servers', _types.METRIC_TYPE.OPERATIONAL, mobiusServers, undefined);
612
+ expect(submitClientMetricSpy).toBeCalledOnceWith(_types.METRIC_EVENT.MOBIUS_DISCOVERY, expectedData);
613
+ });
614
+ });
615
+ describe('Mobius Socket metric tests', function () {
616
+ beforeAll(function () {
617
+ return metricManager.setDeviceInfo(mockDeviceInfo);
618
+ });
619
+ it('submit mobius socket connect success metric', function () {
620
+ var wssUrl = 'wss://mobius.webex.com/api/v1';
621
+ var trackingId = 'track-socket-123';
622
+ var expectedData = {
623
+ tags: {
624
+ action: 'connect',
625
+ device_id: mockDeviceInfo.device.deviceId,
626
+ service_indicator: _types3.ServiceIndicator.CALLING
627
+ },
628
+ fields: {
629
+ device_url: mockDeviceInfo.device.clientDeviceUri,
630
+ mobius_url: mockDeviceInfo.device.uri,
631
+ calling_sdk_version: MOCK_VERSION_NUMBER,
632
+ wss_url: wssUrl,
633
+ tracking_id: trackingId,
634
+ event_type: undefined
635
+ },
636
+ type: _types.METRIC_TYPE.BEHAVIORAL
637
+ };
638
+ metricManager.submitMobiusSocketMetric(_types.METRIC_EVENT.MOBIUS_SOCKET, _types.MOBIUS_SOCKET_ACTION.CONNECT, _types.METRIC_TYPE.BEHAVIORAL, wssUrl, trackingId);
639
+ expect(submitClientMetricSpy).toBeCalledOnceWith(_types.METRIC_EVENT.MOBIUS_SOCKET, expectedData);
640
+ });
641
+ it('submit mobius socket disconnect success metric', function () {
642
+ var expectedData = {
643
+ tags: {
644
+ action: 'disconnect',
645
+ device_id: mockDeviceInfo.device.deviceId,
646
+ service_indicator: _types3.ServiceIndicator.CALLING
647
+ },
648
+ fields: {
649
+ device_url: mockDeviceInfo.device.clientDeviceUri,
650
+ mobius_url: mockDeviceInfo.device.uri,
651
+ calling_sdk_version: MOCK_VERSION_NUMBER,
652
+ wss_url: undefined,
653
+ tracking_id: undefined,
654
+ event_type: undefined
655
+ },
656
+ type: _types.METRIC_TYPE.BEHAVIORAL
657
+ };
658
+ metricManager.submitMobiusSocketMetric(_types.METRIC_EVENT.MOBIUS_SOCKET, _types.MOBIUS_SOCKET_ACTION.DISCONNECT, _types.METRIC_TYPE.BEHAVIORAL);
659
+ expect(submitClientMetricSpy).toBeCalledOnceWith(_types.METRIC_EVENT.MOBIUS_SOCKET, expectedData);
660
+ });
661
+ it('submit mobius socket listener registered metric', function () {
662
+ var expectedData = {
663
+ tags: {
664
+ action: 'listener_registered',
665
+ device_id: mockDeviceInfo.device.deviceId,
666
+ service_indicator: _types3.ServiceIndicator.CALLING
667
+ },
668
+ fields: {
669
+ device_url: mockDeviceInfo.device.clientDeviceUri,
670
+ mobius_url: mockDeviceInfo.device.uri,
671
+ calling_sdk_version: MOCK_VERSION_NUMBER,
672
+ wss_url: undefined,
673
+ tracking_id: undefined,
674
+ event_type: undefined
675
+ },
676
+ type: _types.METRIC_TYPE.BEHAVIORAL
677
+ };
678
+ metricManager.submitMobiusSocketMetric(_types.METRIC_EVENT.MOBIUS_SOCKET, _types.MOBIUS_SOCKET_ACTION.LISTENER_REGISTERED, _types.METRIC_TYPE.BEHAVIORAL);
679
+ expect(submitClientMetricSpy).toBeCalledOnceWith(_types.METRIC_EVENT.MOBIUS_SOCKET, expectedData);
680
+ });
681
+ it('submit mobius socket listener unregistered metric', function () {
682
+ var expectedData = {
683
+ tags: {
684
+ action: 'listener_unregistered',
685
+ device_id: mockDeviceInfo.device.deviceId,
686
+ service_indicator: _types3.ServiceIndicator.CALLING
687
+ },
688
+ fields: {
689
+ device_url: mockDeviceInfo.device.clientDeviceUri,
690
+ mobius_url: mockDeviceInfo.device.uri,
691
+ calling_sdk_version: MOCK_VERSION_NUMBER,
692
+ wss_url: undefined,
693
+ tracking_id: undefined,
694
+ event_type: undefined
695
+ },
696
+ type: _types.METRIC_TYPE.BEHAVIORAL
697
+ };
698
+ metricManager.submitMobiusSocketMetric(_types.METRIC_EVENT.MOBIUS_SOCKET, _types.MOBIUS_SOCKET_ACTION.LISTENER_UNREGISTERED, _types.METRIC_TYPE.BEHAVIORAL);
699
+ expect(submitClientMetricSpy).toBeCalledOnceWith(_types.METRIC_EVENT.MOBIUS_SOCKET, expectedData);
700
+ });
701
+ it('submit mobius socket error metric with connection failure', function () {
702
+ var wssUrl = 'wss://mobius.webex.com/api/v1';
703
+ var trackingId = 'track-error-456';
704
+ var error = 'WebSocket connection failed: timeout';
705
+ var expectedData = {
706
+ tags: {
707
+ action: 'connect',
708
+ device_id: mockDeviceInfo.device.deviceId,
709
+ service_indicator: _types3.ServiceIndicator.CALLING
710
+ },
711
+ fields: {
712
+ device_url: mockDeviceInfo.device.clientDeviceUri,
713
+ mobius_url: mockDeviceInfo.device.uri,
714
+ calling_sdk_version: MOCK_VERSION_NUMBER,
715
+ wss_url: wssUrl,
716
+ tracking_id: trackingId,
717
+ event_type: undefined,
718
+ error: error
719
+ },
720
+ type: _types.METRIC_TYPE.BEHAVIORAL
721
+ };
722
+ metricManager.submitMobiusSocketMetric(_types.METRIC_EVENT.MOBIUS_SOCKET_ERROR, _types.MOBIUS_SOCKET_ACTION.CONNECT, _types.METRIC_TYPE.BEHAVIORAL, wssUrl, trackingId, error);
723
+ expect(submitClientMetricSpy).toBeCalledOnceWith(_types.METRIC_EVENT.MOBIUS_SOCKET_ERROR, expectedData);
724
+ });
725
+ it('submit mobius socket error metric with registration down event', function () {
726
+ var trackingId = 'track-regdown-789';
727
+ var eventType = 'registration.down';
728
+ var expectedData = {
729
+ tags: {
730
+ action: 'registration_down',
731
+ device_id: mockDeviceInfo.device.deviceId,
732
+ service_indicator: _types3.ServiceIndicator.CALLING
733
+ },
734
+ fields: {
735
+ device_url: mockDeviceInfo.device.clientDeviceUri,
736
+ mobius_url: mockDeviceInfo.device.uri,
737
+ calling_sdk_version: MOCK_VERSION_NUMBER,
738
+ wss_url: undefined,
739
+ tracking_id: trackingId,
740
+ event_type: eventType,
741
+ error: undefined
742
+ },
743
+ type: _types.METRIC_TYPE.BEHAVIORAL
744
+ };
745
+ metricManager.submitMobiusSocketMetric(_types.METRIC_EVENT.MOBIUS_SOCKET_ERROR, _types.MOBIUS_SOCKET_ACTION.REGISTRATION_DOWN, _types.METRIC_TYPE.BEHAVIORAL, undefined, trackingId, undefined, eventType);
746
+ expect(submitClientMetricSpy).toBeCalledOnceWith(_types.METRIC_EVENT.MOBIUS_SOCKET_ERROR, expectedData);
747
+ });
748
+ it('submit unknown mobius socket metric', function () {
749
+ var logSpy = jest.spyOn(_Logger.default, 'warn');
750
+ metricManager.submitMobiusSocketMetric('invalidMetricName', _types.MOBIUS_SOCKET_ACTION.CONNECT, _types.METRIC_TYPE.BEHAVIORAL);
751
+ expect(submitClientMetricSpy).not.toBeCalled();
752
+ expect(logSpy).toBeCalledOnceWith('Invalid metric name received. Rejecting request to submit metric.', {
753
+ file: 'metric',
754
+ method: 'submitMobiusSocketMetric'
755
+ });
756
+ });
757
+ });
402
758
  describe('Upload Logs metric tests', function () {
403
759
  beforeAll(function () {
404
760
  return metricManager.setDeviceInfo(mockDeviceInfo);