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

Stats: prompt users to update the Jetpack plugin #99278

Merged
merged 5 commits into from
Feb 5, 2025

Conversation

myhro
Copy link
Contributor

@myhro myhro commented Feb 4, 2025

Closes Automattic/jetpack-roadmap#2219.

Proposed Changes

  • Prompt users to update the Jetpack plugin when they select Regions/Cities in the Locations card.

Why are these changes being made?

  • (p1HpG7-rpL-p2)

Testing Instructions

Note

This feature is meant for Odyssey/self-hosted users. Jurassic Ninja should work perfectly for this scenario, specially when used with the Jetpack Beta Tester plugin.

  • Navigate to Jetpack > Stats on your self-hosted site.
  • Add &flags=stats/locations to the URL.
  • Scroll down to the Locations section, the different scenarios below can be observed:

Outdated (14.1) or recent (14.2) Jetpack plugin, no commercial license

image

Outdated (14.1) Jetpack plugin, commercial license available

image

Recent (14.2) Jetpack plugin, commercial license available

image

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
    • For UI changes, have we tested the change in various languages (for example, ES, PT, FR, or DE)? The length of text and words vary significantly between languages.
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

@matticbot
Copy link
Contributor

matticbot commented Feb 4, 2025

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~189 bytes added 📈 [gzipped])

name   parsed_size           gzip_size
stats      +1023 B  (+0.1%)     +189 B  (+0.1%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@myhro myhro force-pushed the add/stats-jetpack-update-prompt branch from 4394682 to 7beeb03 Compare February 4, 2025 21:13
@matticbot
Copy link
Contributor

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • notifications
  • odyssey-stats
  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug add/stats-jetpack-update-prompt on your sandbox.

@myhro myhro force-pushed the add/stats-jetpack-update-prompt branch from 7beeb03 to bddde31 Compare February 4, 2025 22:06
Comment on lines 113 to 121
const {
data = [],
data: locationsViewsData = [],
isLoading: isRequestingData,
isError,
} = useLocationViewsQuery< StatsLocationViewsData >( siteId, geoMode, query, countryFilter, {
enabled: ! shouldGate,
enabled: ! shouldGate && supportsLocationsStatsFeature,
} );

const countriesViewsData = useSelector( ( state ) =>
getSiteStatsNormalizedData( state, siteId, statType, query )
) as [ id: number, label: string ];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried to check just one or the other, but there were complaints that hooks cannot be conditionally rendered. Shouldn't be an actual performance issue, given the StatsLocationViewsData has the enabled flag and getSiteStatsNormalizedData makes use of cache.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good to me. I assume the getSiteStatsNormalizedData selector retrieves stats from the Redux state, which are stored thanks to QuerySiteStats. Maybe it’s time to render that query component only when needed? Otherwise, we’ll be attempting to fetch the legacy country-views API even when we don’t need it.

Just to clarify, this isn’t an issue related to your PR. It could be addressed in another one if you prefer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm all in for further improving that. Would you mind opening an issue about it? I'm not sure I got 100% of the context to better describe what we need to do.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, I'll take a look and open the issue in the project board :)

@myhro myhro changed the title [WIP] Stats: prompt users to update the Jetpack plugin Stats: prompt users to update the Jetpack plugin Feb 4, 2025
@myhro myhro added [Feature] Stats Everything related to our analytics product at /stats/ [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Feb 4, 2025
@myhro myhro marked this pull request as ready for review February 4, 2025 22:25
@myhro myhro requested a review from Initsogar February 4, 2025 22:31
Comment on lines 113 to 121
const {
data = [],
data: locationsViewsData = [],
isLoading: isRequestingData,
isError,
} = useLocationViewsQuery< StatsLocationViewsData >( siteId, geoMode, query, countryFilter, {
enabled: ! shouldGate,
enabled: ! shouldGate && supportsLocationsStatsFeature,
} );

const countriesViewsData = useSelector( ( state ) =>
getSiteStatsNormalizedData( state, siteId, statType, query )
) as [ id: number, label: string ];
Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good to me. I assume the getSiteStatsNormalizedData selector retrieves stats from the Redux state, which are stored thanks to QuerySiteStats. Maybe it’s time to render that query component only when needed? Otherwise, we’ll be attempting to fetch the legacy country-views API even when we don’t need it.

Just to clarify, this isn’t an issue related to your PR. It could be addressed in another one if you prefer.

Copy link
Contributor Author

@myhro myhro 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 the review @Initsogar. I addressed your comments. Can you please take a look at it again?

Comment on lines 113 to 121
const {
data = [],
data: locationsViewsData = [],
isLoading: isRequestingData,
isError,
} = useLocationViewsQuery< StatsLocationViewsData >( siteId, geoMode, query, countryFilter, {
enabled: ! shouldGate,
enabled: ! shouldGate && supportsLocationsStatsFeature,
} );

const countriesViewsData = useSelector( ( state ) =>
getSiteStatsNormalizedData( state, siteId, statType, query )
) as [ id: number, label: string ];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm all in for further improving that. Would you mind opening an issue about it? I'm not sure I got 100% of the context to better describe what we need to do.

@myhro myhro requested a review from Initsogar February 5, 2025 15:40
@myhro myhro force-pushed the add/stats-jetpack-update-prompt branch from 41fb65b to c8af5e7 Compare February 5, 2025 17:11
Copy link
Contributor

@Initsogar Initsogar 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! ✅


I tried testing with a site with the following conditions:

  • Older Jetpack plugin
  • No commercial license

✅ Clicking on the regions or cities tab, shows me the upsell prompt
CleanShot 2025-02-05 at 13 17 29@2x

✅ After purchasing a commercial license, it shows me the Jetpack upgrade prompt
CleanShot 2025-02-05 at 13 20 07@2x

✅ It redirected me to the plugins admin page (/wp-admin/plugins.php) and after updating my Jetpack to the latest version, and looking Stats again, I can see the regions and cities tabs unlocked properly!
CleanShot 2025-02-05 at 13 23 28@2x


✅ In addition to the happy path, I made some tests to ensure the upsell prompt is working as usual when using the latest Jetpack version, and it works as expected.

@Initsogar
Copy link
Contributor

I'm all in for further improving that. Would you mind opening an issue about it? I'm not sure I got 100% of the context to better describe what we need to do.

It didn't let me reply in the same thread, so I'm adding an additional comment here:

I just created a follow-up task to address this issue: https://github.com/Automattic/jetpack-roadmap/issues/2287

@myhro
Copy link
Contributor Author

myhro commented Feb 5, 2025

Awesome. Thanks for the careful review and creating the follow-up issue, Rafa! Merging...

@myhro myhro merged commit aeccbd3 into trunk Feb 5, 2025
13 checks passed
@myhro myhro deleted the add/stats-jetpack-update-prompt branch February 5, 2025 23:13
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Stats Everything related to our analytics product at /stats/
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants