Skip to content

Add focused type-safe boundaries for analytics mock data #385

Description

@Lakes41

Difficulty

Intermediate

Type

type-safety, structure, consistency

Background

The reported parser failure occurs in the analytics-related section of lib/api/mock.ts, including the MOCK_ANALYTICS_SUMMARY.resourceAccess return path. Large inline mock structures are difficult to maintain when their data shape and access functions are not clearly separated.

Problem

Analytics mock data and the functions consuming it are tightly coupled inside the large mock module, increasing the chance that structural or shape changes will introduce failures that are only discovered when Next.js compiles the module.

Expected outcome

Give the analytics mock data an explicit, reusable TypeScript shape and separate its data definition from access logic.

Suggested implementation

Locate MOCK_ANALYTICS_SUMMARY and the functions that return its analytics fields. Define or reuse an appropriate TypeScript type based on the actual object shape. Move the analytics fixture and related access functions into a focused module if consistent with the repository's existing structure. Ensure resourceAccess and its sibling fields remain type-safe.

Acceptance criteria

  • MOCK_ANALYTICS_SUMMARY has an explicit type or is inferred from a clearly typed fixture.
  • resourceAccess is type-checked against the analytics summary shape.
  • Analytics access functions cannot silently return incompatible structures.
  • Existing consumers receive the same data shape.
  • The modified modules compile without TypeScript errors.

Likely affected files/directories

  • lib/api/mock.ts
  • lib/api/ analytics-related modules

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Third CampaignOfficial FWC26 campaign issue — eligible for campaign scoring and rewardsintermediateIntermediate difficulty tasks requiring solid experience and some contextstructureCode structural organization, architecture changes, and module boundary improvementstype-safetyTypeScript type system improvements and strict type enforcement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions