Skip to content

Premium Analytics: document widget conventions and Stats porting patterns#49987

Open
dognose24 wants to merge 4 commits into
trunkfrom
add/widget-conventions-docs
Open

Premium Analytics: document widget conventions and Stats porting patterns#49987
dognose24 wants to merge 4 commits into
trunkfrom
add/widget-conventions-docs

Conversation

@dognose24

@dognose24 dognose24 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Why

Code review on the Locations (#49513), Devices (#49928), and Search Terms (#49985) widget ports surfaced a set of recurring mistakes and missing patterns — attribute type locality, `presentation` source of truth, `max = 0` semantics, the two-component WidgetRoot structure, and more. This PR consolidates those into shared agent guidance so future batch ports have one source of truth instead of rediscovering them in review.

What

`.agents/rules/widgets.md`

  • New Two-component structure section: outer component wraps ``, inner calls `useWidgetRootContext()`; explains why the split is required and that `reportParams` always comes from context, never from `attributes`

`projects/packages/premium-analytics/AGENTS.md`

  • General Pitfalls: `@jetpack-premium-analytics/*` alias rule, English-only comments
  • Widget pitfalls (5 new): `presentation` only in `widget.json`; attribute type declared once in `widget.ts` and imported; ``; no inline styles; check toolkit helpers before reimplementing
  • New Stats widgets section covering: data hooks already exist in `packages/data/`; data access path (`primary.data → .data?.[0]?.items`); `max = 0` means all rows; loading/stale-data strategy; comparison placeholders; visual conventions (title variant, dataFormat, row height, emptyStateText, picker aspect ratio)

`.agents/skills/widget-audit.md`

  • Shape: `widget.ts` must not declare `presentation`; ghost attribute check; `@jetpack-premium-analytics/*` alias enforcement
  • Contract: attribute type `T` imported from `../widget`, not re-declared in `render.tsx`
  • Chrome: `presentation` value vs actual layout consistency check
  • Style + i18n: no inline styles; explicit `` type; i18n covers data-transform layer; English comments

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

No.

Testing instructions

Documentation-only change — no runtime code is modified. To verify:

🤖 Generated with Claude Code

…erns

Consolidates conventions surfaced during code review of the Locations
(#49513), Devices (#49928), and Search Terms (#49985) ports into shared
agent guidance so future batch ports have a single source of truth.

- `.agents/rules/widgets.md` — adds Two-component structure section
  (outer WidgetRoot / inner useWidgetRootContext, reportParams from context)
- `AGENTS.md` — adds package-wide pitfalls (alias naming, English comments)
  and new Widget pitfalls (presentation source of truth, attribute type
  locality, button type, inline styles, toolkit helpers); new Stats widgets
  section covering data hooks, data access path, max=0 semantics, loading
  strategy, comparison placeholders, and visual conventions
- `.agents/skills/widget-audit.md` — extends checklist with presentation
  consistency, ghost attributes, alias names, WidgetRenderProps<T> import,
  inline styles, button type, i18n scope, and English comments

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 26, 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 26, 2026
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@jp-launch-control

Copy link
Copy Markdown

Code Coverage Summary

This PR did not change code coverage!

That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷

Full summary · PHP report

@dognose24 dognose24 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 26, 2026
@github-actions github-actions Bot added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Jun 26, 2026
@dognose24 dognose24 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 26, 2026
@dognose24 dognose24 requested a review from Copilot June 26, 2026 15:24

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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