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/value to active state videopress card #38812

Merged
merged 12 commits into from
Aug 15, 2024

Conversation

CodeyGuyDylan
Copy link
Contributor

@CodeyGuyDylan CodeyGuyDylan commented Aug 9, 2024

Proposed changes:

  • Add optional $days arg to function in VideoPress package that returns stats. This arg allows us to customize the days returned for featured stats without having to duplicate functionality in My Jetpack. It also doesn't break any current usages of the function as the argument is optional and defaults to the old value of 14 days
  • Add monthly views and watch-time to the active card state (if there is any)
  • Hide value section if the module is active but no views or watch time has been recorded

NOTE: This PR does not intend to handle adding trends, tooltip, or context switching between monthly and all-time views. Those will be handled in separate PRs

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

P2: p1HpG7-rb7-p2

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

No

Testing instructions:

  1. On a Jurassic Ninja site, enable sandbox access and checkout this branch on the main Jetpack plugin.
  2. Go to /wp-admin/options-general.php?page=companion_settings and enter your sandbox domain to enable sandboxed requests
  3. Connect your user account
  4. Add at least 1 video to your site
  5. Go to My Jetpack and confirm you still see the inactive state showing 1 video you could be using VideoPress for
    image
  6. Now activate the VideoPress plugin with this branch. You probably won't have any video data on your test site as far as views or watch time goes, so you should see an active card with no content
    image
  7. To mock some randomized data, go to fbhepr%2Skers%2Sjcpbz%2Schoyvp.ncv%2Serfg%2Sjcpbz%2Qwfba%2Qraqcbvagf%2Spynff.jcpbz%2Qwfba%2Qncv%2Qfgngf%2Qivqrb%2Qcynlf%2Qi1%2Q1%2Qraqcbvag.cuc%3Se%3Q210o65nn%26zb%3Q1199%26sv%3Q37%2350-og and replace all those zeros with something like rand(0, 100). You can pick whatever numbers you'd like if you wanted to test out smaller or bigger numbers.
  8. Now refresh My Jetpack and you should see some data
    image

Play around with the random numbers to make sure they scale well with the compacting number/time formatting.
Additionally make sure they match designs here: p1HpG7-rb7-p2

Note: There are some pending questions as far as the design goes (p1HpG7-rb7-p2#comment-73251), so the CSS is pending, but the functionality should remain the same so I think it is ready to review

Copy link
Contributor

github-actions bot commented Aug 9, 2024

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WordPress.com Simple site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin, and enable the add/value-to-active-state-videopress-card branch.

  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack add/value-to-active-state-videopress-card
    

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

Copy link
Contributor

github-actions bot commented Aug 9, 2024

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


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.


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Choose a review path based on your changes:
    A. Team Review: add the "[Status] Needs Team Review" label
    • For most changes, including minor cross-team impacts.
    • Example: Updating a team-specific component or a small change to a shared library.
      B. Crew Review: add the "[Status] Needs Review" label
    • For significant changes to core functionality.
    • Example: Major updates to a shared library or complex features.
      C. Both: Start with Team, then request Crew
    • For complex changes or when you need extra confidence.
    • Example: Refactor affecting multiple systems.
  3. Get at least one approval before merging.

Still unsure? Reach out in #jetpack-developers for guidance!

@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Aug 9, 2024
import ShieldOff from './assets/shield-off.svg';
import ShieldPartial from './assets/shield-partial.svg';
import ShieldSuccess from './assets/shield-success.svg';
import { InfoTooltip } from './info-tooltip';
import { useProtectTooltipCopy } from './use-protect-tooltip-copy';
import type { ReactElement, PropsWithChildren } from 'react';
import type { PropsWithChildren, ReactElement } from 'react';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was an accident but doesn't make a difference 😅

@CodeyGuyDylan CodeyGuyDylan force-pushed the add/value-to-active-state-videopress-card branch from 536655e to b29bb5b Compare August 12, 2024 14:33
Copy link
Contributor

@jboland88 jboland88 left a comment

Choose a reason for hiding this comment

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

Overall this tested well and is looking good, I had a few small comments and ran into some things that differed from the test instructions.

When setting up the test, after adding a video, I did not get the option to "Activate" VideoPress - I had "learn more". Not a blocker, but just noting that was different

Screenshot 2024-08-13 at 2 29 39 PM

After activating VideoPress through Jetpack settings, I did see the empty stats with 0s.

Screenshot 2024-08-13 at 2 30 42 PM

font-weight: 500;
margin-bottom: calc(var(--spacing-base) + 2px);
line-height: var(--font-title-small);
text-align: center;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure the text-align is needed since the items are aligned with flex-start?

@@ -315,9 +315,16 @@ public static function get_videopress_stats() {
}

$videopress_stats = new VideoPress_Stats();
$featured_stats = $videopress_stats->get_featured_stats( 60 );
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering if we should add a transient cache for this call so we aren't calling it on each page load?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah we could do that 🤔 I'll set it to 1 hour? Or would that be too long?

@CodeyGuyDylan
Copy link
Contributor Author

When setting up the test, after adding a video, I did not get the option to "Activate" VideoPress - I had "learn more". Not a blocker, but just noting that was different

I assume this is because you don't meet the criteria for the product to be owned 🤔 If you didn't have the standalone plugin or a plan, and this showed up in the "Discover" section, based on the criteria we set before then I don't believe we should see an "Activate" 🤔 Let me know if my assumptions were wrong or if you think this should be fixed. It's also possible that a value on the backend of the videopress class needs to be updated

@CodeyGuyDylan CodeyGuyDylan force-pushed the add/value-to-active-state-videopress-card branch from b848419 to e97e266 Compare August 14, 2024 18:47
@@ -29,6 +29,10 @@ const VideoPressValueSection: FC< VideoPressValueSectionProps > = ( { isPluginAc
const currentViews = featuredStats?.data?.views?.current;
const currentWatchTime = featuredStats?.data?.watch_time?.current;

if ( currentViews === undefined || currentWatchTime === undefined ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to handle the case where there was an error on the API call. 0's should be accepted if the site has videos

jboland88
jboland88 previously approved these changes Aug 15, 2024
Copy link
Contributor

@jboland88 jboland88 left a comment

Choose a reason for hiding this comment

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

One small nitpick, this LGTM


const MISSING_CONNECTION_NOTIFICATION_KEY = 'missing-connection';
const MISSING_CONNECTION_NOTIFICATION_KEY = 'missing-connection';
const VIDEOPRESS_STATS_KEY = 'videopress-stats';
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick - might be a good idea to add my-jetpack- to the front of this transient key just in case the videopress plugin decides to use a similar transient name at some point in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, I'll add that

@CodeyGuyDylan CodeyGuyDylan force-pushed the add/value-to-active-state-videopress-card branch from 510c733 to 0bd3885 Compare August 15, 2024 15:36
Copy link
Contributor

@jboland88 jboland88 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 updating the transient name!

@CodeyGuyDylan CodeyGuyDylan merged commit 7015560 into trunk Aug 15, 2024
70 of 71 checks passed
@CodeyGuyDylan CodeyGuyDylan deleted the add/value-to-active-state-videopress-card branch August 15, 2024 16:33
@github-actions github-actions bot removed the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Aug 15, 2024
pkuliga pushed a commit that referenced this pull request Aug 23, 2024
* Add value to active state of VideoPress card

* changelog

* Return videoCount if error on featured stats call

* Update time format to accomodate years

* Update definition of videopress active

* Show stats if user has videos

* Simplify logic of videopress value section

* Left align protect headings per design

* Update monthly views heading to 30-day views

* Add transient

* Specify transient key to my jetpack

* Fixup project versions
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