Skip to content

Image Studio: Add isDevMode property to imageStudioData#48084

Open
t-wright wants to merge 10 commits intotrunkfrom
image-studio-devmode-prop
Open

Image Studio: Add isDevMode property to imageStudioData#48084
t-wright wants to merge 10 commits intotrunkfrom
image-studio-devmode-prop

Conversation

@t-wright
Copy link
Copy Markdown
Contributor

@t-wright t-wright commented Apr 14, 2026

Fixes FORNO-337

Proposed changes

  • Adds is_dev_mode() function to Image Studio that detects dev/test environments (localhost, Jurassic Ninja/Tube, proxied A8C requests, Atomic proxied requests)
  • Passes the result as isDevMode in the imageStudioData inline script object, so the Calypso side (wp-calypso#109983) can tag analytics events as test traffic
  • Logic mirrors Agents_Manager::is_dev_mode() so Image Studio works independently of Big Sky

Related product discussion/links

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

No new tracking. This adds a flag that allows the Calypso consumer to distinguish dev/test traffic from production traffic in existing analytics.

Testing instructions

Adds a is_dev_mode() check that mirrors the Agents_Manager logic to
detect local/dev/proxied environments. The resulting isDevMode flag is
passed to Calypso so analytics events can be tagged as test traffic.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 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 (Jetpack), and enable the image-studio-devmode-prop branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack image-studio-devmode-prop

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 github-actions bot added [Extension] Image Studio [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Tests] Includes Tests labels Apr 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

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!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: May 5, 2026
    • Code freeze: May 4, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Apr 14, 2026
@jp-launch-control
Copy link
Copy Markdown

jp-launch-control bot commented Apr 14, 2026

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/functions.global.php 25/182 (13.74%) 4.53% 9 💔
projects/plugins/jetpack/extensions/plugins/image-studio/image-studio.php 146/158 (92.41%) 0.05% 0 💚

Full summary · PHP report · JS report

Coverage check overridden by I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. .

Adds unit tests covering each early-return branch: production domain
(false), localhost, jurassic.ninja, jurassic.tube, and
wpcom_is_proxied_request().
@t-wright t-wright force-pushed the image-studio-devmode-prop branch from b2218b7 to b1c8392 Compare April 14, 2026 07:52
@t-wright t-wright added the I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. label Apr 15, 2026
@t-wright t-wright marked this pull request as ready for review April 15, 2026 04:25
…nager

The jetpack-mu-wpcom package is only available on WordPress.com hosted
sites, so Image Studio needs its own copy for self-hosted Jetpack sites.
Copy link
Copy Markdown
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

Adds a dev/test environment signal to Image Studio so Calypso can distinguish test traffic from production when emitting analytics.

Changes:

  • Add is_dev_mode() detection (localhost/Jurassic, proxied A8C requests, Atomic proxied requests) to Image Studio.
  • Expose the result as isDevMode on the imageStudioData inline script object.
  • Add PHPUnit coverage for the new inline property and some is_dev_mode() scenarios, plus a changelog fragment.

Reviewed changes

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

File Description
projects/plugins/jetpack/extensions/plugins/image-studio/image-studio.php Introduces is_dev_mode() and adds isDevMode into the inline imageStudioData.
projects/plugins/jetpack/tests/php/extensions/plugins/image-studio/Image_Studio_Test.php Adds tests asserting isDevMode exists and basic URL-based dev mode detection.
projects/plugins/jetpack/changelog/image-studio-devmode-prop Documents the change in Jetpack’s changelog fragments.

Comment on lines +84 to +88
$domain = wp_parse_url( get_site_url(), PHP_URL_HOST );
if (
$domain === 'localhost' ||
'.jurassic.tube' === stristr( $domain, '.jurassic.tube' ) ||
'.jurassic.ninja' === stristr( $domain, '.jurassic.ninja' )
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

wp_parse_url( get_site_url(), PHP_URL_HOST ) can return false/null, which then gets passed into stristr(). On newer PHP versions this can raise warnings/deprecations for non-string arguments. Consider normalizing $domain to a string (or early-returning false when no host is present) before calling stristr().

Copilot uses AI. Check for mistakes.
$this->assertFalse( ImageStudio\is_dev_mode() );
}

/**
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

is_dev_mode() includes multiple proxy/constant-based detection paths, but the unit tests only cover localhost/Jurassic and the default false case. Add coverage for at least the $_SERVER['A8C_PROXIED_REQUEST'] path (and ideally the wpcom_is_proxied_request() and AT_PROXIED_REQUEST/ATOMIC_CLIENT_ID paths) to prevent regressions in environments where the site URL is production-like but requests are proxied.

Suggested change
/**
/**
* Test is_dev_mode returns true for proxied production requests.
*/
public function test_is_dev_mode_returns_true_for_a8c_proxied_request() {
update_option( 'siteurl', 'https://example.com' );
$had_proxied_request = array_key_exists( 'A8C_PROXIED_REQUEST', $_SERVER );
$original_value = $had_proxied_request ? $_SERVER['A8C_PROXIED_REQUEST'] : null;
try {
$_SERVER['A8C_PROXIED_REQUEST'] = '1';
$this->assertTrue( ImageStudio\is_dev_mode() );
} finally {
if ( $had_proxied_request ) {
$_SERVER['A8C_PROXIED_REQUEST'] = $original_value;
} else {
unset( $_SERVER['A8C_PROXIED_REQUEST'] );
}
}
}
/**

Copilot uses AI. Check for mistakes.
Comment thread projects/plugins/jetpack/changelog/image-studio-devmode-prop Outdated
saroshaga
saroshaga previously approved these changes Apr 15, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Prevents any risk of siteurl state leaking between tests, independent
of the WP_UnitTestCase transaction rollback.
…dev_mode()

Moves the dev/test environment detection helper out of the Image Studio
extension and into functions.global.php so other parts of the Jetpack
plugin can reuse it. Tests live alongside other functions.global.php
tests in Functions_Global_Test.php.
Avoids passing false/null to stristr() in edge cases where the site URL
has no host component.
saroshaga
saroshaga previously approved these changes Apr 17, 2026
…nt()

The previous name overlapped with Jetpack's legacy "Development Mode"
terminology (now Status::is_offline_mode()) and could mislead developers
searching for dev-mode helpers. The new name makes clear this is about
detecting A8C-internal testing infrastructure for analytics tagging.
Copy link
Copy Markdown
Contributor

@kat3samsin kat3samsin left a comment

Choose a reason for hiding this comment

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

Thanks for adding this!

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

Labels

[Extension] Image Studio I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants