Skip to content

Add Survicate survey integration for wp-admin, block editor, and site editor#47107

Open
paulopmt1 wants to merge 1 commit intotrunkfrom
add/survicate-wp-admin-integration
Open

Add Survicate survey integration for wp-admin, block editor, and site editor#47107
paulopmt1 wants to merge 1 commit intotrunkfrom
add/survicate-wp-admin-integration

Conversation

@paulopmt1
Copy link
Contributor

@paulopmt1 paulopmt1 commented Feb 12, 2026

Fixes DOTCOM-15989

Proposed changes:

  • Add Survicate survey SDK integration for WordPress.com users in wp-admin contexts (admin pages, block editor, and site editor)
  • Server-side guards: logged-in user, is_admin, English locale only
  • Client-side guard: skips mobile viewports (< 480px)
  • Sets visitor traits (email, site_id, site_type, editor_context) for survey targeting
  • Uses the same Survicate workspace key as the existing Calypso integration

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

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

This PR sends visitor traits (email, site_id, site_type, editor_context) to the Survicate survey SDK for survey targeting. This mirrors the existing Survicate integration in Calypso (@automattic/survicate package).

Testing instructions

Tip: we can always reset our visitorId to see the survey in case we closed it: window._sva?.destroyVisitor?.();
Log in as an English-locale WordPress.com user on a desktop browser:

  • Apply it in your sandbox, redirect a simple site to it, open its /wp-admin, and add the ?test_survey=1 to the URL. It should appear:
image
  • Make sure it also works for the site editor:
image
  • It should also work inside Gutenberg's Post/Page editor:
image
  • It should work on Atomic sites as well (here's how to test: PCYsg-Osp-p2):
image

Negative tests

  • Switch to a non-English locale user — Survicate should NOT load
  • Resize browser below 480px width and reload — Survicate should NOT load
  • Make sure we don't load it on the user's facing site (non WP-admin area):
image

Survicate data test

  • In the console, verify window._sva exists and visitor traits are set (Paulo validated already)
  • IOpen a post in the block editor — verify editor_context trait is block-editor (Paulo validated already)
  • INavigate to Appearance > Editor — verify editor_context trait is site-editor (Paulo validated already)

@paulopmt1 paulopmt1 added the [Status] Needs Review This PR is ready for review. label Feb 12, 2026
@paulopmt1 paulopmt1 self-assigned this Feb 12, 2026
@paulopmt1 paulopmt1 added the [Status] Needs Review This PR is ready for review. label Feb 12, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

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 add/survicate-wp-admin-integration branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/survicate-wp-admin-integration

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
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
Copy link

jp-launch-control bot commented Feb 12, 2026

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php 0/335 (0.00%) 0.00% 2 ❤️‍🩹

1 file is newly checked for coverage.

File Coverage
projects/packages/jetpack-mu-wpcom/src/features/survicate/class-survicate.php 47/48 (97.92%) 💚

Full summary · PHP report

@paulopmt1 paulopmt1 force-pushed the add/survicate-wp-admin-integration branch from bc6854e to 61de511 Compare February 13, 2026 18:15
… editor

Loads the Survicate SDK for WordPress.com users in wp-admin contexts
(admin pages, block editor, site editor) to enable in-product surveys.
Includes server-side guards (logged-in, admin, English locale) and
client-side mobile viewport check. Sets visitor traits (email, site_id,
site_type, editor_context) for survey targeting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@paulopmt1 paulopmt1 force-pushed the add/survicate-wp-admin-integration branch from 61de511 to c9eb02f Compare February 13, 2026 18:25
@paulopmt1 paulopmt1 marked this pull request as ready for review February 13, 2026 18:30
Copilot AI review requested due to automatic review settings February 13, 2026 18:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Survicate survey SDK integration for WordPress.com users in wp-admin contexts (admin pages, block editor, and site editor). The integration enables targeted surveys with proper visitor traits (email, site_id, site_type, editor_context) and includes both server-side and client-side guards to ensure the SDK only loads in appropriate contexts.

Changes:

  • Add new Survicate class that implements survey SDK integration with singleton pattern
  • Enqueue inline JavaScript that loads Survicate SDK with mobile viewport guard
  • Add comprehensive unit tests covering all loading conditions and edge cases

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
projects/packages/jetpack-mu-wpcom/src/features/survicate/class-survicate.php Core Survicate integration class with loading guards, visitor trait collection, and script enqueuing
projects/packages/jetpack-mu-wpcom/tests/php/features/survicate/Survicate_Test.php Comprehensive unit tests covering singleton, loading conditions, editor context detection, and visitor traits
projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php Integration point to load Survicate feature for WordPress.com users
projects/packages/jetpack-mu-wpcom/changelog/2026-02-12-22-25-24-309661 Changelog entry documenting the new feature

@paulopmt1 paulopmt1 requested a review from a team February 13, 2026 18:37
Copy link
Contributor

@zaguiini zaguiini left a comment

Choose a reason for hiding this comment

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

Works fine. Left a comment about commiting a potential environment variable.

/**
* Survicate workspace key.
*/
const WORKSPACE_KEY = 'e4794374cce15378101b63de24117572';
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to commit this key?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. That's fine. We use it to load our profile on Survicate. In Calypso, we use it in the URL, so it's not sensitive data.

Thanks for checking it!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants