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: Show upgrade notices for commercial sites with PWYW plans #92040

Merged
merged 8 commits into from
Jun 25, 2024

Conversation

a8ck3n
Copy link
Contributor

@a8ck3n a8ck3n commented Jun 22, 2024

Related to #81361.

Proposed Changes

Show the commercial upgrade notice on any site flagged as isCommercial that has a PWYW plan. Previously we didn't show the notice to these sites.

SCR-20240614-rcmz

Why are these changes being made?

The PWYW plans are meant for non-commercial sites. It's possible to purchase one if the site has not been classified or if the site's classification changes over time. We want to make sure we surface notices to upgrade to the correct license if we find a mismatch of classification & license type.

Testing Instructions

  • Add a PWYW plan to your test site.
  • Force the site to commercial status using the "jetpack-site-is-commercial-override" override on the Blog RC tool.
  • Visit the Stats page and confirm the notice is visible.

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 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)?

@a8ck3n a8ck3n self-assigned this Jun 22, 2024
@matticbot
Copy link
Contributor

matticbot commented Jun 22, 2024

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 update/stats-notices-for-commercial-pwyw on your sandbox.

@matticbot
Copy link
Contributor

matticbot commented Jun 22, 2024

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

Sections (~113 bytes added 📈 [gzipped])

name   parsed_size           gzip_size
stats       +310 B  (+0.0%)     +113 B  (+0.0%)

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.

@a8ck3n a8ck3n marked this pull request as ready for review June 22, 2024 09:16
@a8ck3n a8ck3n requested a review from a team June 22, 2024 09:16
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jun 22, 2024
@kangzj kangzj added the Stats Everything related to our analytics product at /stats/ label Jun 24, 2024
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.

It works well for self hosted, Atomic and simple sites. Minor suggestions inlined, no blockers.

Comment on lines +123 to +127
if ( showUpgradeNoticeOnOdyssey || showUpgradeNoticeForJetpackNotAtomic ) {
if ( isCommercial && hasPWYWPlanOnly ) {
return true;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand this might be written intentionally in two conditions but for the sake of simplicity, could we merge them to one?

@@ -130,4 +103,39 @@ const ALL_STATS_NOTICES: StatsNoticeType[] = [
},
];

function shouldShowCommercialSiteUpgradeNotice( {
Copy link
Contributor

@kangzj kangzj Jun 25, 2024

Choose a reason for hiding this comment

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

Can we please not change the pattern here just to be consistent?

Not related to the PR: I'm thinking maybe we could put those notices back to their own files, where the notice component are defined. It'll be better to satisfy the open/close principal. Thought?

// Get listing of all plans that support stats in some way and qualify as "paid" plans.
const plansSupportingStats = sitePurchases?.filter(
( product ) =>
productHasStats( camelOrSnakeSlug( product ), true ) && product.expiryStatus !== 'expired'
Copy link
Contributor

Choose a reason for hiding this comment

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

Side note: We currently only have two features for Stats, stats-paid and stats-free, and we probably want to introduce another one stats-commercial which includes support for all advanced features and commercial use.

@a8ck3n a8ck3n force-pushed the update/stats-notices-for-commercial-pwyw branch from 3b18f9b to b4e4aa9 Compare June 25, 2024 07:07
@a8ck3n a8ck3n merged commit f5d2c80 into trunk Jun 25, 2024
11 checks passed
@a8ck3n a8ck3n deleted the update/stats-notices-for-commercial-pwyw branch June 25, 2024 07:22
@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 Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stats Everything related to our analytics product at /stats/
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants