-
Notifications
You must be signed in to change notification settings - Fork 31
jingram/cpm-stats-on-ntp-animated: Animated Count for Protection Stats on New Tab Page #2062
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
Conversation
✅ Deploy Preview for content-scope-scripts ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Temporary Branch UpdateThe temporary branch has been updated with the latest changes. Below are the details:
Please use the above install command to update to the latest version. |
[Beta] Generated file diffTime updated: Wed, 26 Nov 2025 00:33:34 GMT Apple
File has changed Integration
File has changed Windows
File has changed |
@todo wire up real data
Balance of lint-fix fixes
Bug: Tracker Status UI: No Message for Zero Trackers.
The TrackerStatus function computes totalTrackersPillText for the
zero-trackers case but never displays it. When totalTrackersBlocked ===
0, the condition {totalTrackersBlocked > 0 && <TickPill .../>} prevents
rendering any tracker status message. The legacy TrackerStatusLegacy
displays "No trackers blocked" or "No trackers found" in this scenario,
but the new implementation shows nothing, breaking the expected UI
behavior for sites with no blocked trackers.
#2039 (comment)
Details: [integration] › pages/new-tab/app/protections/integrations-tests/protections.spec.js:61:5 › protections report › displays cookie popup blocking stats when enabled and counts > 0
Apply ?cpm=true&locale=ru to see why this matters
f8ef9b0 to
8f13df6
Compare
special-pages/pages/new-tab/app/protections/components/ProtectionsHeading.js
Show resolved
Hide resolved
shakyShane
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsoningram implementation looks solid 👍🏻
I'd possibly consider reducing the amount of tests, though.
Since all of the mocking is self-contained in the class (meaning the messing with globals doesn't impact other modules) I think it's ok to have these for now, but it's a lot of new code directly tied to the implementation - meaning any change to the feature carries a burden of changing the tests.
Let's scope a follow up with (or choose to do this now)
- Have a think if you can reduce this right down to a few tests that give you confidence on the algorithm
- Ensure end state is captured in screenshot tests
Asana Task/Github Issue: https://app.asana.com/1/137249556945/project/1211050482669423/task/1212009313322048?focus=true
Description
Implements an animated counter feature for the tracker and cookie pop-up counts displayed in the Protections section of the New Tab Page. Instead of the count instantly jumping to its final value, it now smoothly animates from a starting value to the target count, providing a more polished and engaging user experience.
animate.mov
Implementation Details
Animation Specification
The
animateCountfunction implements a specific animation behavior based on count thresholds:Initial Display Rules
onCompleteby 500ms)Incremental Updates
When the count increases (e.g., from 50 to 55), the animation:
Animation Characteristics
cubic-bezier(0.42, 0.0, 0.58, 1.0))requestAnimationFramefor smooth 60fps animationHook Features (
useAnimatedCount)The
useAnimatedCounthook provides:useCallbackto optimize performanceTesting
Visit the preview URL to see it in action.
The test suite (
animateCount.spec.js) covers:fromValueparameter, smooth transitionsTesting Utilities
The suite includes a custom
AnimationMockerclass that:requestAnimationFrameandcancelAnimationFrameperformance.now()for deterministic time controlsetTimeoutandclearTimeouttick()method to advance time programmaticallyrunToCompletion()helper for full animation cyclesChecklist
Please tick all that apply:
Note
Adds animated counts for trackers and cookie pop-ups in the Protections header using a new utility and hook, with style tweaks, mock updates, and comprehensive tests.
useAnimatedCountinprotections/components/ProtectionsHeading.js.totalCookiePopUpsBlocked; show CPM stats only when enabled and counts > 0.noRecentTitle).protections/utils/animateCount.jsimplementing 500ms cubic ease-in-out count animation with thresholds, caps, cancellation, and incremental updates.protections/utils/useAnimatedCount.jshook with visibility-aware animations and cleanup.PrivacyStats.module.cssheadings: updated.titlehierarchy, new.noRecentTitle, adjusted colors/sizing/spacing.protections.mock-transport.js(cpm=true->1222).protections/unit-tests/animateCount.spec.jscovering thresholds, easing, duration, cancellation, incremental updates, and caps.Written by Cursor Bugbot for commit 8f13df6. This will update automatically on new commits. Configure here.