fix(ca): send stayLobbyTime with lobby exit event#4744
fix(ca): send stayLobbyTime with lobby exit event#4744gabrielchl merged 7 commits intowebex:nextfrom
Conversation
There was a problem hiding this comment.
💡 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".
...ages/@webex/internal-plugin-metrics/src/call-diagnostic/call-diagnostic-metrics-latencies.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
💡 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".
| if (ignoreMissingEndEvent && !this.latencyTimestamps.get('client.lobby.exited')) { | ||
| this.saveTimestamp({ | ||
| key: 'client.lobby.exited', | ||
| }); |
There was a problem hiding this comment.
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({ |
There was a problem hiding this comment.
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()?
There was a problem hiding this comment.
looks like you're right, we do saveTimestamp before prepareDiagnosticMetricItem gets called
i've also tested with logs to confirm this
There was a problem hiding this comment.
💡 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".
| case 'client.lobby.exited': | ||
| joinTimes.stayLobbyTime = cdl.getStayLobbyTime(); |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
@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
There was a problem hiding this comment.
💡 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".
| case 'client.lobby.exited': | ||
| joinTimes.stayLobbyTime = cdl.getStayLobbyTime(); |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
💡 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".
| case 'client.lobby.exited': | ||
| joinTimes.stayLobbyTime = cdl.getStayLobbyTime(); |
There was a problem hiding this comment.
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 👍 / 👎.
Co-authored-by: Jordan Rowan <jorowan@cisco.com> Co-authored-by: Gabriel Lee <chihonglee777@gmail.com>
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
The following scenarios were tested
< ENUMERATE TESTS PERFORMED, WHETHER MANUAL OR AUTOMATED >
The GAI Coding Policy And Copyright Annotation Best Practices
I certified that
Make sure to have followed the contributing guidelines before submitting.