Skip to content

Connection: Record Tracks events on the new Safe Mode screen - #55183

Merged
bindlegirl merged 2 commits into
trunkfrom
add/connection-idc-tracking
Nov 26, 2026
Merged

bindlegirl merged 2 commits into
trunkfrom
add/connection-idc-tracking

Conversation

@bindlegirl

@bindlegirl bindlegirl commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Fixes CONNECT-620

Proposed changes

The new Safe Mode screen now records Tracks events. The screen is behind the connection-idc-screen feature flag, which is off by default. The admin notice, the My Jetpack window and the Connectors card all render it when the flag is on.

  • Views: jetpack_idc_notice_view, or jetpack_idc_non_admin_notice_view for a viewer who can't resolve Safe Mode. It's sent once per mount, the first time the screen is in the viewport while the tab is visible.

  • Questions: jetpack_idc_question_click, with the question, the answer and the path so far. It's sent:

    • on Next, when the answer leads to another step,
    • on each answer in the step-by-step guide, which moves on without Next,
    • on Back, and on the guide's links back to an earlier answer.

    Picking an answer without Next sends nothing.

  • The guide: jetpack_idc_guide_click, with action open when the guide is opened, conclusion when an answer reaches a statement, or later for "Stay in Safe Mode for now". A conclusion follows that answer's jetpack_idc_question_click and carries the statement (old, original or copyof) as answer.

  • Actions: each action's start keeps the old screen's event name (jetpack_idc_migrate, jetpack_idc_start_fresh or jetpack_idc_confirm_safe_mode). Then jetpack_idc_action_success or jetpack_idc_action_error follows. All three carry the flow's path, which starts with guide when the admin got there through the guide.

    • The success is sent with use_beacon, because the host may reload or leave the page right after it. Start fresh's success adds new_blog_id.
    • The error adds error_code and error_cause.
  • The recorder: a new trackIdentityCrisisEvent( event, context, props ), exported from the package, adds the properties every Safe Mode event carries:

    • screen_version: 2,
    • placement, from the screen's context prop,
    • context, which is the admin screen id on the notice,
    • platform, mapped from site.host to the old screen's values,
    • blog_id.
  • Hosts (packages/connection):

    • The admin notice identifies the viewer to Tracks before it renders the new screen. Until now its events went out anonymous, because the old screen identified the viewer itself and the new one leaves that to its host.
    • On the Connectors card, the new screen's Disconnect site records jetpack_connection_card_action_click with action: safe_mode_disconnect_site, as the old Safe Mode panel did, instead of the plain disconnect_site. Once the dialog has disconnected the site and the admin leaves it, the card sends jetpack_idc_disconnect_site through the recorder. That is later than the old panel, which sent it on the confirm click, before the request. docs/connectors.md names the dialog's events that give exact counts.
  • useIdentityCrisisActions() takes two new optional options, context and isDevelopmentSite, for its events. The actions keep their signatures.

  • ConnectionPlacement gains page_modal.

  • The README gains a "Safe Mode events" section listing every event and property, and docs/connectors.md points to it.

Views and action starts keep the old screen's event names, so one query counts both screens, split by screen_version.

Related product discussion/links

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

Yes, so this PR carries the [Status] Needs Privacy Updates label. When the new Safe Mode screen is shown (it sits behind a feature flag that is off by default), it records the Tracks events listed above.

  • They record how the screen is used: which questions were answered, whether the step-by-step guide was used, which action was taken, and whether it worked.
  • Their properties are the admin screen the notice was shown on (for example dashboard), the site's hosting platform (woa, vip, newspack or self-hosted), its WordPress.com blog id, and whether it's a development or staging site. After Start fresh, the new blog id the site registered as is added.
  • None of the new properties describes the user. The viewer is identified to Tracks by their WordPress.com account, as on My Jetpack and the Connectors card. The admin notice now does this too.
  • They go through Tracks, so they're only sent on pages that load the Tracks script, which the hosts do only when the site allows tracking.
  • The new screen records no jetpack-idc MC stats. The old screen still does.

Testing instructions

Unit tests

  • Run jp test js js-packages/connection and jp test js packages/connection. These files pin the event payloads:
    • hooks/use-identity-crisis-actions/test/index.test.ts: each action's start, success and error.
    • components/identity-crisis/test/identity-crisis.test.tsx: the path from the screen, question and guide clicks, and views.
    • helpers/test/connection-tracking.test.ts: the properties every event carries.
    • In packages/connection, src/identity-crisis/_inc/test/admin.test.jsx (the notice's identity) and src/connectors/js/test/connectors-card.test.js (the card's Disconnect).
  • Run pnpm run typecheck in projects/js-packages/connection and in projects/js-packages/ai-client. ai-client resolves this package's TypeScript with nodenext, so a relative import without a .ts extension breaks it even when this package's own check passes.

On a site

Set up a connected Jetpack site running this branch:

  • Put it in Safe Mode with Jetpack Debug Helper.
  • Turn the flag on with add_filter( 'jetpack_feature_flag_enabled_connection-idc-screen', '__return_true' ); in an mu-plugin.
  • In the browser console, run localStorage.debug = 'dops:analytics', and turn on Preserve log in the Console and Network panels.

Then check:

  1. Notice: on the Dashboard, one jetpack_idc_notice_view is logged, with context: dashboard, placement: page_notice and screen_version: 2. In the Network panel, its pixel.wp.com/t.gif request has _ut=wpcom:user_id, not anon. The block editor, where the notice is hidden, logs no view.
  2. Questions: pick "A copy of this site", click Next, then Back. That logs jetpack_idc_question_click twice, with action answer and then back. Picking an answer alone logs nothing.
  3. Guide: click "Work it out step by step" (jetpack_idc_guide_click, action: open), answer "A site loads there" (jetpack_idc_question_click with question: open_address), then click "Stay in Safe Mode for now" (jetpack_idc_guide_click, action: later). Click Back, answer "A separate site", then the address WordPress.com has (not this site's). After that answer's jetpack_idc_question_click, jetpack_idc_guide_click logs action: conclusion with answer: original.
  4. Actions: click Stay in Safe Mode. jetpack_idc_confirm_safe_mode is logged, then jetpack_idc_action_success with the same path, and the page reloads. Repeat an action with DevTools offline: it logs jetpack_idc_action_error with error_code and error_cause, and no success.
  5. My Jetpack: clear the confirmation from the admin bar's Safe Mode link, then open My Jetpack. The window's events carry placement: page_modal and context: my-jetpack.
  6. Connectors card (Settings › Connectors): click Resolve, and the view carries placement: connection_card. Disconnect site logs jetpack_connection_card_action_click with action: safe_mode_disconnect_site. Disconnect, then click "Back to WordPress": jetpack_idc_disconnect_site is logged before the reload. This disconnects the site, so do it last.
  7. Flag off: remove the filter. The old screens' events are the same as on trunk.

🤖 Generated with Claude Code

@bindlegirl bindlegirl added [Status] In Progress [Status] Needs Privacy Updates Our support docs will need to be updated to take this change into account Enhancement Changes to an existing feature — removing, adding, or changing parts of it labels Nov 18, 2026
@bindlegirl bindlegirl self-assigned this Nov 18, 2026
@github-actions

github-actions Bot commented Nov 18, 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 (Jetpack or WordPress.com Site Helper), and enable the add/connection-idc-tracking branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/connection-idc-tracking
bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/connection-idc-tracking

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 Nov 18, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 7 files. Only the first 5 are listed here.

File Coverage Δ% Δ Uncovered
projects/js-packages/connection/components/identity-crisis/flow/steps.ts 74/83 (89.16%) 0.09% 2 ❤️‍🩹
projects/js-packages/connection/components/identity-crisis/flow/use-identity-crisis-flow.ts 14/15 (93.33%) 1.03% 0 💚
projects/js-packages/connection/components/identity-crisis/identity-crisis.tsx 84/88 (95.45%) 0.05% 0 💚
projects/js-packages/connection/helpers/connection-tracking.ts 19/19 (100.00%) 0.00% 0 💚
projects/js-packages/connection/hooks/use-identity-crisis-actions/index.ts 62/62 (100.00%) 0.00% 0 💚

1 file is newly checked for coverage.

File Coverage
projects/js-packages/connection/components/identity-crisis/use-identity-crisis-view.ts 27/27 (100.00%) 💚

Full summary · PHP report · JS report

@bindlegirl
bindlegirl force-pushed the add/connection-idc-tracking branch from 544f24f to 436d6a3 Compare November 24, 2026 11:09
@bindlegirl
bindlegirl force-pushed the add/connection-idc-tracking branch from 436d6a3 to 319e791 Compare November 25, 2026 14:25
@bindlegirl
bindlegirl marked this pull request as ready for review November 26, 2026 11:54
@bindlegirl
bindlegirl requested a review from a team as a code owner November 26, 2026 11:54
@bindlegirl bindlegirl added the [Status] Needs Review This PR is ready for review. label Nov 26, 2026
The new Safe Mode screen records when it is seen, when its questions and
step-by-step guide are used, and when its actions start, succeed or fail.
Every event goes through a new trackIdentityCrisisEvent() recorder, which
adds the properties all Safe Mode events carry.

With the new screen, the admin notice now identifies the viewer to Tracks,
and the Connectors card's Disconnect records safe_mode_disconnect_site and
jetpack_idc_disconnect_site, as the old Safe Mode panel did.

Part of CONNECT-620.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bindlegirl
bindlegirl force-pushed the add/connection-idc-tracking branch from 319e791 to 785137a Compare November 26, 2026 12:39
coder-karen
coder-karen previously approved these changes Nov 26, 2026

@coder-karen coder-karen left a comment

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.

This looks good to me, thanks for taking this one on!

Approving as it's just nits I've left comments for. There was just one thing that I wanted to ask about, but not blocking:

When jetpack_idc_disconnect_site fires is different to before. The build plan comment suggests it should be sent from the same place as today - when the disconnect is confirmed. Now it runs after the disconnect succeeds. I left a it comment to suggest a readme wording change, perhaps that's al that is needed here, but wanted to flag this as it was different.

Separately another nit / question - jetpack_idc_guide_click - I'd suggested action: open | conclusion in the plan. Here it's open | later, and reaching a conclusion only shows up as a jetpack_idc_question_click answer with a guide path. Counting conclusions therefore means knowing which guide answers lead to a statement. Was dropping conclusion deliberate? If not, could it go alongside later?

- Send jetpack_idc_guide_click with action conclusion when a guide answer
  reaches a statement, with the statement as answer.
- Have the flow return Tracks-shaped events (kind, action), so the
  screen passes them through.
- Type the action events' action values as a literal union.
- Docs: note when jetpack_idc_disconnect_site fires with the flag on,
  and which dialog events give exact counts; say when path is left out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bindlegirl

Copy link
Copy Markdown
Contributor Author

@coder-karen thanks! Both points are addressed in 77e5f9e.

  • Disconnect timing: I kept it after the disconnect and documented it, as you suggested. The shared dialog has no hook before its request outside the plugins page. It already records the confirm click as jetpack_disconnect_dialog_click_disconnect, so the docs now point there for attempts.
  • conclusion: dropping it was deliberate, since the answer's question_click records it. But you're right that counting it then needs the answer-to-statement mapping, so it's back. A guide answer that reaches a statement sends its question_click, then jetpack_idc_guide_click with action: conclusion, the statement (old, original or copyof) as answer, and the same path.

@coder-karen coder-karen left a comment

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.

LGTM, thanks!

PCYsg-mUj-p2 should help for registering the new events.

@bindlegirl
bindlegirl merged commit 2f42d96 into trunk Nov 26, 2026
192 of 199 checks passed
@bindlegirl
bindlegirl deleted the add/connection-idc-tracking branch November 26, 2026 16:03
@github-actions github-actions Bot added [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. and removed [Status] In Progress [Status] Needs Review This PR is ready for review. labels Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Docs Enhancement Changes to an existing feature — removing, adding, or changing parts of it [JS Package] Connection [Package] Connection RNA [Status] Needs Privacy Updates Our support docs will need to be updated to take this change into account [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants