---
id: 01-scaffold-core-analytics-package
epic: product-analytics-channel
title: Scaffold @repo/core-analytics package with IAnalytics and NoopAnalytics
type: technical-story
status: done
feature: core-analytics
depends-on: []
blocks:
  [
    02-recording-analytics,
    03-analyzed-brand-and-with-analytics-wrapper,
    06-analytics-protocol-bind-context,
    08-react-provider,
  ]
created: 2026-05-18T12:00:00Z
updated: 2026-05-18T11:33:06.880Z
---

## Goal

Produce a green `@repo/core-analytics` package — generator-scaffolded skeleton, then fleshed out with `IAnalytics` interface (`track`, `identify`, `pageView`, `flush`), `NoopAnalytics` default implementation, supporting types (`AnalyticsAttributeValue`, `AnalyticsUser`), and full method-level test coverage. The package is vendor-neutral: no third-party analytics SDK is bundled.

## Why

All downstream stories depend on `IAnalytics` existing as the contract surface. Landing this first means every subsequent story compiles and imports from a real package rather than a placeholder.

## Done when

- `packages/core-analytics/` exists as a workspace package `@repo/core-analytics`.
- `IAnalytics`, `AnalyticsAttributeValue`, `AnalyticsUser` are exported from the package root.
- `NoopAnalytics` implements `IAnalytics`; `flush()` resolves with a microtask (`Promise.resolve()`).
- Sibling tests cover all four interface methods on `NoopAnalytics`.
- `pnpm typecheck && pnpm lint && pnpm test && pnpm conformance && pnpm fallow:audit && pnpm coverage:diff` all pass.

## In scope

- `packages/core-analytics/` — package scaffold, `IAnalytics` interface, `AnalyticsAttributeValue` + `AnalyticsUser` types, `NoopAnalytics` impl, sibling tests, root barrel export.
- No subpath exports in this story (`./react` lands in Story 08).
- No `withAnalytics` wrapper in this story (Story 03).

## Out of scope

- `RecordingAnalytics` (Story 02).
- `Analyzed` brand / `withAnalytics` wrapper (Story 03).
- React provider (Story 08).
- Backend vendor integration — template ships Noop only.

## Tasks

- [x] Run `pnpm turbo gen core-package analytics` to scaffold `@repo/core-analytics` — verify the generator output compiles and all gates pass on this commit alone.
- [x] Replace generator placeholder content with `IAnalytics` interface (`track`, `identify`, `pageView`, `flush`), `AnalyticsAttributeValue` + `AnalyticsUser` types, and `NoopAnalytics` implementation (`flush()` returns `Promise.resolve()`); add sibling tests covering all four methods; export everything from the package root barrel — all gates pass on this commit.
