Skip to content

feat(premium-analytics): expose initial_full_sync_finished on sync status response#49602

Open
chihsuan wants to merge 1 commit into
trunkfrom
wooa7s-1542-expose-sync-milestone-live
Open

feat(premium-analytics): expose initial_full_sync_finished on sync status response#49602
chihsuan wants to merge 1 commit into
trunkfrom
wooa7s-1542-expose-sync-milestone-live

Conversation

@chihsuan

@chihsuan chihsuan commented Jun 15, 2026

Copy link
Copy Markdown
Member

Related to WOOA7S-1542. Backend half; the frontend consumer (#49267) stacks on top.

Proposed changes

Why: The analytics dashboard reads the initial-full-sync milestone (jetpack_premium_analytics_initial_full_sync_finished) to know when the first analytics sync has completed. Today Sync_Status_Tracker surfaces it only once, at page load, via JetpackScriptData — a static snapshot that can't reflect a sync finishing mid-session.

How: A rest_post_dispatch filter in Sync_Status_Tracker appends the milestone to Jetpack core's existing GET /jetpack/v4/sync/status response. No new endpoint and no Jetpack-core changes — the field rides along on the poll the dashboard already makes. Only the already-authorized, successful status payload is touched; other routes and error responses pass through untouched (no milestone leak).

What: GET /jetpack/v4/sync/status now includes an initial_full_sync_finished integer (0 until the analytics initial full sync completes, then the finish timestamp). Additive and standalone — no consumer in this PR (same split as the PHP/JS halves #49211 / #49267).

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

No.

Testing instructions

cd projects/packages/premium-analytics
composer phpunit   # 34 tests pass, incl. enrich_sync_status_response coverage

On a Jetpack-connected site with the package active:

  • GET /jetpack/v4/sync/status now includes an initial_full_sync_finished integer.
  • Confirm non-status routes (e.g. POST /jetpack/v4/sync/full-sync) and unauthorized/error responses are unaffected.

@github-actions

github-actions Bot commented Jun 15, 2026

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!

@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 Jun 15, 2026
@jp-launch-control

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/premium-analytics/src/Sync/class-sync-status-tracker.php 45/49 (91.84%) 2.36% 0 💚

Full summary · PHP report

Copilot AI 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.

Pull request overview

This PR enhances the Premium Analytics sync milestone exposure by injecting the persisted initial_full_sync_finished timestamp into Jetpack core’s existing GET /jetpack/v4/sync/status REST response, enabling consumers (e.g., the analytics dashboard) to observe the milestone flipping mid-session via the existing polling mechanism.

Changes:

  • Add a rest_post_dispatch filter in Sync_Status_Tracker to append initial_full_sync_finished to successful /jetpack/v4/sync/status responses.
  • Extend PHPUnit coverage to validate enrichment behavior (correct route only, skips error responses, passthrough for non-REST responses).
  • Add a changelog entry documenting the new REST response field.

Reviewed changes

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

File Description
projects/packages/premium-analytics/src/Sync/class-sync-status-tracker.php Adds REST response enrichment for /jetpack/v4/sync/status with the milestone timestamp.
projects/packages/premium-analytics/tests/php/Sync/Sync_Status_Tracker_Test.php Adds unit tests covering the new REST enrichment behavior and hook registration.
projects/packages/premium-analytics/changelog/wooa7s-1542-expose-sync-milestone-live Documents the new initial_full_sync_finished field on the sync status REST response.

@chihsuan chihsuan added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Jun 15, 2026
@chihsuan chihsuan requested review from a team and kangzj June 15, 2026 05:21

@louwie17 louwie17 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 @chihsuan and tested well, nice work!

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.

3 participants