@webex/internal-plugin-metrics 3.12.0-next.27 → 3.12.0-next.29
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/call-diagnostic/call-diagnostic-metrics-batcher.js +1 -10
- package/dist/call-diagnostic/call-diagnostic-metrics-batcher.js.map +1 -1
- package/dist/call-diagnostic/call-diagnostic-metrics.js +24 -7
- package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -1
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js +5 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js.map +1 -1
- package/dist/metrics.js +1 -1
- package/dist/prelogin-metrics-batcher.js +1 -10
- package/dist/prelogin-metrics-batcher.js.map +1 -1
- package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +12 -9
- package/package.json +2 -2
- package/src/call-diagnostic/call-diagnostic-metrics-batcher.ts +1 -11
- package/src/call-diagnostic/call-diagnostic-metrics.ts +22 -6
- package/src/call-diagnostic/call-diagnostic-metrics.util.ts +5 -0
- package/src/prelogin-metrics-batcher.ts +1 -11
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +52 -33
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +86 -8
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.util.ts +27 -0
- package/test/unit/spec/prelogin-metrics-batcher.ts +52 -33
|
@@ -460,6 +460,33 @@ describe('internal-plugin-metrics', () => {
|
|
|
460
460
|
});
|
|
461
461
|
});
|
|
462
462
|
|
|
463
|
+
it('logs a Milestone entry when event name is present', () => {
|
|
464
|
+
const logSpy = sinon.spy(webex.logger, 'log');
|
|
465
|
+
const eventName = 'client.call.initiated';
|
|
466
|
+
const eventPayload = {event: {name: eventName}};
|
|
467
|
+
|
|
468
|
+
prepareDiagnosticMetricItem(webex, {eventPayload, type: ['diagnostic-event']});
|
|
469
|
+
|
|
470
|
+
assert.isTrue(
|
|
471
|
+
logSpy.calledWith('Milestone,CallDiagnostic', eventName),
|
|
472
|
+
'expected logger.log to be called with Milestone,CallDiagnostic and the event name'
|
|
473
|
+
);
|
|
474
|
+
sinon.restore();
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
it('does not log a Milestone entry when event name is absent', () => {
|
|
478
|
+
const logSpy = sinon.spy(webex.logger, 'log');
|
|
479
|
+
const eventPayload = {event: {}};
|
|
480
|
+
|
|
481
|
+
prepareDiagnosticMetricItem(webex, {eventPayload, type: ['diagnostic-event']});
|
|
482
|
+
|
|
483
|
+
assert.isFalse(
|
|
484
|
+
logSpy.calledWith('Milestone,CallDiagnostic', sinon.match.any),
|
|
485
|
+
'expected logger.log not to be called with Milestone,CallDiagnostic when event name is absent'
|
|
486
|
+
);
|
|
487
|
+
sinon.restore();
|
|
488
|
+
});
|
|
489
|
+
|
|
463
490
|
it('sets buildType and upgradeChannel correctly', () => {
|
|
464
491
|
const item: any = {
|
|
465
492
|
eventPayload: {
|
|
@@ -415,45 +415,64 @@ describe('internal-plugin-metrics', () => {
|
|
|
415
415
|
})
|
|
416
416
|
|
|
417
417
|
describe('#handleHttpResponseStatus', () => {
|
|
418
|
-
|
|
419
|
-
{shouldMark: true, statusCode: 200, currentTelemetryOptOut: 'automatic', shouldCallSetTelemetryOptOut: false, expectedSetTelemetryOptOutArg: 'N/A'},
|
|
420
|
-
{shouldMark: true, statusCode: 200, currentTelemetryOptOut: 'manual', shouldCallSetTelemetryOptOut: false, expectedSetTelemetryOptOutArg: 'N/A'},
|
|
421
|
-
{shouldMark: true, statusCode: 200, currentTelemetryOptOut: undefined, shouldCallSetTelemetryOptOut: true, expectedSetTelemetryOptOutArg: 'automatic'},
|
|
422
|
-
|
|
423
|
-
{shouldMark: true, statusCode: 201, currentTelemetryOptOut: 'automatic', shouldCallSetTelemetryOptOut: true, expectedSetTelemetryOptOutArg: undefined},
|
|
424
|
-
{shouldMark: true, statusCode: 202, currentTelemetryOptOut: 'manual', shouldCallSetTelemetryOptOut: false, expectedSetTelemetryOptOutArg: 'N/A'},
|
|
425
|
-
{shouldMark: true, statusCode: 203, currentTelemetryOptOut: undefined, shouldCallSetTelemetryOptOut: false, expectedSetTelemetryOptOutArg: 'N/A'},
|
|
426
|
-
|
|
427
|
-
{shouldMark: false, statusCode: 200, currentTelemetryOptOut: 'automatic', shouldCallSetTelemetryOptOut: false, expectedSetTelemetryOptOutArg: 'N/A'},
|
|
428
|
-
{shouldMark: false, statusCode: 200, currentTelemetryOptOut: 'manual', shouldCallSetTelemetryOptOut: false, expectedSetTelemetryOptOutArg: 'N/A'},
|
|
429
|
-
{shouldMark: false, statusCode: 200, currentTelemetryOptOut: undefined, shouldCallSetTelemetryOptOut: false, expectedSetTelemetryOptOutArg: 'N/A'},
|
|
430
|
-
|
|
431
|
-
{shouldMark: false, statusCode: 201, currentTelemetryOptOut: 'automatic', shouldCallSetTelemetryOptOut: false, expectedSetTelemetryOptOutArg: 'N/A'},
|
|
432
|
-
{shouldMark: false, statusCode: 202, currentTelemetryOptOut: 'manual', shouldCallSetTelemetryOptOut: false, expectedSetTelemetryOptOutArg: 'N/A'},
|
|
433
|
-
{shouldMark: false, statusCode: 203, currentTelemetryOptOut: undefined, shouldCallSetTelemetryOptOut: false, expectedSetTelemetryOptOutArg: 'N/A'},
|
|
434
|
-
].forEach(({shouldMark, statusCode, currentTelemetryOptOut, shouldCallSetTelemetryOptOut, expectedSetTelemetryOptOutArg}) => {
|
|
435
|
-
it(`should call setTelemetryOptOut ${shouldCallSetTelemetryOptOut ? 'with ' + expectedSetTelemetryOptOutArg : 'not at all'} when shouldMark is ${shouldMark}, statusCode is ${statusCode} and currentTelemetryOptOut is ${currentTelemetryOptOut}`, () => {
|
|
436
|
-
webex.internal.newMetrics.callDiagnosticMetrics.setTelemetryOptOut = sinon.stub();
|
|
437
|
-
webex.internal.newMetrics.callDiagnosticMetrics.getTelemetryOptOut = sinon
|
|
438
|
-
.stub()
|
|
439
|
-
.returns(currentTelemetryOptOut);
|
|
418
|
+
let setIsTelemetryOptOutAutomaticStub;
|
|
440
419
|
|
|
420
|
+
beforeEach(() => {
|
|
421
|
+
setIsTelemetryOptOutAutomaticStub = sinon.stub(
|
|
422
|
+
webex.internal.newMetrics.callDiagnosticMetrics,
|
|
423
|
+
'setIsTelemetryOptOutAutomatic'
|
|
424
|
+
);
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
[201, 400, 503, undefined].forEach((statusCode) => {
|
|
428
|
+
it(`does not call setIsTelemetryOptOutAutomatic when shouldMark is true and statusCode is ${statusCode}`, () => {
|
|
441
429
|
webex.internal.newMetrics.callDiagnosticMetrics.preLoginMetricsBatcher.handleHttpResponseStatus(
|
|
442
430
|
statusCode,
|
|
443
|
-
|
|
431
|
+
[{markTelemetryOptOutOnResponse: true}]
|
|
444
432
|
);
|
|
445
433
|
|
|
446
|
-
|
|
447
|
-
assert.calledOnce(webex.internal.newMetrics.callDiagnosticMetrics.setTelemetryOptOut);
|
|
448
|
-
assert.deepEqual(
|
|
449
|
-
webex.internal.newMetrics.callDiagnosticMetrics.setTelemetryOptOut.getCalls()[0].args[0],
|
|
450
|
-
expectedSetTelemetryOptOutArg
|
|
451
|
-
);
|
|
452
|
-
} else {
|
|
453
|
-
assert.notCalled(webex.internal.newMetrics.callDiagnosticMetrics.setTelemetryOptOut);
|
|
454
|
-
}
|
|
434
|
+
assert.notCalled(setIsTelemetryOptOutAutomaticStub);
|
|
455
435
|
});
|
|
456
|
-
})
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
it('calls setIsTelemetryOptOutAutomatic(true) when statusCode is 200 and markTelemetryOptOutOnResponse is true', () => {
|
|
439
|
+
webex.internal.newMetrics.callDiagnosticMetrics.preLoginMetricsBatcher.handleHttpResponseStatus(
|
|
440
|
+
200,
|
|
441
|
+
[{markTelemetryOptOutOnResponse: true}]
|
|
442
|
+
);
|
|
443
|
+
|
|
444
|
+
assert.calledOnce(setIsTelemetryOptOutAutomaticStub);
|
|
445
|
+
assert.calledWithExactly(setIsTelemetryOptOutAutomaticStub, true);
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
[200, 201, 400, 503, undefined].forEach((statusCode) => {
|
|
449
|
+
it(`does not call setIsTelemetryOptOutAutomatic when shouldMark is false (statusCode: ${statusCode})`, () => {
|
|
450
|
+
webex.internal.newMetrics.callDiagnosticMetrics.preLoginMetricsBatcher.handleHttpResponseStatus(
|
|
451
|
+
statusCode,
|
|
452
|
+
[{markTelemetryOptOutOnResponse: false}]
|
|
453
|
+
);
|
|
454
|
+
|
|
455
|
+
assert.notCalled(setIsTelemetryOptOutAutomaticStub);
|
|
456
|
+
});
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
it('does not call setIsTelemetryOptOutAutomatic when payload is empty', () => {
|
|
460
|
+
webex.internal.newMetrics.callDiagnosticMetrics.preLoginMetricsBatcher.handleHttpResponseStatus(
|
|
461
|
+
200,
|
|
462
|
+
[]
|
|
463
|
+
);
|
|
464
|
+
|
|
465
|
+
assert.notCalled(setIsTelemetryOptOutAutomaticStub);
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
it('does not call setIsTelemetryOptOutAutomatic when payload is not an array', () => {
|
|
469
|
+
webex.internal.newMetrics.callDiagnosticMetrics.preLoginMetricsBatcher.handleHttpResponseStatus(
|
|
470
|
+
200,
|
|
471
|
+
null
|
|
472
|
+
);
|
|
473
|
+
|
|
474
|
+
assert.notCalled(setIsTelemetryOptOutAutomaticStub);
|
|
475
|
+
});
|
|
457
476
|
});
|
|
458
477
|
});
|
|
459
478
|
});
|