Skip to content

Build the Analytics module scaffold behind the existing feature flag #333

Description

@Lakes41

Difficulty: Advanced
Type: feature

Background
The README already defines a NEXT_PUBLIC_FEATURE_ANALYTICS flag (defaulting to false in every environment, since the module is "not yet built"), and documents the exact process for adding new feature-gated modules via lib/features.ts and <FeatureGate>.

Problem
The Analytics module has a reserved flag and nav slot but no implementation, meaning there's no way to see engagement/membership trends for a community, and no established data-source abstraction for what will eventually need to consume analytics data (from guildpass-core or elsewhere).

Expected outcome
A working Analytics module (behind the existing flag, off by default in prod) renders at least: membership growth over time, role distribution, and gated-resource access attempts (allowed vs. denied), using a pluggable data-source interface so it can start on mock data and later swap to a real analytics backend.

Suggested implementation

  • Add the /analytics route wrapped in <FeatureGate enabled={features.analytics} name="Analytics">, following the documented pattern for adding new flagged modules exactly.
  • Define an AnalyticsDataSource interface (getMembershipTrend(), getRoleDistribution(), getAccessAttempts()) with a mock implementation seeded from existing mock data patterns in lib/api/mock.ts.
  • Build the three chart/summary views using a lightweight charting approach consistent with the project's minimal shadcn-style UI primitives.
  • Update .env.example to note the flag's purpose and default, consistent with existing flag documentation style.

Acceptance criteria

  • Module is fully gated behind NEXT_PUBLIC_FEATURE_ANALYTICS, hidden from nav and showing "Feature unavailable" when disabled and visited directly
  • All three views render correctly against mock data
  • Data-source interface is swappable without touching the view components
  • Follows the README's documented "Adding a new flag" steps exactly

Likely affected files/directories

  • app/analytics/ (new)
  • lib/features.ts
  • lib/api/mock.ts
  • .env.example

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox Open Source Sponsorship program tagMaybe RewardedIssue may qualify for a reward upon successful completion per campaign rulesOfficial Campaign | FWC26Official FWC26 campaign issue — eligible for campaign scoring and rewardsadvancedAdvanced difficulty tasks requiring significant domain knowledge and implementation effortfeatureNew feature, enhancement, or functional addition

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions