Add Survicate survey integration for wp-admin, block editor, and site editor#47107
Add Survicate survey integration for wp-admin, block editor, and site editor#47107
Conversation
|
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 SummaryCoverage changed in 1 file.
1 file is newly checked for coverage.
|
bc6854e to
61de511
Compare
… 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>
61de511 to
c9eb02f
Compare
There was a problem hiding this comment.
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
Survicateclass 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 |
zaguiini
left a comment
There was a problem hiding this comment.
Works fine. Left a comment about commiting a potential environment variable.
| /** | ||
| * Survicate workspace key. | ||
| */ | ||
| const WORKSPACE_KEY = 'e4794374cce15378101b63de24117572'; |
There was a problem hiding this comment.
Do we want to commit this key?
There was a problem hiding this comment.
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!
Fixes DOTCOM-15989
Proposed changes:
Other information:
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/survicatepackage).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:
?test_survey=1to the URL. It should appear:Negative tests
Survicate data test
In the console, verifywindow._svaexists and visitor traits are set (Paulo validated already)IOpen a post in the block editor — verifyeditor_contexttrait isblock-editor(Paulo validated already)INavigate to Appearance > Editor — verifyeditor_contexttrait issite-editor(Paulo validated already)