RTC: Track unique sessions via a session_id on jetpack_rtc_* events#50008
RTC: Track unique sessions via a session_id on jetpack_rtc_* events#50008mmtr wants to merge 1 commit into
Conversation
Derive session_id from the Yjs awareness clientID (unique per Y.Doc / per client connection to a room, stable for the session's lifetime) and attach it to the join, blocked, and connection_error Tracks events. This lets unique collaboration sessions be counted separately from unique users and posts, scoped to a blog_id/post_id like the contributor roster. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryThis PR did not change code coverage! That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷 |
Fixes https://linear.app/a8c/issue/DOTCOM-17703
Proposed changes
session_idproperty to thejetpack_rtc_join,jetpack_rtc_blocked, andjetpack_rtc_connection_errorTracks events so unique collaboration sessions can be measured separately from unique users and posts.clientIDvia a newgetSessionId()helper.clientIDis generated fresh for eachY.Docinstance — i.e. each time a client connects to a room (page load / provider creation) — and is stable for that connection's lifetime. So every event a single client emits during one editing session shares onesession_id, while a reload, a second tab, or a different user each get a distinct one.contributorsroster,clientIDis only unique within a room, so distinct sessions should be counted scoped to a singleblog_id/post_id(both already attached to every event).connection_error, thesession_idis read fromoptions.awarenessat provider-wrap time and omitted (dropped byrecordRtcEvent) when awareness isn't available.Related product discussion/links
Does this pull request change what data or activity we track or use?
Yes. It adds a
session_idproperty to the existingjetpack_rtc_join,jetpack_rtc_blocked, andjetpack_rtc_connection_errorTracks events. The value is the Yjs awarenessclientID(a random per-document integer), not a user identifier — it carries no additional PII and exists only to let distinct collaboration sessions be counted within ablog_id/post_id.Testing instructions
jetpack_rtc_*events server-side) and confirm:jetpack_rtc_joinnow includes asession_id.session_id, and reloading a tab produces a new one.jetpack_rtc_blockedwith asession_id; a genuine disconnect producesjetpack_rtc_connection_errorwith the samesession_idthat client reported on join.cd projects/packages/rtc && pnpm test(45 tests pass).