Skip to content

Updated statsX flag to trafficAnalyticsAlpha - #23029

Merged
9larsons merged 2 commits into
mainfrom
update-stats-alpha-flag
Apr 24, 2025
Merged

9larsons merged 2 commits into
mainfrom
update-stats-alpha-flag

Conversation

@9larsons

Copy link
Copy Markdown
Contributor

@coderabbitai

coderabbitai Bot commented Apr 24, 2025 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • ghost/core/test/e2e-api/admin/__snapshots__/config.test.js.snap is excluded by !**/*.snap

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes in this pull request focus on renaming a feature flag across multiple codebases. Specifically, the feature flag identifier for the "Stats redesign" or related analytics features has been changed from 'statsX' to 'trafficAnalyticsAlpha'. This update is consistently applied in several locations: the advanced labs settings UI, the conditional logic for displaying the "Web stats" link in the post analytics header, the feature flag tracking in the FeatureService class, the template logic for rendering the AdminX Posts component, and the list of recognized alpha features. No other logic, UI elements, or feature descriptions are altered, and there are no changes to exported or public API signatures except for the renaming of the feature property in the FeatureService class.

Possibly related PRs

Suggested labels

browser-tests


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@9larsons
9larsons enabled auto-merge (squash) April 24, 2025 13:48

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9f7c11b and 36e9271.

📒 Files selected for processing (5)
  • apps/admin-x-settings/src/components/settings/advanced/labs/AlphaFeatures.tsx (1 hunks)
  • ghost/admin/app/components/posts/analytics.hbs (1 hunks)
  • ghost/admin/app/services/feature.js (1 hunks)
  • ghost/admin/app/templates/posts-x.hbs (1 hunks)
  • ghost/core/core/shared/labs.js (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (14)
  • GitHub Check: Ghost-CLI tests
  • GitHub Check: Admin-X Settings tests
  • GitHub Check: Unit tests (Node 22.13.1)
  • GitHub Check: Database tests (Node 20.11.1, sqlite3)
  • GitHub Check: Unit tests (Node 20.11.1)
  • GitHub Check: Regression tests (Node 20.11.1, sqlite3)
  • GitHub Check: Database tests (Node 22.13.1, mysql8)
  • GitHub Check: Unit tests (Node 18.12.1)
  • GitHub Check: Regression tests (Node 20.11.1, mysql8)
  • GitHub Check: Database tests (Node 20.11.1, mysql8)
  • GitHub Check: Database tests (Node 18.12.1, mysql8)
  • GitHub Check: Lint
  • GitHub Check: i18n
  • GitHub Check: Admin tests - Chrome
🔇 Additional comments (4)
ghost/core/core/shared/labs.js (1)

51-51: Flag renamed consistently with PR objective.

The feature flag has been correctly renamed from 'statsX' to 'trafficAnalyticsAlpha' in the ALPHA_FEATURES array, which aligns with the PR objective to better distinguish between beta features and alpha features under development.

apps/admin-x-settings/src/components/settings/advanced/labs/AlphaFeatures.tsx (1)

41-41: Feature flag updated correctly in settings UI.

The feature flag name has been updated from 'statsX' to 'trafficAnalyticsAlpha' while maintaining the same feature title and description. This ensures the labs settings UI reflects the renamed flag consistently.

ghost/admin/app/templates/posts-x.hbs (1)

1-1: Feature flag condition updated appropriately.

The feature flag condition for rendering the AdminX::Posts component has been correctly updated to use 'trafficAnalyticsAlpha' instead of 'statsX'.

ghost/admin/app/components/posts/analytics.hbs (1)

38-38: Feature flag in conditional check properly renamed.

The feature flag has been correctly updated in the conditional check that controls the visibility of the "Web stats" link. This maintains the existing permission requirements (admin user and stats config enabled) while using the renamed flag.

@feature('contentVisibilityAlpha') contentVisibilityAlpha;
@feature('postsX') postsX;
@feature('statsX') statsX;
@feature('trafficAnalyticsAlpha') trafficAnalyticsAlpha;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Add new trafficAnalyticsAlpha feature flag
The introduction of @feature('trafficAnalyticsAlpha') trafficAnalyticsAlpha; properly aligns with the renaming of the old statsX flag. Please double-check that all statsX references (in code, tests, docs, etc.) have been purged and that any documentation or configuration schemas have been updated to reflect this change.

Suggested verification:


🏁 Script executed:

#!/bin/bash
# Ensure no residual 'statsX' references remain
rg -n "statsX" -C2 .

Length of output: 498


Update Remaining Snapshot Test Reference for statsX

The new @feature('trafficAnalyticsAlpha') trafficAnalyticsAlpha; addition looks good, but there’s still a leftover statsX entry in your e2e snapshot tests. Please update it to use the new flag (or remove it if no longer needed) so your tests reflect the change:

• File: ghost/core/test/e2e-api/admin/__snapshots__/config.test.js.snap
– Line 29: replace "statsX": true with the appropriate "trafficAnalyticsAlpha": true entry (and update the surrounding snapshot if needed).

After updating, run your tests to regenerate the snapshot and ensure there are no more statsX references anywhere.

@9larsons
9larsons merged commit eb9bd5a into main Apr 24, 2025
@9larsons
9larsons deleted the update-stats-alpha-flag branch April 24, 2025 14:03
cmraible added a commit that referenced this pull request Aug 20, 2026
no refs

## Evidence that the component is unused

`PostAnalyticsView` is not exported by the private Admin package, and
repository-wide searches for both its symbol and module path find no
importer. Admin-only Knip reported
`apps/admin/src/posts/analytics/components/post-analytics-view.tsx` as
an unused file before this removal and stopped reporting it afterward.
The Admin build uses explicit routes and entry points; no dynamic import
or glob references this path.

## History and intentionality

Documented facts:

-
ad52284
introduced the component as the loading/empty/content wrapper in the
first React post-analytics skeleton.
#22978 explains that the work
began a better breakdown of post statistics, initially focused on web
analytics for one post.
-
54d993b
replaced that static wrapper in the main page with real post and traffic
data. #22986 says this made the
previously static skeleton usable for beta users.
-
26de9ed
later reused the component only as the loading screen for a duplicated
`withFeatureFlag` wrapper. #23270
documents that the wrapper prevented the Newsletter tab from redirecting
before the alpha setting had loaded, and explicitly called the
duplication temporary.
- #23029 documents the rollout
model: `trafficAnalytics` selected beta users, while
`trafficAnalyticsAlpha` selected features still under development for
that beta.
-
f0a33b8
intentionally moved Newsletter analytics out of alpha. Its diff replaced
the protected route with the direct `Newsletter` route and made the
sidebar links unconditional;
#23294 states that purpose
directly. Production therefore stopped reaching the wrapper, and
consequently `PostAnalyticsView`, on May 12, 2025. Given the documented
flag semantics, this was an intentional promotion to the analytics beta
rather than an accidental bypass.
-
fb0790b
later restored the alpha flag for other design work but did not restore
Newsletter's route guard, corroborating that Newsletter's promotion was
deliberate.
-
566f8a9
removed the now-unreachable wrapper and its tests.
#29686 identifies those files as
duplicated dead code with no live importers. That deletion removed the
component's last source or test importer on July 30, 2026.

Inference: leaving `PostAnalyticsView` behind in that last cleanup was
an incomplete leaf cleanup. No historical source explicitly describes
the omission, but the dead-code PR's stated intent, the current
zero-reference result, and Knip's independent unused-file report support
that conclusion.

## Removal

Deleted the 33-line orphaned component. It had no dedicated tests,
export, dependency, configuration, or documentation to remove. Its
`EmptyStatView` and `PostAnalyticsContent` dependencies remain used by
live analytics screens.

## Verification

- `pnpm exec knip --workspace @tryghost/admin --include files --reporter
compact --no-progress` (the removed file is absent; four pre-existing
acceptance setup/config entries remain)
- `pnpm --dir apps/admin lint`
- `pnpm --dir apps/admin typecheck`
- `pnpm --dir apps/admin test:unit` (135 files, 1,604 tests)
- `pnpm nx run @tryghost/admin:build`
- `pnpm nx run-many -t test --exclude @tryghost/e2e --exclude
ghost-admin --exclude @tryghost/koenig-lexical` (35 projects, including
8,000 Ghost tests)

`pnpm check` completed repository-wide lint and documentation checks,
but its aggregate test phase could not run Koenig Lexical's browser
suite in this environment: Chromium was denied Mach port registration
and the configured Firefox executable is absent. The broader test run
above excludes only that environment-blocked package and passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant