Skip to content

RTC: Track unique sessions via a session_id on jetpack_rtc_* events#50008

Open
mmtr wants to merge 1 commit into
trunkfrom
dotcom-17703-track-unique-sessions-in-jetpack_rtc_-events
Open

RTC: Track unique sessions via a session_id on jetpack_rtc_* events#50008
mmtr wants to merge 1 commit into
trunkfrom
dotcom-17703-track-unique-sessions-in-jetpack_rtc_-events

Conversation

@mmtr

@mmtr mmtr commented Jun 26, 2026

Copy link
Copy Markdown
Member

Fixes https://linear.app/a8c/issue/DOTCOM-17703

Proposed changes

  • Add a session_id property to the jetpack_rtc_join, jetpack_rtc_blocked, and jetpack_rtc_connection_error Tracks events so unique collaboration sessions can be measured separately from unique users and posts.
  • The id is derived from the Yjs awareness clientID via a new getSessionId() helper. clientID is generated fresh for each Y.Doc instance — 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 one session_id, while a reload, a second tab, or a different user each get a distinct one.
  • Like the existing contributors roster, clientID is only unique within a room, so distinct sessions should be counted scoped to a single blog_id/post_id (both already attached to every event).
  • For connection_error, the session_id is read from options.awareness at provider-wrap time and omitted (dropped by recordRtcEvent) when awareness isn't available.
  • Updated and added unit tests; added a changelog entry.

Related product discussion/links

Does this pull request change what data or activity we track or use?

Yes. It adds a session_id property to the existing jetpack_rtc_join, jetpack_rtc_blocked, and jetpack_rtc_connection_error Tracks events. The value is the Yjs awareness clientID (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 a blog_id/post_id.

Testing instructions

  • Build the RTC package (or a plugin bundling it) and open a post in the block editor on a site with RTC enabled.
  • Open the same post in a second browser/profile so two clients join the room.
  • Watch the Tracks events (e.g. via the browser's network tab / Tracks debug, or the jetpack_rtc_* events server-side) and confirm:
    • jetpack_rtc_join now includes a session_id.
    • Each client reports a different session_id, and reloading a tab produces a new one.
    • Forcing the room limit produces jetpack_rtc_blocked with a session_id; a genuine disconnect produces jetpack_rtc_connection_error with the same session_id that client reported on join.
  • Run the package unit tests: cd projects/packages/rtc && pnpm test (45 tests pass).

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>
@mmtr mmtr added [Status] Needs Review This PR is ready for review. [Status] Needs Privacy Updates Our support docs will need to be updated to take this change into account labels Jun 26, 2026
@mmtr mmtr self-assigned this Jun 26, 2026
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (WordPress.com Site Helper), and enable the dotcom-17703-track-unique-sessions-in-jetpack_rtc_-events branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack-mu-wpcom-plugin dotcom-17703-track-unique-sessions-in-jetpack_rtc_-events

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@jp-launch-control

jp-launch-control Bot commented Jun 26, 2026

Copy link
Copy Markdown

Code Coverage Summary

This 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. 🤷

Full summary · PHP report · JS report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Rtc [Status] Needs Privacy Updates Our support docs will need to be updated to take this change into account [Status] Needs Review This PR is ready for review. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant