Skip to content

Commit

Permalink
fix(internal-plugin-metrics): allow for 0 value in joinTimes (#4119)
Browse files Browse the repository at this point in the history
  • Loading branch information
jor-row authored Feb 27, 2025
1 parent 2048787 commit 6802b46
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ export default class CallDiagnosticLatencies extends WebexPlugin {
public getDiffBetweenTimestamps(a: MetricEventNames, b: MetricEventNames) {
const start = this.latencyTimestamps.get(a);
const end = this.latencyTimestamps.get(b);
if (start && end) {

if (typeof start === 'number' && typeof end === 'number') {
return end - start;
}

Expand Down Expand Up @@ -193,7 +194,7 @@ export default class CallDiagnosticLatencies extends WebexPlugin {
public getU2CTime() {
const u2cLatency = this.precomputedLatencies.get('internal.get.u2c.time');

return u2cLatency ? Math.floor(u2cLatency) : undefined;
return typeof u2cLatency === 'number' ? Math.floor(u2cLatency) : undefined;
}

/**
Expand Down Expand Up @@ -296,15 +297,19 @@ export default class CallDiagnosticLatencies extends WebexPlugin {
* @returns - latency
*/
public getPageJMT() {
return this.precomputedLatencies.get('internal.client.pageJMT') || undefined;
const latency = this.precomputedLatencies.get('internal.client.pageJMT');

return typeof latency === 'number' ? latency : undefined;
}

/**
* Download Time JMT
* @returns - latency
*/
public getDownloadTimeJMT() {
return this.precomputedLatencies.get('internal.download.time') || undefined;
const latency = this.precomputedLatencies.get('internal.download.time');

return typeof latency === 'number' ? latency : undefined;
}

/**
Expand All @@ -320,8 +325,15 @@ export default class CallDiagnosticLatencies extends WebexPlugin {
);
}

// for cross launch and guest flows
return this.precomputedLatencies.get('internal.click.to.interstitial') || undefined;
const clickToInterstitialLatency = this.precomputedLatencies.get(
'internal.click.to.interstitial'
);

if (typeof clickToInterstitialLatency === 'number') {
return clickToInterstitialLatency;
}

return undefined;
}

/**
Expand Down Expand Up @@ -358,7 +370,8 @@ export default class CallDiagnosticLatencies extends WebexPlugin {
// get the first timestamp
const connectedMedia = this.latencyTimestamps.get('client.ice.end');

const lobbyTime = this.getStayLobbyTime() || 0;
const lobbyTimeLatency = this.getStayLobbyTime();
const lobbyTime = typeof lobbyTimeLatency === 'number' ? lobbyTimeLatency : 0;

if (interstitialJoinClickTimestamp && connectedMedia) {
return connectedMedia - interstitialJoinClickTimestamp - lobbyTime;
Expand All @@ -375,7 +388,7 @@ export default class CallDiagnosticLatencies extends WebexPlugin {
const clickToInterstitial = this.getClickToInterstitial();
const interstitialToJoinOk = this.getInterstitialToJoinOK();

if (clickToInterstitial && interstitialToJoinOk) {
if (typeof clickToInterstitial === 'number' && typeof interstitialToJoinOk === 'number') {
return clickToInterstitial + interstitialToJoinOk;
}

Expand Down Expand Up @@ -427,7 +440,7 @@ export default class CallDiagnosticLatencies extends WebexPlugin {
const interstitialToJoinOk = this.getInterstitialToJoinOK();
const joinConfJMT = this.getJoinConfJMT();

if (interstitialToJoinOk && joinConfJMT) {
if (typeof interstitialToJoinOk === 'number' && typeof joinConfJMT === 'number') {
return interstitialToJoinOk - joinConfJMT;
}

Expand All @@ -454,7 +467,9 @@ export default class CallDiagnosticLatencies extends WebexPlugin {
public getReachabilityClustersReqResp() {
const reachablityClusterReqResp = this.precomputedLatencies.get('internal.get.cluster.time');

return reachablityClusterReqResp ? Math.floor(reachablityClusterReqResp) : undefined;
return typeof reachablityClusterReqResp === 'number'
? Math.floor(reachablityClusterReqResp)
: undefined;
}

/**
Expand All @@ -477,7 +492,7 @@ export default class CallDiagnosticLatencies extends WebexPlugin {
public getExchangeCITokenJMT() {
const exchangeCITokenJMT = this.precomputedLatencies.get('internal.exchange.ci.token.time');

return exchangeCITokenJMT ? Math.floor(exchangeCITokenJMT) : undefined;
return typeof exchangeCITokenJMT === 'number' ? Math.floor(exchangeCITokenJMT) : undefined;
}

/**
Expand All @@ -486,7 +501,9 @@ export default class CallDiagnosticLatencies extends WebexPlugin {
public getRefreshCaptchaReqResp() {
const refreshCaptchaReqResp = this.precomputedLatencies.get('internal.refresh.captcha.time');

return refreshCaptchaReqResp ? Math.floor(refreshCaptchaReqResp) : undefined;
return typeof refreshCaptchaReqResp === 'number'
? Math.floor(refreshCaptchaReqResp)
: undefined;
}

/**
Expand All @@ -498,7 +515,7 @@ export default class CallDiagnosticLatencies extends WebexPlugin {
'internal.api.fetch.intelligence.models'
);

return downloadIntelligenceModelsReqResp
return typeof downloadIntelligenceModelsReqResp === 'number'
? Math.floor(downloadIntelligenceModelsReqResp)
: undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,15 @@ describe('internal-plugin-metrics', () => {
assert.deepEqual(cdl.getClickToInterstitial(), 5);
});

it('calculates getClickToInterstitial without join button timestamp when it is 0', () => {
cdl.saveLatency('internal.click.to.interstitial', 0);
cdl.saveTimestamp({
key: 'internal.client.meeting.interstitial-window.showed',
value: 20,
});
assert.deepEqual(cdl.getClickToInterstitial(), 0);
});

it('calculates getInterstitialToJoinOK correctly', () => {
cdl.saveTimestamp({
key: 'internal.client.interstitial-window.click.joinbutton',
Expand All @@ -449,6 +458,18 @@ describe('internal-plugin-metrics', () => {
assert.deepEqual(cdl.getInterstitialToJoinOK(), 10);
});

it('calculates getInterstitialToJoinOK correctly when one value is not a number', () => {
cdl.saveTimestamp({
key: 'internal.client.interstitial-window.click.joinbutton',
value: 'ten' as unknown as number,
});
cdl.saveTimestamp({
key: 'client.locus.join.response',
value: 20,
});
assert.deepEqual(cdl.getInterstitialToJoinOK(), undefined);
});

it('calculates getCallInitMediaEngineReady correctly', () => {
cdl.saveTimestamp({
key: 'internal.client.interstitial-window.click.joinbutton',
Expand Down Expand Up @@ -481,6 +502,58 @@ describe('internal-plugin-metrics', () => {
assert.deepEqual(cdl.getTotalJMT(), 45);
});

it('calculates getTotalJMT correctly when clickToInterstitial is 0', () => {
cdl.saveLatency('internal.click.to.interstitial', 0);
cdl.saveTimestamp({
key: 'internal.client.interstitial-window.click.joinbutton',
value: 20,
});
cdl.saveTimestamp({
key: 'client.locus.join.response',
value: 40,
});
assert.deepEqual(cdl.getTotalJMT(), 20);
});

it('calculates getTotalJMT correctly when interstitialToJoinOk is 0', () => {
cdl.saveTimestamp({
key: 'internal.client.interstitial-window.click.joinbutton',
value: 40,
});
cdl.saveLatency('internal.click.to.interstitial', 12);
cdl.saveTimestamp({
key: 'client.locus.join.response',
value: 40,
});
assert.deepEqual(cdl.getTotalJMT(), 12);
});

it('calculates getTotalJMT correctly when both clickToInterstitial and interstitialToJoinOk are 0', () => {
cdl.saveTimestamp({
key: 'internal.client.interstitial-window.click.joinbutton',
value: 40,
});
cdl.saveLatency('internal.click.to.interstitial', 0);
cdl.saveTimestamp({
key: 'client.locus.join.response',
value: 40,
});
assert.deepEqual(cdl.getTotalJMT(), 0);
});

it('calculates getTotalJMT correctly when both clickToInterstitial is not a number', () => {
cdl.saveTimestamp({
key: 'internal.client.interstitial-window.click.joinbutton',
value: 40,
});
cdl.saveLatency('internal.click.to.interstitial', 'eleven' as unknown as number);
cdl.saveTimestamp({
key: 'client.locus.join.response',
value: 40,
});
assert.deepEqual(cdl.getTotalJMT(), undefined);
});

it('calculates getTotalMediaJMT correctly', () => {
cdl.saveTimestamp({
key: 'internal.client.meeting.click.joinbutton',
Expand Down

0 comments on commit 6802b46

Please sign in to comment.