Skip to content

Implement the newness model & derived selectors #13246

Closed

Description

@techanvil

Feature Description

The hub's "What's new?" tab, and the new-feature indicators that point at it, need a definition of what counts as "new" to a given user.

The product intent is that a regularly active, up-to-date user sees the features launched in the current or previous Site Kit release — Site Kit ships roughly every two weeks, so about a four-week window — while a user who wasn't active when a feature launched still gets to see it, and a brand new user isn't greeted by years of history flagged as new.

Three per-user rules deliver that: a floor relative to the version the user installed, a hold until the user is first shown a feature, and a 28-day lapse thereafter. All of the state behind them reuses Site Kit's existing dismissed-items and expirable-items APIs, so nothing new is stored server-side, and membership of "What's new?" and the new-feature count are derived rather than persisted.

This issue implements those rules, the selectors that derive from them, and the action that marks features as seen. The surfaces that consume them — the tab itself (#13321), the dashboard header pill (#13358) and the wp-admin menu badge (#13359) — are handled by their own issues.

For reference, see the Newness & per-user state section in the design doc.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • Whether a feature is new is evaluated per user, by three rules:
    • Floor — a feature can only ever count as new if the version it was added in is at or after the release immediately preceding the Site Kit version at the user's first authentication. Anything older is part of that user's baseline and is never new to them, however recently they arrived.
    • Hold — an eligible feature is not on a clock until the user is first shown it: its 28-day timer is seeded the first time the feature appears in that user's "What's new?" list. A feature released while the user was away therefore still counts as new, and unread, on their next visit — regardless of how long ago it was released.
    • Lapse — 28 days after its timer is seeded, a feature stops counting as new.
  • The following selectors are added:
    • isFeatureNew( slug ) — whether the feature passes the floor and its 28-day timer has not expired. A feature whose timer has never been seeded is new.
    • isFeatureUnread( slug ) — whether the feature is new and its timer has never been seeded.
    • getWhatsNewFeatures() — the features to list on "What's new?": new, not dismissed, not already set up, and with their prerequisite modules connected. Ordered with unread features before read ones; within each of those, by the version the feature was added in, newest first; and features sharing a version keeping their catalog registration order.
    • getNewFeatureCount() — the single count behind every new-feature indicator: how many getWhatsNewFeatures() entries are still unread.
  • A markFeaturesSeen( slugs ) action seeds the 28-day timer for each of the given features, in a single request.
  • Seeding a feature's timer both marks it read and starts its lapse. There is no separate read state, so a feature is unread until it has first been listed, read but still listed while its timer is active, and lapsed once the timer expires.
  • A feature whose prerequisite modules are not all connected is not listed by getWhatsNewFeatures() and is not counted by getNewFeatureCount(). It is held in the same way as a feature the user hasn't visited yet: its timer cannot be seeded, so it is still new once its prerequisites are connected.
  • Dismissing a feature removes it from getWhatsNewFeatures() permanently, and setting a feature up removes it from getWhatsNewFeatures() too. A lapsed, dismissed or set-up feature is still a registered catalog entry — only its newness is affected.
  • All per-user state reuses the existing dismissed-items and expirable-items APIs: the permanent dismissal key feature-discovery-dismissed-{slug} and the 28-day timer feature-discovery-new-{slug}. No new REST endpoints, options, or user settings are added.

Implementation Brief

  • Add assets/js/googlesitekit/datastore/feature-discovery/utils.ts:

    • Key builders for the dismissal key feature-discovery-dismissed-{slug} and the timer key feature-discovery-new-{slug}.
  • In assets/js/googlesitekit/datastore/feature-discovery/newness.ts (new file, combined into the store in index.ts):

    • Add markFeaturesSeen( slugs ), which seeds the timers in a single CORE_USER.setExpirableItemTimers() call, passing one { slug, expiresInSeconds } entry per feature, where slug is the feature's timer key rather than the feature slug and expiresInSeconds is WEEK_IN_SECONDS * 4 from @/js/util.
    • Add isFeatureNew( slug ): the feature passes the floor and its timer has not lapsed. For the timer half, follow WidgetNewBadge: hasExpirableItem( key ) === false || isExpirableItemActive( key ), so a feature with no timer yet counts as new.
    • For the floor, compare the feature's addedInVersion against the release preceding CORE_USER.getInitialSiteKitVersion(), using compareVersions as datastore/user/feature-tours.js does. Derive the preceding release by decrementing the minor, e.g. 1.160.0 gives a floor of 1.159.0. Return false when there is no initial version, as feature tours do.
    • Add isFeatureUnread( slug ): isFeatureNew( slug ) and hasExpirableItem( key ) === false.
    • Add getWhatsNewFeatures(): start from getAvailableFeatures() (Add the core/feature-discovery datastore — registration & core selectors #13245), which already covers set-up, prerequisite and checkRequirements state, then keep the entries that are isFeatureNew and not isItemDismissed( dismissal key ). Sort unread entries before read ones, then by addedInVersion descending, comparing with compareVersions rather than as strings so that e.g. 1.100.0 sorts above 1.99.0; getAvailableFeatures() is in registration order and sort is stable, so features sharing a version keep it.
    • Add getNewFeatureCount(): how many getWhatsNewFeatures() entries are isFeatureUnread.
    • Return undefined from these selectors while getExpirableItems(), getDismissedItems() or the initial version are unresolved, so consumers can tell loading from empty.

Test Coverage

  • Add newness.test.ts covering the three rules: a feature added before the preceding release is never new, one at or after it is; a feature with no timer is new and unread; a feature with an expired timer is neither.
  • Cover getWhatsNewFeatures() membership, including features that are dismissed, already set up, or have unconnected prerequisites, and its ordering across unread state, version and registration order.
  • Cover getNewFeatureCount() counting only unread entries, and markFeaturesSeen() seeding several slugs in one request and leaving those features listed but read.

QA Brief

  • In assets/js/googlesitekit-datastore-site.ts, register the feature discovery store using:
import { registerStore } from './googlesitekit/datastore/site';

registerFeatureDiscoveryStore( Data );
  • Set up Site Kit and open any Site Kit admin page. In the browser console, confirm the store is available:

    const { dispatch, select } = googlesitekit.data;
    const FD = "core/feature-discovery";
    !!select(FD); // true
  • Register test features and provide a known initial version and user state. old is below the 1.159.0 floor; the other features are eligible:

    const base = {
      title: "Test feature",
      shortDescription: "Test description.",
      effort: 1,
      goalCategories: ["audience"],
      setup: { type: "background-toggle", isEnabled: () => false },
    };
    
    dispatch("core/user").receiveInitialSiteKitVersion("1.160.0");
    dispatch("core/user").receiveGetDismissedItems([]);
    dispatch("core/user").receiveGetExpirableItems({});
    dispatch(FD).registerFeature("old", { ...base, addedInVersion: "1.158.0" });
    dispatch(FD).registerFeature("unread", {
      ...base,
      addedInVersion: "1.159.0",
    });
    dispatch(FD).registerFeature("newer", { ...base, addedInVersion: "1.161.0" });
  • Confirm the floor, hold, and unread rules. old is never new; both eligible features are new and unread because neither has a timer:

    select(FD).isFeatureNew("old"); // false
    select(FD).isFeatureNew("unread"); // true
    select(FD).isFeatureUnread("unread"); // true
    select(FD)
      .getWhatsNewFeatures()
      .map(({ slug }) => slug); // [ 'newer', 'unread' ]
    select(FD).getNewFeatureCount(); // 2
  • Run await dispatch( FD ).markFeaturesSeen( [ 'unread', 'newer' ] ) and confirm the browser Network panel shows one set-expirable-item-timers request containing both feature-discovery-new-* keys with a 28-day expiration. In the same page session, confirm both features remain in getWhatsNewFeatures() but isFeatureUnread() and getNewFeatureCount() report false and 0 respectively.

  • In the console, expire one feature and confirm it lapses:

    dispatch("core/user").receiveGetExpirableItems({
      "feature-discovery-new-unread": Math.floor(Date.now() / 1000) - 1,
      "feature-discovery-new-newer": Math.floor(Date.now() / 1000) + 60,
    });
    select(FD).isFeatureNew("unread"); // false
    select(FD)
      .getWhatsNewFeatures()
      .map(({ slug }) => slug); // [ 'newer' ]
  • Confirm dismissing, setup, and unmet prerequisites remove catalog entries from the list and unread count while keeping them registered. Register features using prerequisiteModules: [ 'analytics-4' ] while Analytics is disconnected, and isEnabled: () => true for an already set-up feature; add feature-discovery-dismissed-{slug} to receiveGetDismissedItems(). Verify none appear in getWhatsNewFeatures(), but each remains returned by getFeature( slug ).

Changelog entry

  • Add the feature discovery newness model and selectors for determining which features are new to a user.

Activity

  1. self-assigned this
    on Aug 3, 2026
  2. added
    P0
    Type: Enhancement
    Team M
    on Aug 3, 2026
  3. removed their assignment
    on Aug 3, 2026
  4. self-assigned this
    on Aug 4, 2026
  5. techanvil commented on Aug 10, 2026

    @techanvil
    CollaboratorAuthor

    Hey @hussain-t, just a heads up that I've tweaked the definition for getNewFeatureCount() in the AC, in response to review feedback in the design doc.

  6. added
    Next Up
    on Aug 18, 2026
  7. removed their assignment
    on Aug 20, 2026
  8. self-assigned this
    on Aug 20, 2026
  9. techanvil commented on Aug 21, 2026

    @techanvil
    CollaboratorAuthor

    Thanks @hussain-t, this IB is looking good.

    A small point - key builders for the dismissal and timer keys should go in a utils.ts file rather than constants.ts.

  10. hussain-t commented on Aug 21, 2026

    @hussain-t
    Collaborator

    Thanks, @techanvil! I've updated the IB.

  11. 2 remaining items

  12. techanvil commented on Aug 24, 2026

    @techanvil
    CollaboratorAuthor

    Thanks @hussain-t! That LGTM.

    IB ✅

  13. removed their assignment
    on Aug 24, 2026
  14. self-assigned this
    on Aug 31, 2026
  15. removed
    Next Up
    on Sep 1, 2026
  16. removed their assignment
    on Sep 7, 2026
  17. self-assigned this
    on Sep 9, 2026
  18. kelvinballoo commented on Sep 9, 2026

    @kelvinballoo
    Collaborator

    QA Update ⚠️

    Hi @ankitrox , this is mostly tested good.
    Used the scripts provided but I just wanted to report that I did have an additional 'new' features returned: email-reports.
    I believe this is likely due to the actual release we had recently and there is nothing to be fixed here.

    Can you confirm please before I move this to approval?

    Details Image

    Other than that, tested this and results are as expected.

    • The branch is returned true.

      Details Image
    • The new features are returned as expected but with one additional one: email-reports which is likely due to the actual release we had recently.

      Details Image
    • markFeaturesSeen tested good.

      Details
      13246.-.03.markfeaturesseen-.expirable.ok.mov
    • Expired one feature and confirmed it lapsed

      Details Image
    • Confirm dismissing, setup, and unmet prerequisites remove catalog entries from the list. Note that I reloaded the screen for this and that's why some old entries are still there.

      Details Image
  19. ankitrox commented on Sep 11, 2026

    @ankitrox
    Collaborator

    @kelvinballoo You are right about what you discovered about the email reports and we are good to go there. If that's the only case and other things are looking good, we can move this to approval. 👍🏼

  20. removed their assignment
    on Sep 11, 2026
  21. kelvinballoo commented on Sep 11, 2026

    @kelvinballoo
    Collaborator

    QA Update ✅

    Thanks for confirming @ankitrox
    Other parts were verified good. Moving to approval.

    • The branch is returned true.

      Details Image
    • The new features are returned as expected but with one additional one: email-reports which is likely due to the actual release we had recently.

      Details Image
    • markFeaturesSeen tested good.

      Details
      13246.-.03.markfeaturesseen-.expirable.ok.mov
    • Expired one feature and confirmed it lapsed

      Details Image
    • Confirm dismissing, setup, and unmet prerequisites remove catalog entries from the list. Note that I reloaded the screen for this and that's why some old entries are still there.

      Details Image
  22. removed their assignment
    on Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0Team MType: Enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions