Skip to content

fix(ca): send stayLobbyTime with lobby exit event#4744

Merged
gabrielchl merged 7 commits intowebex:nextfrom
jor-row:fix/send-staylobbytime-on-lobby-exit
Mar 20, 2026
Merged

fix(ca): send stayLobbyTime with lobby exit event#4744
gabrielchl merged 7 commits intowebex:nextfrom
jor-row:fix/send-staylobbytime-on-lobby-exit

Conversation

@jor-row
Copy link
Copy Markdown
Contributor

@jor-row jor-row commented Feb 25, 2026

COMPLETES https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-603148

This pull request addresses

stayLobbyTime being sent before lobby is exited

by making the following changes

only send this latency with client.lobby.exited event. this means it will only be populated on join result if lobby was actually entered.

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tooling change
  • Internal code refactor

The following scenarios were tested

< ENUMERATE TESTS PERFORMED, WHETHER MANUAL OR AUTOMATED >

The GAI Coding Policy And Copyright Annotation Best Practices

  • GAI was not used (or, no additional notation is required)
  • Code was generated entirely by GAI
  • GAI was used to create a draft that was subsequently customized or modified
  • Coder created a draft manually that was non-substantively modified by GAI (e.g., refactoring was performed by GAI on manually written code)
  • Tool used for AI assistance (GitHub Copilot / Other - specify)
    • Github Copilot
    • Other - Please Specify
  • This PR is related to
    • Feature
    • Defect fix
    • Tech Debt
    • Automation

I certified that

  • I have read and followed contributing guidelines
  • I discussed changes with code owners prior to submitting this pull request
  • I have not skipped any automated checks
  • All existing and new tests passed
  • I have updated the documentation accordingly

Make sure to have followed the contributing guidelines before submitting.

@jor-row jor-row requested review from a team as code owners February 25, 2026 22:36
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e81a969c8c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@jor-row jor-row added the validated If the pull request is validated for automation. label Feb 26, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8b6b720b00

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +307 to +310
if (ignoreMissingEndEvent && !this.latencyTimestamps.get('client.lobby.exited')) {
this.saveTimestamp({
key: 'client.lobby.exited',
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid persisting synthetic lobby-exit timestamp

This branch mutates shared latency state by writing client.lobby.exited = now when the event timestamp is missing, which can happen when queued/retried client.lobby.exited items are prepared after latencies were cleared (fresh evidence: batcher.js re-invokes prepareItem() in rerequest(), and prepareDiagnosticMetricItem() calls getStayLobbyTime(true) for that event). Once this synthetic timestamp is stored, later calls like getTotalMediaJMT()/getInterstitialToMediaOKJMT() can subtract an unrelated lobby duration and report clamped/incorrect media latencies for subsequent meetings.

Useful? React with 👍 / 👎.

public getStayLobbyTime(ignoreMissingEndEvent = false) {
// stayLobbyTime is sent with client.lobby.exited event so we may not have time timestamp yet
if (ignoreMissingEndEvent && !this.latencyTimestamps.get('client.lobby.exited')) {
this.saveTimestamp({
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't feel right to be saving a timestamp in a getter for latency. In general getters shouldn't change the state of a system, right? Could we maybe have a separate setter for the "client.lobby.exited" timestamp? Also I'm a bit confused why we need this in the first place, aren't the timestamps for all events saved already via the calls to saveTimestamp() from submitClientEvent()?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like you're right, we do saveTimestamp before prepareDiagnosticMetricItem gets called
i've also tested with logs to confirm this

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b687848a25

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +373 to +374
case 'client.lobby.exited':
joinTimes.stayLobbyTime = cdl.getStayLobbyTime();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Save the lobby-exit timestamp before populating stayLobbyTime

When client.lobby.exited is sent through the public fetch/keepalive path (buildClientEventFetchRequestOptions() / setMetricTimingsAndFetch()), this new case computes cdl.getStayLobbyTime() before that event’s timestamp has ever been recorded. submitClientEvent() records callDiagnosticLatencies.saveTimestamp({key: name}) in new-metrics.ts, but buildClientEventFetchRequestOptions() skips that and calls prepareDiagnosticMetricItem() directly, so the generated payload for client.lobby.exited ends up with joinTimes.stayLobbyTime unset. That means the new dedicated lobby-exit metric is silently missing in the unload-safe submission flow this SDK already exposes.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appears to not be an actual issue
the buildClientEventFetchRequestOptions path gets called when the client is about to be closed, if the user did exit the lobby before that, we'll have the timestamp, and if not, it's ok and expected that the stayLobbyTime will be undefined

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gabrielchl are you sure about this? I thought the whole point of buildClientEventFetchRequestOptions() was that it's called much earlier before user attempts to close the tab - I think it's called on meeting join, so that the metrics are prepared and can be sent quickly when tab is closed

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 30bad6c633

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +373 to +374
case 'client.lobby.exited':
joinTimes.stayLobbyTime = cdl.getStayLobbyTime();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve original stayLobbyTime on retried lobby-exit events

If a client.lobby.exited batch is retried after a NetworkOrCORSError, MetricsBatcher.rerequest() re-runs prepareItem() on the same event. This branch recomputes stayLobbyTime from the shared callDiagnosticLatencies map, which Meeting.leave() clears and the next meeting repopulates. In the sequence “meeting A lobby exit -> network failure -> join meeting B -> retry”, merge() here will overwrite meeting A’s previously prepared stayLobbyTime with meeting B’s value, so the resent lobby-exit metric reports the wrong lobby duration.

Useful? React with 👍 / 👎.

@gabrielchl gabrielchl enabled auto-merge (squash) March 20, 2026 17:10
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 22e465f78f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +373 to +374
case 'client.lobby.exited':
joinTimes.stayLobbyTime = cdl.getStayLobbyTime();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Save the lobby-exit timestamp before reading stayLobbyTime

When client.lobby.exited is sent through the supported fetch/keepalive path, this case runs before any client.lobby.exited timestamp has been stored. CallDiagnosticMetrics.buildClientEventFetchRequestOptions() goes straight to prepareDiagnosticMetricItem() (src/call-diagnostic/call-diagnostic-metrics.ts:1367-1373), unlike NewMetrics.submitClientEvent() which first calls callDiagnosticLatencies.saveTimestamp({key: name}) (src/new-metrics.ts:371-376). Because getStayLobbyTime() now uses client.lobby.exited itself as the end timestamp, fetch-built lobby-exit events will always omit stayLobbyTime, so unload-safe submissions lose the metric entirely.

Useful? React with 👍 / 👎.

@gabrielchl gabrielchl merged commit b359ca4 into webex:next Mar 20, 2026
11 checks passed
fnowakow pushed a commit to fnowakow/webex-js-sdk that referenced this pull request Mar 25, 2026
Co-authored-by: Jordan Rowan <jorowan@cisco.com>
Co-authored-by: Gabriel Lee <chihonglee777@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

validated If the pull request is validated for automation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants