Subscribers: Use new helper library#101857
Conversation
Jetpack Cloud live (direct link)
Automattic for Agencies live (direct link)
|
|
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Sections (~284 bytes added 📈 [gzipped]) DetailsSections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~85 bytes added 📈 [gzipped]) DetailsReact components that are loaded lazily, when a certain part of UI is displayed for the first time. 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. Generated by performance advisor bot at iscalypsofastyet.com. |
|
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
3824c1c to
c20e8de
Compare
There was a problem hiding this comment.
Pull Request Overview
This pull request adds support for a new subscribers helper library behind a feature flag, updating type definitions, query parameters, cache key construction, and components that display subscriber data.
- Updated type definitions in index.ts to accommodate responses from both the new helper library and the old format.
- Updated queries and cache key generation to include the new helper flag.
- Modified subscriber data view components to conditionally use new helper library fields for subscription IDs and dates.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| client/my-sites/subscribers/types/index.ts | Updated Subscriber type definitions to include new helper fields. |
| client/my-sites/subscribers/queries/use-subscribers-query.tsx | Added the new helper flag to query parameters and cache key. |
| client/my-sites/subscribers/helpers/index.ts | Integrated the new helper flag into the cache key generation. |
| client/my-sites/subscribers/components/subscriber-data-views/subscriber-data-views.tsx | Updated subscription ID and date accessors to handle both formats. |
Comments suppressed due to low confidence (2)
client/my-sites/subscribers/components/subscriber-data-views/subscriber-data-views.tsx:60
- [nitpick] The helper flag is declared as 'useNewHelper' here using camelCase, but elsewhere it is referred to as 'use_new_helper' using snake_case. Consider unifying the naming convention for clarity and consistency.
const useNewHelper = config.isEnabled( 'subscribers-helper-library' );
client/my-sites/subscribers/components/subscriber-data-views/subscriber-data-views.tsx:64
- Using the logical OR operator may inadvertently default to 0 even if a valid subscription ID of 0 exists. Consider using the nullish coalescing operator (??) to properly check for null or undefined values.
return subscriber.wpcom_subscription_id || subscriber.email_subscription_id || 0;
There was a problem hiding this comment.
Pull Request Overview
This PR enables the use of a new subscribers helper library behind the "subscribers-helper-library" feature flag to improve performance. Key changes include:
- Adding new optional fields (email_subscription_id, wpcom_subscription_id, and corresponding dates) to support the new helper library.
- Updating queries, mutations, and cache key generation to include the new flag.
- Modifying subscriber details and data views components to use the new helper library fields when available.
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| client/my-sites/subscribers/types/index.ts | Added optional fields for new helper library support in subscription types. |
| client/my-sites/subscribers/queries/use-subscribers-query.tsx | Updated query parameters and cache keys to include the new flag. |
| client/my-sites/subscribers/mutations/use-subscriber-remove-mutation.ts | Adapted removal logic to use helper functions based on the flag. |
| client/my-sites/subscribers/helpers/index.ts | Modified cache key generation to include the use_new_helper flag. |
| client/my-sites/subscribers/components/subscriber-details/subscriber-details.tsx | Introduced a fallback check when converting the subscription date. |
| client/my-sites/subscribers/components/subscriber-data-views/subscriber-data-views.tsx | Implemented helper methods for consistent subscription ID and date handling across components. |
Files not reviewed (1)
- config/development.json: Language not supported
Comments suppressed due to low confidence (1)
client/my-sites/subscribers/queries/use-subscribers-query.tsx:19
- [nitpick] For consistency across the codebase, consider using camelCase (e.g., useNewHelper) for the flag instead of snake_case.
use_new_helper?: boolean;
client/my-sites/subscribers/components/subscriber-details/subscriber-details.tsx
Outdated
Show resolved
Hide resolved
| import wpcom from 'calypso/lib/wp'; | ||
| import { getSubscriberDetailsCacheKey, getSubscriberDetailsType } from '../helpers'; | ||
| import type { Subscriber } from '../types'; | ||
| import type { SubscriberDetails } from '../types'; |
There was a problem hiding this comment.
Type fix: the Subscriber type no longer always has subscriber_id because we're using different ids with the library. So I created a separate type for SubscriberDetails.
bab41e0 to
ed36013
Compare
spsiddarthan
left a comment
There was a problem hiding this comment.
LGTM and tests well
936f50c to
4811975
Compare
…01857) * Use new helper library. * Update id and date handling. * Add feature flag. * Fix type errors. * Turn on feature flag in dev env and fix id issues. * Remove no cache. * Fix the date_subscribed type error in a better way. * Assert that we have the date in the query. * Turn subscribers-helper-library flag on in Jetpack Cloud dev environment, as well.
…01857) * Use new helper library. * Update id and date handling. * Add feature flag. * Fix type errors. * Turn on feature flag in dev env and fix id issues. * Remove no cache. * Fix the date_subscribed type error in a better way. * Assert that we have the date in the query. * Turn subscribers-helper-library flag on in Jetpack Cloud dev environment, as well.
Related to https://github.com/Automattic/loop/issues/567
Proposed Changes
subscribers-helper-library, add a param to use the new subscribers library:use_new_helper.use_new_helperto the cache key.Why are these changes being made?
Testing Instructions
Pre-merge Checklist