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

Add statTypeToPlan to map stat types to plan in stats upsells #97159

Merged
merged 2 commits into from
Dec 6, 2024

Conversation

lsl
Copy link
Contributor

@lsl lsl commented Dec 6, 2024

Related to #

Proposed Changes

  • When stats/paid-wpcom-v3 is enabled we want to upsell to the premium or personal plan depending on the stat. These stats will be split between STATS_PAID and STATS_COMMERCIAL site features with Add new paid stats site features: STATS_FREE, STATS_COMMERCIAL #97041.
  • This PR makes it so the upsell chooses the right plan based on the stat type in question.

Testing Instructions

Personal site looking at search terms (commercial feature) should see premium upsell with and without the flag:

Free site looking at search terms should see premium upsell with and without the flag:

Free site looking at clicks should se personal upsell with the flag, premium upsell without the flag:

Unit tests:

yarn run test-client client/my-sites/stats/test/stat-type-to-plan.ts

Main change adds the premium link when looking at a premium feature

Screenshot 2024-12-06 at 16-12-22 Site Title — WordPress com

But upsells to personal when looking at a personal feature

Screenshot 2024-12-06 at 16-10-24 Site Title — WordPress com

@lsl lsl self-assigned this Dec 6, 2024
@lsl lsl added the [Feature] Stats Everything related to our analytics product at /stats/ label Dec 6, 2024
@matticbot
Copy link
Contributor

matticbot commented Dec 6, 2024

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

Sections (~98 bytes added 📈 [gzipped])

name   parsed_size           gzip_size
stats       +166 B  (+0.0%)      +98 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.

@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 update/stats-personal-premium on your sandbox.

// Clicks is a paid stats feature that requires the personal plan
expect( statTypeToPlan( STAT_TYPE_CLICKS ) ).toEqual( PLAN_PERSONAL );
// 7 Days is a free plan feature, this should not be gated but test we default to personal when the stat type doesn't make sense to query
expect( statTypeToPlan( STATS_FEATURE_DATE_CONTROL_LAST_7_DAYS ) ).toEqual( PLAN_PERSONAL );
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏽

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.

LGTM!

Tests

# Plan Site Scenario v3 flag Expected result Test result
1 Free initsogarfree.* Premium feature (e.g., search terms) Yes Should see premium upsell
2 Free initsogarfree.* Premium feature (e.g., search terms) No Should see premium upsell
3 Free initsogarfree.* Personal feature (e.g., clicks) Yes Should see personal upsell
4 Free initsogarfree.* Personal feature (e.g., clicks) No Should see premium upsell
5 Personal initsogarpersonal.* Premium feature (e.g., search terms) Yes Should see premium upsell
6 Personal initsogarpersonal.* Premium feature (e.g., search terms) No Should see premium upsell
  • v3 flag enabled: passing ?flags=stats/paid-wpcom-v3 to the request.
  • v3 flag disabled: passing ?flags=-stats/paid-wpcom-v3 to the request. Mimics the current production behavior.

Unit test

yarn run test-client client/my-sites/stats/test/stat-type-to-plan.ts
 PASS  client/my-sites/stats/test/stat-type-to-plan.ts

Test Suites: 1 passed, 1 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        3.448 s
Ran all test suites matching /client\/my-sites\/stats\/test\/stat-type-to-plan.ts/i.

@Initsogar Initsogar merged commit 3d01d4e into trunk Dec 6, 2024
11 checks passed
@Initsogar Initsogar deleted the update/stats-personal-premium branch December 6, 2024 18:10
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.

3 participants