Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gutenberg: Add Blog Stats Block #34557

Merged
merged 27 commits into from
Feb 2, 2024
Merged

Conversation

Aurorum
Copy link
Contributor

@Aurorum Aurorum commented Dec 9, 2023

Fixes #17588

Proposed changes:

Converts the Blog Stats legacy widget into a block so that it can be used with FSE. This is broadly just a 1:1 convert of a pretty simple (albeit popular) widget, but I've added a feature whereby users can display views for a single item rather than their entire site.

Screenshot 2023-12-09 at 19 09 22

Jetpack product discussion

See the original issue and Automattic/wp-calypso#63584 (comment)

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

No - it uses Stats data, but in the same way as the Legacy Widget does.

Testing instructions:

You'll need to enable Beta blocks for this. When you insert the Blog Stats block, you should be able to insert text that follows the view count, similar to the widget. I thought that it was a nice touch to display the actual view count where possible, but "12,345" should appear as a placeholder when there is no Post ID (eg. widgets/FSE templates). The correct view count should appear when on the front end, so you might want to confirm this happens.

Screenshot 2023-12-09 at 22 34 38

Also, you'll want to verify that you're encouraged to active the Stats module if it's disabled, and that setting successfully works. I felt it was best not to share the code with the Top Posts block here because it's not that much, and I've also stressed that views are only counted when the module is active, which feels more relevant to this block.

For context, this is the legacy widget it replaces - it should be a fairly 1:1 conversion, besides the extra feature to display stats for an individual post:
Screenshot 2023-12-09 at 19 13 51

@kangzj super sorry to ping you for another stats block so soon - if you do fancy taking a look at this one (and totally understand if not given you've just reviewed the Top Posts and Pages block!), this one should be 10x simpler :)

@github-actions github-actions bot added [Feature] Extra Sidebar Widgets [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests [Block] Blog Stats labels Dec 9, 2023
Copy link
Contributor

github-actions bot commented Dec 9, 2023

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 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 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.



Jetpack plugin:

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

  • WordPress.com Simple releases happen daily.
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly. The next release is scheduled for February 6, 2024 (scheduled code freeze on February 5, 2024).

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


Backup plugin:

  • Next scheduled release: March 5, 2024.
  • Scheduled code freeze: February 26, 2024.

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


Boost plugin:

  • Next scheduled release: March 5, 2024.
  • Scheduled code freeze: February 26, 2024.

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


Search plugin:

  • Next scheduled release: March 5, 2024.
  • Scheduled code freeze: February 26, 2024.

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


Social plugin:

  • Next scheduled release: March 5, 2024.
  • Scheduled code freeze: February 26, 2024.

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


Starter Plugin plugin:

  • Next scheduled release: March 5, 2024.
  • Scheduled code freeze: February 26, 2024.

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


Protect plugin:

  • Next scheduled release: March 5, 2024.
  • Scheduled code freeze: February 26, 2024.

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


Videopress plugin:

  • Next scheduled release: March 5, 2024.
  • Scheduled code freeze: February 26, 2024.

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


Migration plugin:

  • Next scheduled release: March 5, 2024.
  • Scheduled code freeze: February 26, 2024.

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


Mu Wpcom plugin:

  • Next scheduled release: March 5, 2024.
  • Scheduled code freeze: February 26, 2024.

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 OSS Citizen This Pull Request was opened by an Open Source contributor. label Dec 9, 2023
@@ -99,7 +111,7 @@ public function form( $instance ) {
<label for="<?php echo esc_attr( $this->get_field_id( 'hits' ) ); ?>"><?php esc_html_e( 'Pageview Description:', 'jetpack' ); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'hits' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'hits' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['hits'] ); ?>" />
</p>
<p><?php esc_html_e( 'Hit counter is delayed by up to 60 seconds.', 'jetpack' ); ?></p>
<p><?php esc_html_e( 'Hit counter is delayed by up to 5 minutes.', 'jetpack' ); ?></p>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The caching time has increased since the widget was released (I think it happened when moving functions to the Stats package)

/**
* Time, in minutes, to cache stats results from the REST API.
*
* @var int
*/
const STATS_CACHE_EXPIRATION_IN_MINUTES = 5;

@kangzj kangzj requested review from jeherve, a team and kangzj December 11, 2023 01:55
@kangzj
Copy link
Contributor

kangzj commented Dec 11, 2023

Wow another productive week uh @Aurorum 🤩 Nice one! I'll take a spin this week. Thank you so much for your contribution ❤️

@Aurorum
Copy link
Contributor Author

Aurorum commented Dec 11, 2023

Thanks so much! No rush at all. :)

@github-actions github-actions bot added the [Plugin] Search A plugin to add an instant search modal to your site to help visitors find content faster. label Dec 13, 2023
@Aurorum
Copy link
Contributor Author

Aurorum commented Dec 21, 2023

Trying to fix the tests, but I seem to get this error whenever I try to update the branch (not just this branch, but any Jetpack one).

Checking for filename collisions. Just a sec...
No collisions detected.
Checking if changelog files are needed. Just a sec...
Project packages/backup-helper-script-manager is being changed, but no change file in projects/packages/backup-helper-script-manager/changelog/ is touched!
Use `jetpack changelogger add <slug>` to add a change file for each project.
Guidelines: https://github.com/Automattic/jetpack/blob/trunk/docs/writing-a-good-changelog-entry.md
Checking if changelog files are needed. Just a sec...
? Found 46 project(s) that need a changelog. Create and add the same changelog to all of them?

Any ideas what I'm doing wrong?! I'm assuming that I'm not supposed to actually add a changelog for each project.

@kraftbj
Copy link
Contributor

kraftbj commented Dec 21, 2023

At first blush, I thought it might be a situation where if you update a package version that is used in a lot of different packages, there will often need a changelog in all of the impacted projects to acknowledge the package dependencies were updated.

But, I don't think that's what's happening here. Or at least not as straightforward. It looks like your branch is a little behind trunk as well, I opened Aurorum#2 for you to pull in the latest trunk changes. I'm curious if you accept that PR into your branch, if the issue will continue.

* Social: Fix auto-conversion cleanup logic (Automattic#34666)

* Fix logic to be mindful of absent option

* changelog

* Fixup versions

* Launchpad: Improve the WC task visibility check (Automattic#34648)

* Improve the WC task visibility check

* Bump version

* Fix composer

* changelog

* Bump version

---------

Co-authored-by: Valter Lorran <[email protected]>

* Improve sharing buttons events performance (Automattic#34652)

* Backport mu-wpcom-plugin 2.0.7, jetpack 13.0-a.5 Changes (Automattic#34676)

* Changelog edits.

* Init new cycle

* Carousel: fix unresponsive navigation (Automattic#34678)

* Check for both aksimet and antispam for backwards compatibility (Automattic#34674)

* Jetpack Google Fonts: Fix the fonts provided by theme are still added (Automattic#34608)

* Google Fonts: Ignore the fonts that are provied by the active theme

* changelog

* Update syntax

* Subscribers: fix the reach count above 1000 (Automattic#34689)

Allows strings in translation strings. Ensures reachCount is consistently a Number, and convert it to string for localization.

* Subscriptions: localize number format in access panel (Automattic#34691)

* Added preemptive check full sync posts processing (Automattic#34661)

* Added preemptive check to break the loop of adding metadata if we are already over the MAX SIZE

* Added changelog

* Added break 2 since there is no point in doing the comparison in the outer loop which will break too

* Version bump

* Like block: remove like module dependency (Automattic#34664)

* - Remove dependency on likes module
- Render master iframe (only once)

* Changelog

* Don't render anything when post_id is missing

* Better check

* Change master to main

* Enqueue styles & register them on first usage

* Remove require_once

* Update iframe for WPCOM

* Require the module

* Docs: update quick start guide (Automattic#34656)

* Clarify quick start guide is geared for a12s

* Cleanup cloning and install script steps

* Move env checker script heading below install steps

* Adjust heading levels

* Move jtube a11n-only note to top of its section

* Add ngrok/jtube info to full dev-env guide

* CRM: Ensure segments can be deleted (Automattic#34690)

* Update JS unit testing packages (major) (Automattic#34694)

* Update JS unit testing packages
* Update indirect @adobe/css-tools dep

---------

Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Brad Jorsch <[email protected]>

* Update storybook monorepo to v7.6.5 (Automattic#34696)

Co-authored-by: Renovate Bot <[email protected]>

* Show an error when one is encountered while rendering a payment button (Automattic#34380)

* Render an error message when the button cannot be rendered

* changelog

* CRM: Resolves 3399 - make KB links consistent in settings (Automattic#34695)

* Adjust wording to clarify all fields can show in Woo My Account

* Add KB link

* Use consistent UI to link to KB from settings

* Simplify wording

* Remove stray end tag

* Remove errant colspan attribute

* Add changelog

* Only contact fields

* Feature: AI Assistant UI fixes (Automattic#34383)

* use spinner instead of ai icon

* adjust main action button styles

* only show main action buttons when there's content. Switch between icon and label for mobile. Do not show clear button is state is requesting

* do not show clearbutton

* changelog

* fix versions

* keep spinner while suggesting state

* remove clear button

* AI Assistant: change main action buttons style and behavior (Automattic#34370)

* optimize style declaration

* always use inputValue

* AI Assistant: add suggestions actions (Automattic#34399)

* add suggestion action buttons

* add editRequest state to handle back and forth editing 'mode'

* add discard callback on AI control, pass on tryAgain handler

* add changelog entries

* adjust behavior upon observations

* AI Assistant: improve spacing and sizes for block and action buttons (Automattic#34444)

* address spacing and size issues on the assistant block

* modify loading icon wrapper and size

* avoid height jumps when buttons wrapper is introduced

* fix spacing on icon buttons

* add changelogger entry for js-package

* AI Assistant: fix block to bottom when content exceeds the viewport height (Automattic#34452)

* fix ai block to bottom when content exceeds the viewport height

* add outside wrapper

* move positioning directive to outside wrapper

* adjust bottom space for outside wrapper

* AI Assistant: remove try again toolbar button (Automattic#34464)

* make handleTryAgain optional so to remove when not present

* add changelog entry

* AI Assistant bar: fix positioning on mobile (Automattic#34476)

* wrap assistant bar to control positioning

* always make sure the assistant bar is placed AFTER the toolbar

* add changelog entry

* AI Assistant: add prompt to attributes (Automattic#34438)

* add userPrompt to the block's attributes

* set last value to default to initial prop

* add requestingState to attributes to keep consistency between reloads

* add changelog entry

* AI assistant: change guideline component (Automattic#34496)

* fix multiple line display on ai control footer message

* export AI control message as FooterMessage

* add changelog entry

* AI Assistant: fix bottom padding issue (Automattic#34519)

* fix bottom padding by using bottom directive for sticky positioning

* add changelog entry

* remove unnecessary directive

* AI Assistant: restrict stored state value (Automattic#34522)

* restrict stored states to 'init' and 'done' so we don't reload into half way scenarios

* add changelog entry

* fix misuse of ternary

* add cancel button to get rid of the assistant block (Automattic#34524)

* AI Client: fix empty prompts handling (Automattic#34547)

* use a default value to keep track of changes in the prompt, allow for empty prompts to show suggestion action buttons

* use null instead of a made up default value

* handle edit mode logic on one-click actions (Automattic#34584)

* AI Assistant: prepare new UI/UX features for merge (Automattic#34620)

* consolidate changelog entry for ai-client

* consolidate changelog entry for Jetpack plugin

* add test instructions for the new AI Assistant UI/UX

* AI Assistant: change prompt placeholder (Automattic#34671)

* remove typing effect from prompt placeholders

* use a fixed placeholder with suggestions on how to create a prompt

* use different placeholders depending on whether there is content or not

* move ternary out of jsx chunk

* take i18n out of ternary

* change placeholder text

* remove back to edit button (Automattic#34675)

* add showRemove attribute to AIControl (Automattic#34677)

* Cleanup quick wins after feedback (Automattic#34679)

* clean up changelog entries for ai-client

* clean up changelog entries for jetpack plugin

* AI assistant: fix positioning (Automattic#34700)

* remove some confusing 100% widths messing with border alignments

* fix colliding bottom directives on assistant bar

* Membership services: small refactor (Automattic#34635)

* Very small clean up

* Rename abstract class filename

* Create membership-abstract-token-class

* Fix path

* fix typing

* Update class-wpcom-online-subscription-service.php

* Update projects/plugins/jetpack/extensions/blocks/premium-content/_inc/subscription-service/class-asbtract-token-subscription-service.php

Co-authored-by: Miguel Lezama <[email protected]>

* Update projects/plugins/jetpack/extensions/blocks/premium-content/_inc/subscription-service/class-jetpack-token-subscription-service.php

Co-authored-by: Miguel Lezama <[email protected]>

* Rename file

* Update class-wpcom-online-subscription-service.php

* Rename references to Token_Subscription_Service

* Fix naming

---------

Co-authored-by: Miguel Lezama <[email protected]>

* Boost: Refactor module, index and more into React (Automattic#34662)

* Create skeleton for Module component in React

* Refactor UpgradeCTA to React

* Added a small variant for toggle control

* Use small variant of toggle control

* Fix onEnable, onMountEnable, and onDisable

* Do not pass yearlyPricing

* Implement onEnable and onDisable

* changelog

* Create index component

* Make module errors consistent with old design

* Fix ISA alignment

* Improve alignments and spacing

* Add resize unavailable notice

* Add fake recommendations meta

* Add missing pieces

* Cleanup

* Remove Index.svelte

* Move pricing to ds based config

* Remove Module.svelte

* Use React DS based moduleState management

* Restore tsconfig change

* Change interface for useModuleState callbacks

* Call useModuleState hook directly on the component

* Fix infinite loop on purchase success

* Fixup project version

* Fix selector in test

* Make speed score dependent on useModulesState for auto-refresh to work

* Fix isModuleEnabled check

* Update modules-state endpoint in tests

---------

Co-authored-by: Mark George <[email protected]>

* Boost: Migrate Tips to react (Automattic#34697)

* Update Tips to react

* add changelog

* Backport crm 6.3.2 Changes (Automattic#34708)

* Fix missing class fatal related to PR Automattic#34635 (Automattic#34705)

* CRM: start 6.3.3-alpha release cycle (Automattic#34710)

* Fix My plan dashboard js errors due to nested anchor tags  (Automattic#34707)

* Moved href from Button props to ExternalLink props to avoid duplicate anchor tags

* Added changelog

* Admin Page: avoid react warning with VideoPress card (Automattic#34713)

This should avoid us getting the following warning:

```
Warning: Failed prop type: Invalid prop `overrideContent` of type `boolean` supplied to `DashItem`, expected a single ReactElement.
DashItem@wp-content/plugins/jetpack/_inc/build/admin.js?ver=28b3a12169ab227bdcfa:36878:1
SettingsForm@wp-content/plugins/jetpack/_inc/build/admin.js?ver=28b3a12169ab227bdcfa:43524:3
ConnectFunction@wp-content/plugins/jetpack/_inc/build/admin.js?ver=28b3a12169ab227bdcfa:8870:68
ConnectFunction@wp-content/plugins/jetpack/_inc/build/admin.js?ver=28b3a12169ab227bdcfa:8870:68
DashVideoPress@wp-content/plugins/jetpack/_inc/build/admin.js?ver=28b3a12169ab227bdcfa:34467:1
```

* Fix missing class fatal related to PR Automattic#34635 (Automattic#34718)

* Subscriptions: update "verify your email" wall copy (Automattic#34716)

Co-authored-by: Jeremy Herve <[email protected]>

* Fix sharing buttons window open (Automattic#34703)

* Contact Form: add extra field settings to base field (Automattic#34704)

* Contact Form: add extra field settings to base field

* Fix package version

* Fix the media validation notice shown even when auto conversion is enabled. (Automattic#34730)

Co-authored-by: Gergely Juhasz <[email protected]>

* Add `wpcom_ai_site_prompt` option to the site settings endpoint (Automattic#34709)

* Social: Fix endpoint backwards compatibility (Automattic#34566)

* Readd REST controllers with updated logic

* Readd class-settings classes for initial state population

* changelog

* Use depreacted and next_version tags

* Fixup versions

* Boost: Update Settings Page to react (Automattic#34714)

* Update Settings Page to react

* add changelog

* Sharing: update Twitter and X buttons to support official X button (Automattic#34719)

* Sharing: update Twitter and X buttons to support official X button

See Automattic#34459

- The official Twitter button is no more; it has been updated to the X design. Let's update our preview Twitter button match.
- Since we now have an official X button, let's offer it with the X service.

* Adjust official button styles in wp-admin

* This method is not needed

* Update domain name

* Update source name

* Bump version by specifying Jetpack version when enqueuing

* Update logo

* Update icon with more radius

* Social | Hide conversion notice for Simple sites (Automattic#34733)

* Hide notice on simple sites

* changelog

* Make auto-conversion disabled if not available

* Fixup versions

* Sharing buttons block alternate settings screen (Automattic#34673)

* build: Use a GitHub webhook to trigger the betadownload site (Automattic#34604)

Once Automattic/jetpack-builder#36 is deployed, we can update our build
script to produce the artifact for forked PRs and set up a GitHub
webhook for the `workflow_run` event to support testing with PRs from
forked repositories.

This requires the GitHub "Fork pull request workflows from outside
collaborators" setting to be set to "Require approval for all outside
contributors" to avoid unreviewed code potentially producing malicious
zips for the betadownload server. We've had that set since March 2023
(p9dueE-6Rp-p2).

This also updates the Jetpack Live Branches script to remove the check
for a forked PR, since we can now test with them.

* Contact Form: minify stylesheets in prod (Automattic#34672)

* Contact Form: minify stylesheets in prod

* Update registered styles paths

* Fix package version

* Tools: Add the Readme to the release script (Automattic#34722)

* Make sure the readme.txt file gets updated after saving changelog edits

* Fix command being run

* comment out a check

* pass the correct flag

* Undo comments

* Update the next steps at the end

* Fix token subscription service name (Automattic#34723)

* Rename Token_Subscript_Service to Abstract_Token_Subscription_Service

* changelog

* Allow old class just in case

* `use` classes at the top to shorten up the class check.

* Content Lens: move feature to `beta` (Automattic#34740)

* move `content-lens` feature to beta

* changelog

* Newsletter prepublish panel: update toggle appearance (Automattic#34724)

* Contact Form: add accessible name to form (Automattic#34667)

* Contact Form: add accessible name to form

* Update accessible name on content change

* Remove unused code

* Fix package version

* Add warning notice

* Backport mu-wpcom-plugin 2.0.8, jetpack 13.0-a.7 Changes (Automattic#34742)

* Changelog and readme.txt edits.

* Init new cycle

* Fix the stable tag

* [Boost] Fix importmap deferral (Automattic#34746)

* Add importmap to the set of script types we exclude from deferral

* changelog

* Fix versions in packages/forms

* changelog

---------

Co-authored-by: Mark George <[email protected]>

* Update changelog (Automattic#34747)

* Admin page: remove alt attribute from decorative icon (Automattic#34715)

The Alt value isn't necessary here, since the icon doesn't bring any additional info on the page for folks using screen readers.

This has the added benefit of getting rid of a React warning:

```
Warning: Failed prop type: Invalid prop `alt` of type `object` supplied to `PlanIcon`, expected `string`.
PlanIcon@wp-content/plugins/jetpack/_inc/build/admin.js?ver=15a830895a6f6d1e3c39:44686:1
MyPlanCard@wp-content/plugins/jetpack/_inc/build/admin.js?ver=15a830895a6f6d1e3c39:51709:20
```

* Add/fix typo (Automattic#34712)

* Fix typo

* Chnagelog

---------

Co-authored-by: Fabien MILLERAND <[email protected]>

* Boost: Refactor navigation into react (Automattic#34731)

* Use react router

* Add redirects

* Fix typo

* Add dummy ISA page

* Add tracks

* Restore getting started functionality

* Move props to DS

* Move connection to DS and cleanup props

* Remove connection from JS constants

* Improve getting started handling

* Remove wrapping individual components with `DataSyncProvider`

* Only start ISA if ISA is active

* changelog

* Use hook and component provided by react-router-dom

* Remove data-sync provider wrapping from settings-page

* Remove jetpack connection prop from analytics

Analytics isn't collected while there is no connection. So, this prop is unnecessary anyway.

* Pop bubbles for performanceHistoryNeedsUpdate

* Fix priority support

* Cast wpcom blogId into integer

* Fix getting started with free

* Fix getting started for real

* Show index for missing routes

* Stats: add passing select UTM parameters (Automattic#34431)

This commit adds select UTM parameters to the pixel requests send to wp.com, so that we can show more statistics to site owners.

---------

Co-authored-by: Gergely Márk Juhász <[email protected]>
Co-authored-by: valterlorran <[email protected]>
Co-authored-by: Valter Lorran <[email protected]>
Co-authored-by: Andrii Lysenko <[email protected]>
Co-authored-by: Steve D <[email protected]>
Co-authored-by: Kev <[email protected]>
Co-authored-by: arthur791004 <[email protected]>
Co-authored-by: Mikael Korpela <[email protected]>
Co-authored-by: Juanma Rodriguez Escriche <[email protected]>
Co-authored-by: Tim Broddin <[email protected]>
Co-authored-by: Samiff <[email protected]>
Co-authored-by: Karen Attfield <[email protected]>
Co-authored-by: Calypso Bot <[email protected]>
Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Brad Jorsch <[email protected]>
Co-authored-by: Chris McCluskey <[email protected]>
Co-authored-by: tbradsha <[email protected]>
Co-authored-by: Christian Gastrell <[email protected]>
Co-authored-by: MILLER/F <[email protected]>
Co-authored-by: Miguel Lezama <[email protected]>
Co-authored-by: Adnan Haque <[email protected]>
Co-authored-by: Mark George <[email protected]>
Co-authored-by: Peter Petrov <[email protected]>
Co-authored-by: Jeremy Herve <[email protected]>
Co-authored-by: Manzoor Wani <[email protected]>
Co-authored-by: Gergely Juhasz <[email protected]>
Co-authored-by: Griffith Chen <[email protected]>
Co-authored-by: Brad Jorsch <[email protected]>
Co-authored-by: Christopher Smith <[email protected]>
Co-authored-by: Damián Suárez <[email protected]>
Co-authored-by: thingalon <[email protected]>
Co-authored-by: Fabien MILLERAND <[email protected]>
Co-authored-by: Piotr Stankowski <[email protected]>
@github-actions github-actions bot added [Block] AI Assistant [Block] Contact Form Form block (also see Contact Form label) labels Dec 21, 2023
@kangzj
Copy link
Contributor

kangzj commented Jan 31, 2024

Thanks for working on this @Aurorum 👍 I'll take a look early tomorrow 😄

@kangzj
Copy link
Contributor

kangzj commented Feb 1, 2024

Sorry I didn't manage to get onto this one today. Will do first thing tomorrow.

@Aurorum
Copy link
Contributor Author

Aurorum commented Feb 1, 2024

All good! :)

Copy link
Contributor

@kangzj kangzj 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 your amazing work @Aurorum 👍

All looks and works amazingly well except for missing a return and another nitpick 👍 👍 👍

$this->resource = sprintf( 'post/%d', $post_id );

if ( $cache_in_meta ) {
$this->fetch_post_stats( $args, $post_id );
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$this->fetch_post_stats( $args, $post_id );
return $this->fetch_post_stats( $args, $post_id );

I believe we should return the result here 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops, great spot! :)

@Aurorum
Copy link
Contributor Author

Aurorum commented Feb 2, 2024

Thanks so much - very much appreciated! :))

Copy link
Contributor

@kangzj kangzj left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thanks for working on this 👍 ❤️

@kangzj kangzj enabled auto-merge (squash) February 2, 2024 02:05
@kangzj kangzj merged commit 2b429b9 into Automattic:trunk Feb 2, 2024
52 checks passed
@Aurorum
Copy link
Contributor Author

Aurorum commented Feb 2, 2024

Thanks so much for your help @kangzj! ❤️

Do we need to create an issue like #32937 on the steps still needed to get the block out of beta (supporting WPcom etc) or will that be okay?

@kangzj
Copy link
Contributor

kangzj commented Feb 4, 2024

Do we need to create an issue like #32937 on the steps still needed to get the block out of beta (supporting WPcom etc)

Hi @Aurorum, thanks for your contribution. Yes, it'll be great to track it than forgetting it later 😄 I've filed an issue for that:

#35436

spsiddarthan pushed a commit that referenced this pull request Feb 15, 2024
* Initial commit

* Add block

* Improving handling for no post ID

* Improve i18n

* Override cache

* Run tools/fixup-project-versions.sh

* Cache stats again

* Cache in post meta

* Catch up your branch (#2)

* Social: Fix auto-conversion cleanup logic (#34666)

* Fix logic to be mindful of absent option

* changelog

* Fixup versions

* Launchpad: Improve the WC task visibility check (#34648)

* Improve the WC task visibility check

* Bump version

* Fix composer

* changelog

* Bump version

---------

Co-authored-by: Valter Lorran <[email protected]>

* Improve sharing buttons events performance (#34652)

* Backport mu-wpcom-plugin 2.0.7, jetpack 13.0-a.5 Changes (#34676)

* Changelog edits.

* Init new cycle

* Carousel: fix unresponsive navigation (#34678)

* Check for both aksimet and antispam for backwards compatibility (#34674)

* Jetpack Google Fonts: Fix the fonts provided by theme are still added (#34608)

* Google Fonts: Ignore the fonts that are provied by the active theme

* changelog

* Update syntax

* Subscribers: fix the reach count above 1000 (#34689)

Allows strings in translation strings. Ensures reachCount is consistently a Number, and convert it to string for localization.

* Subscriptions: localize number format in access panel (#34691)

* Added preemptive check full sync posts processing (#34661)

* Added preemptive check to break the loop of adding metadata if we are already over the MAX SIZE

* Added changelog

* Added break 2 since there is no point in doing the comparison in the outer loop which will break too

* Version bump

* Like block: remove like module dependency (#34664)

* - Remove dependency on likes module
- Render master iframe (only once)

* Changelog

* Don't render anything when post_id is missing

* Better check

* Change master to main

* Enqueue styles & register them on first usage

* Remove require_once

* Update iframe for WPCOM

* Require the module

* Docs: update quick start guide (#34656)

* Clarify quick start guide is geared for a12s

* Cleanup cloning and install script steps

* Move env checker script heading below install steps

* Adjust heading levels

* Move jtube a11n-only note to top of its section

* Add ngrok/jtube info to full dev-env guide

* CRM: Ensure segments can be deleted (#34690)

* Update JS unit testing packages (major) (#34694)

* Update JS unit testing packages
* Update indirect @adobe/css-tools dep

---------

Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Brad Jorsch <[email protected]>

* Update storybook monorepo to v7.6.5 (#34696)

Co-authored-by: Renovate Bot <[email protected]>

* Show an error when one is encountered while rendering a payment button (#34380)

* Render an error message when the button cannot be rendered

* changelog

* CRM: Resolves 3399 - make KB links consistent in settings (#34695)

* Adjust wording to clarify all fields can show in Woo My Account

* Add KB link

* Use consistent UI to link to KB from settings

* Simplify wording

* Remove stray end tag

* Remove errant colspan attribute

* Add changelog

* Only contact fields

* Feature: AI Assistant UI fixes (#34383)

* use spinner instead of ai icon

* adjust main action button styles

* only show main action buttons when there's content. Switch between icon and label for mobile. Do not show clear button is state is requesting

* do not show clearbutton

* changelog

* fix versions

* keep spinner while suggesting state

* remove clear button

* AI Assistant: change main action buttons style and behavior (#34370)

* optimize style declaration

* always use inputValue

* AI Assistant: add suggestions actions (#34399)

* add suggestion action buttons

* add editRequest state to handle back and forth editing 'mode'

* add discard callback on AI control, pass on tryAgain handler

* add changelog entries

* adjust behavior upon observations

* AI Assistant: improve spacing and sizes for block and action buttons (#34444)

* address spacing and size issues on the assistant block

* modify loading icon wrapper and size

* avoid height jumps when buttons wrapper is introduced

* fix spacing on icon buttons

* add changelogger entry for js-package

* AI Assistant: fix block to bottom when content exceeds the viewport height (#34452)

* fix ai block to bottom when content exceeds the viewport height

* add outside wrapper

* move positioning directive to outside wrapper

* adjust bottom space for outside wrapper

* AI Assistant: remove try again toolbar button (#34464)

* make handleTryAgain optional so to remove when not present

* add changelog entry

* AI Assistant bar: fix positioning on mobile (#34476)

* wrap assistant bar to control positioning

* always make sure the assistant bar is placed AFTER the toolbar

* add changelog entry

* AI Assistant: add prompt to attributes (#34438)

* add userPrompt to the block's attributes

* set last value to default to initial prop

* add requestingState to attributes to keep consistency between reloads

* add changelog entry

* AI assistant: change guideline component (#34496)

* fix multiple line display on ai control footer message

* export AI control message as FooterMessage

* add changelog entry

* AI Assistant: fix bottom padding issue (#34519)

* fix bottom padding by using bottom directive for sticky positioning

* add changelog entry

* remove unnecessary directive

* AI Assistant: restrict stored state value (#34522)

* restrict stored states to 'init' and 'done' so we don't reload into half way scenarios

* add changelog entry

* fix misuse of ternary

* add cancel button to get rid of the assistant block (#34524)

* AI Client: fix empty prompts handling (#34547)

* use a default value to keep track of changes in the prompt, allow for empty prompts to show suggestion action buttons

* use null instead of a made up default value

* handle edit mode logic on one-click actions (#34584)

* AI Assistant: prepare new UI/UX features for merge (#34620)

* consolidate changelog entry for ai-client

* consolidate changelog entry for Jetpack plugin

* add test instructions for the new AI Assistant UI/UX

* AI Assistant: change prompt placeholder (#34671)

* remove typing effect from prompt placeholders

* use a fixed placeholder with suggestions on how to create a prompt

* use different placeholders depending on whether there is content or not

* move ternary out of jsx chunk

* take i18n out of ternary

* change placeholder text

* remove back to edit button (#34675)

* add showRemove attribute to AIControl (#34677)

* Cleanup quick wins after feedback (#34679)

* clean up changelog entries for ai-client

* clean up changelog entries for jetpack plugin

* AI assistant: fix positioning (#34700)

* remove some confusing 100% widths messing with border alignments

* fix colliding bottom directives on assistant bar

* Membership services: small refactor (#34635)

* Very small clean up

* Rename abstract class filename

* Create membership-abstract-token-class

* Fix path

* fix typing

* Update class-wpcom-online-subscription-service.php

* Update projects/plugins/jetpack/extensions/blocks/premium-content/_inc/subscription-service/class-asbtract-token-subscription-service.php

Co-authored-by: Miguel Lezama <[email protected]>

* Update projects/plugins/jetpack/extensions/blocks/premium-content/_inc/subscription-service/class-jetpack-token-subscription-service.php

Co-authored-by: Miguel Lezama <[email protected]>

* Rename file

* Update class-wpcom-online-subscription-service.php

* Rename references to Token_Subscription_Service

* Fix naming

---------

Co-authored-by: Miguel Lezama <[email protected]>

* Boost: Refactor module, index and more into React (#34662)

* Create skeleton for Module component in React

* Refactor UpgradeCTA to React

* Added a small variant for toggle control

* Use small variant of toggle control

* Fix onEnable, onMountEnable, and onDisable

* Do not pass yearlyPricing

* Implement onEnable and onDisable

* changelog

* Create index component

* Make module errors consistent with old design

* Fix ISA alignment

* Improve alignments and spacing

* Add resize unavailable notice

* Add fake recommendations meta

* Add missing pieces

* Cleanup

* Remove Index.svelte

* Move pricing to ds based config

* Remove Module.svelte

* Use React DS based moduleState management

* Restore tsconfig change

* Change interface for useModuleState callbacks

* Call useModuleState hook directly on the component

* Fix infinite loop on purchase success

* Fixup project version

* Fix selector in test

* Make speed score dependent on useModulesState for auto-refresh to work

* Fix isModuleEnabled check

* Update modules-state endpoint in tests

---------

Co-authored-by: Mark George <[email protected]>

* Boost: Migrate Tips to react (#34697)

* Update Tips to react

* add changelog

* Backport crm 6.3.2 Changes (#34708)

* Fix missing class fatal related to PR #34635 (#34705)

* CRM: start 6.3.3-alpha release cycle (#34710)

* Fix My plan dashboard js errors due to nested anchor tags  (#34707)

* Moved href from Button props to ExternalLink props to avoid duplicate anchor tags

* Added changelog

* Admin Page: avoid react warning with VideoPress card (#34713)

This should avoid us getting the following warning:

```
Warning: Failed prop type: Invalid prop `overrideContent` of type `boolean` supplied to `DashItem`, expected a single ReactElement.
DashItem@wp-content/plugins/jetpack/_inc/build/admin.js?ver=28b3a12169ab227bdcfa:36878:1
SettingsForm@wp-content/plugins/jetpack/_inc/build/admin.js?ver=28b3a12169ab227bdcfa:43524:3
ConnectFunction@wp-content/plugins/jetpack/_inc/build/admin.js?ver=28b3a12169ab227bdcfa:8870:68
ConnectFunction@wp-content/plugins/jetpack/_inc/build/admin.js?ver=28b3a12169ab227bdcfa:8870:68
DashVideoPress@wp-content/plugins/jetpack/_inc/build/admin.js?ver=28b3a12169ab227bdcfa:34467:1
```

* Fix missing class fatal related to PR #34635 (#34718)

* Subscriptions: update "verify your email" wall copy (#34716)

Co-authored-by: Jeremy Herve <[email protected]>

* Fix sharing buttons window open (#34703)

* Contact Form: add extra field settings to base field (#34704)

* Contact Form: add extra field settings to base field

* Fix package version

* Fix the media validation notice shown even when auto conversion is enabled. (#34730)

Co-authored-by: Gergely Juhasz <[email protected]>

* Add `wpcom_ai_site_prompt` option to the site settings endpoint (#34709)

* Social: Fix endpoint backwards compatibility (#34566)

* Readd REST controllers with updated logic

* Readd class-settings classes for initial state population

* changelog

* Use depreacted and next_version tags

* Fixup versions

* Boost: Update Settings Page to react (#34714)

* Update Settings Page to react

* add changelog

* Sharing: update Twitter and X buttons to support official X button (#34719)

* Sharing: update Twitter and X buttons to support official X button

See #34459

- The official Twitter button is no more; it has been updated to the X design. Let's update our preview Twitter button match.
- Since we now have an official X button, let's offer it with the X service.

* Adjust official button styles in wp-admin

* This method is not needed

* Update domain name

* Update source name

* Bump version by specifying Jetpack version when enqueuing

* Update logo

* Update icon with more radius

* Social | Hide conversion notice for Simple sites (#34733)

* Hide notice on simple sites

* changelog

* Make auto-conversion disabled if not available

* Fixup versions

* Sharing buttons block alternate settings screen (#34673)

* build: Use a GitHub webhook to trigger the betadownload site (#34604)

Once Automattic/jetpack-builder#36 is deployed, we can update our build
script to produce the artifact for forked PRs and set up a GitHub
webhook for the `workflow_run` event to support testing with PRs from
forked repositories.

This requires the GitHub "Fork pull request workflows from outside
collaborators" setting to be set to "Require approval for all outside
contributors" to avoid unreviewed code potentially producing malicious
zips for the betadownload server. We've had that set since March 2023
(p9dueE-6Rp-p2).

This also updates the Jetpack Live Branches script to remove the check
for a forked PR, since we can now test with them.

* Contact Form: minify stylesheets in prod (#34672)

* Contact Form: minify stylesheets in prod

* Update registered styles paths

* Fix package version

* Tools: Add the Readme to the release script (#34722)

* Make sure the readme.txt file gets updated after saving changelog edits

* Fix command being run

* comment out a check

* pass the correct flag

* Undo comments

* Update the next steps at the end

* Fix token subscription service name (#34723)

* Rename Token_Subscript_Service to Abstract_Token_Subscription_Service

* changelog

* Allow old class just in case

* `use` classes at the top to shorten up the class check.

* Content Lens: move feature to `beta` (#34740)

* move `content-lens` feature to beta

* changelog

* Newsletter prepublish panel: update toggle appearance (#34724)

* Contact Form: add accessible name to form (#34667)

* Contact Form: add accessible name to form

* Update accessible name on content change

* Remove unused code

* Fix package version

* Add warning notice

* Backport mu-wpcom-plugin 2.0.8, jetpack 13.0-a.7 Changes (#34742)

* Changelog and readme.txt edits.

* Init new cycle

* Fix the stable tag

* [Boost] Fix importmap deferral (#34746)

* Add importmap to the set of script types we exclude from deferral

* changelog

* Fix versions in packages/forms

* changelog

---------

Co-authored-by: Mark George <[email protected]>

* Update changelog (#34747)

* Admin page: remove alt attribute from decorative icon (#34715)

The Alt value isn't necessary here, since the icon doesn't bring any additional info on the page for folks using screen readers.

This has the added benefit of getting rid of a React warning:

```
Warning: Failed prop type: Invalid prop `alt` of type `object` supplied to `PlanIcon`, expected `string`.
PlanIcon@wp-content/plugins/jetpack/_inc/build/admin.js?ver=15a830895a6f6d1e3c39:44686:1
MyPlanCard@wp-content/plugins/jetpack/_inc/build/admin.js?ver=15a830895a6f6d1e3c39:51709:20
```

* Add/fix typo (#34712)

* Fix typo

* Chnagelog

---------

Co-authored-by: Fabien MILLERAND <[email protected]>

* Boost: Refactor navigation into react (#34731)

* Use react router

* Add redirects

* Fix typo

* Add dummy ISA page

* Add tracks

* Restore getting started functionality

* Move props to DS

* Move connection to DS and cleanup props

* Remove connection from JS constants

* Improve getting started handling

* Remove wrapping individual components with `DataSyncProvider`

* Only start ISA if ISA is active

* changelog

* Use hook and component provided by react-router-dom

* Remove data-sync provider wrapping from settings-page

* Remove jetpack connection prop from analytics

Analytics isn't collected while there is no connection. So, this prop is unnecessary anyway.

* Pop bubbles for performanceHistoryNeedsUpdate

* Fix priority support

* Cast wpcom blogId into integer

* Fix getting started with free

* Fix getting started for real

* Show index for missing routes

* Stats: add passing select UTM parameters (#34431)

This commit adds select UTM parameters to the pixel requests send to wp.com, so that we can show more statistics to site owners.

---------

Co-authored-by: Gergely Márk Juhász <[email protected]>
Co-authored-by: valterlorran <[email protected]>
Co-authored-by: Valter Lorran <[email protected]>
Co-authored-by: Andrii Lysenko <[email protected]>
Co-authored-by: Steve D <[email protected]>
Co-authored-by: Kev <[email protected]>
Co-authored-by: arthur791004 <[email protected]>
Co-authored-by: Mikael Korpela <[email protected]>
Co-authored-by: Juanma Rodriguez Escriche <[email protected]>
Co-authored-by: Tim Broddin <[email protected]>
Co-authored-by: Samiff <[email protected]>
Co-authored-by: Karen Attfield <[email protected]>
Co-authored-by: Calypso Bot <[email protected]>
Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Brad Jorsch <[email protected]>
Co-authored-by: Chris McCluskey <[email protected]>
Co-authored-by: tbradsha <[email protected]>
Co-authored-by: Christian Gastrell <[email protected]>
Co-authored-by: MILLER/F <[email protected]>
Co-authored-by: Miguel Lezama <[email protected]>
Co-authored-by: Adnan Haque <[email protected]>
Co-authored-by: Mark George <[email protected]>
Co-authored-by: Peter Petrov <[email protected]>
Co-authored-by: Jeremy Herve <[email protected]>
Co-authored-by: Manzoor Wani <[email protected]>
Co-authored-by: Gergely Juhasz <[email protected]>
Co-authored-by: Griffith Chen <[email protected]>
Co-authored-by: Brad Jorsch <[email protected]>
Co-authored-by: Christopher Smith <[email protected]>
Co-authored-by: Damián Suárez <[email protected]>
Co-authored-by: thingalon <[email protected]>
Co-authored-by: Fabien MILLERAND <[email protected]>
Co-authored-by: Piotr Stankowski <[email protected]>

* Revert "Catch up your branch (#2)" (#3)

This reverts commit 2434b7a.

* Try force conflict

* Try force conflict again

* Remove forced conflict

* Fix tests

* Fix tests

* Update composer.lock

* Resolve conflicts

* Specific class names

* Update projects/packages/stats/src/class-wpcom-stats.php

* Avoid caching error messages

* Revert caching change


Co-authored-by: Jasper Kang <[email protected]>
jeherve added a commit that referenced this pull request Feb 19, 2024
This is a follow-up to #34557. It was discussed a bit here:
https://github.com/Automattic/jetpack/pull/34557/files#r1475310509

I ran into the following issue in the post editor today:

```
PHP Fatal error:  Uncaught TypeError: array_merge(): Argument #2 must be of type array, WP_Error given in wp-content/plugins/jetpack/jetpack_vendor/automattic/jetpack-stats/src/class-wpcom-stats.php:453
Stack trace:
wp-content/plugins/jetpack/jetpack_vendor/automattic/jetpack-stats/src/class-wpcom-stats.php(453): array_merge()
wp-content/plugins/jetpack/jetpack_vendor/automattic/jetpack-stats/src/class-wpcom-stats.php(215): Automattic\Jetpack\Stats\WPCOM_Stats->fetch_post_stats()
```

This added security fixes the issue.
@jeherve
Copy link
Member

jeherve commented Feb 19, 2024

Related diff: D138696-code

@Aurorum
Copy link
Contributor Author

Aurorum commented Feb 19, 2024

Thanks!! Out of interest, does that handle the WPcom side? If so, can I remove the WPcom check?

@jeherve
Copy link
Member

jeherve commented Feb 19, 2024

does that handle the WPcom side? If so, can I remove the WPcom check?

We should indeed be able to remove that check now.

jeherve added a commit that referenced this pull request Feb 19, 2024
This is a follow-up to #34557. It was discussed a bit here:
https://github.com/Automattic/jetpack/pull/34557/files#r1475310509

I ran into the following issue in the post editor today:

```
PHP Fatal error:  Uncaught TypeError: array_merge(): Argument #2 must be of type array, WP_Error given in wp-content/plugins/jetpack/jetpack_vendor/automattic/jetpack-stats/src/class-wpcom-stats.php:453
Stack trace:
wp-content/plugins/jetpack/jetpack_vendor/automattic/jetpack-stats/src/class-wpcom-stats.php(453): array_merge()
wp-content/plugins/jetpack/jetpack_vendor/automattic/jetpack-stats/src/class-wpcom-stats.php(215): Automattic\Jetpack\Stats\WPCOM_Stats->fetch_post_stats()
```

This added security fixes the issue.
@kangzj
Copy link
Contributor

kangzj commented Feb 19, 2024

Thanks @jeherve 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Actions GitHub actions used to automate some of the work around releases and repository management Admin Page React-powered dashboard under the Jetpack menu [Block] AI Assistant [Block] Blog Stats [Block] Contact Form Form block (also see Contact Form label) [Block] Like [Block] Paid Content aka Premium Content [Block] Sharing Button [Block] Sharing Buttons [Block] Subscriptions [Boost Feature] Optimizations [Boost Feature] Setup Prompt [CRM] MailPoet Module [CRM] WooSync Module Docs E2E Tests [Feature] Carousel A fullscreen modal appearing when clicking on an image in a gallery or tiled gallery. [Feature] Contact Form [Feature] Extra Sidebar Widgets [Feature] Google Fonts [Feature] Memberships [Feature] Sharing Post sharing, sharing buttons [Feature] Subscriptions All subscription-related things such as paid and unpaid, user management, and newsletter settings. [Feature] WPCOM API [JS Package] AI Client [JS Package] Components [JS Package] Connection [JS Package] Licensing [JS Package] Partner Coupon [JS Package] Publicize Components [JS Package] Shared Extension Utils [JS Package] Storybook [mu wpcom Feature] Launchpad OSS Citizen This Pull Request was opened by an Open Source contributor. [Package] Ad aka WordAds [Package] Backup [Package] Forms [Package] Jetpack mu wpcom WordPress.com Features [Package] My Jetpack [Package] Publicize [Package] Search Contains core Search functionality for Jetpack and Search plugins [Package] Stats Data [Package] Sync [Package] VideoPress [Plugin] Backup A plugin that allows users to save every change and get back online quickly with one-click restores. [Plugin] Boost A feature to speed up the site and improve performance. [Plugin] CRM Issues about the Jetpack CRM plugin [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Migration [Plugin] mu wpcom jetpack-mu-wpcom plugin [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Plugin] Search A plugin to add an instant search modal to your site to help visitors find content faster. [Plugin] Social Issues about the Jetpack Social plugin [Plugin] Starter Plugin [Plugin] VideoPress A standalone plugin to add high-quality VideoPress videos to your site. RNA [Tests] Includes Tests [Tools] Development CLI The tools/cli to assist during JP development.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stats: add option to display views for each post on the frontend
5 participants