---
id: 04-manifest-schema-and-wire-use-case
epic: product-analytics-channel
title: Extend manifest schema and wireUseCase with analyticsEvents
type: technical-story
status: done
feature: core-shared
depends-on: [03-analyzed-brand-and-with-analytics-wrapper]
blocks:
  [
    05-assert-feature-conformance-analyzed,
    07-eslint-rule-no-undeclared-analytics-event,
  ]
created: 2026-05-18T12:03:00Z
updated: 2026-05-18T15:15:39.064Z
---

## Goal

Add `analyticsEvents: string[]` (default `[]`) to the per-use-case manifest schema in `define-feature.ts`, update the feature generator template to emit the field, and extend `wireUseCase` to compose `withAnalytics` when an `analytics` arg is provided and the use case declares at least one analytics event.

## Why

The manifest field is the declaration surface the ESLint rule (Story 07) and boot assertion (Story 05) both read from. `wireUseCase` is the composition site that attaches the `Analyzed` brand; it must compose analytics in the right position (`factory → withAnalytics → withAudit → withCapture → withSpan`).

## Done when

- `useCases.<name>.analyticsEvents: string[]` is valid in every feature manifest; existing manifests stay green with an absent or empty field.
- The feature generator template emits `analyticsEvents: []` for each scaffolded use case.
- `wireUseCase({ ..., analytics? })` composes `withAnalytics` when `analytics` is provided; existing callers without `analytics` are unaffected.
- `wire-use-case.test.ts` covers the analytics path (brand present) and the no-analytics path (brand absent).
- All gates pass on each commit independently.

## In scope

- `packages/core-shared/src/conformance/define-feature.ts` — schema extension.
- Feature generator template (`turbo/generators/`) — `analyticsEvents: []` added to use-case scaffold output.
- `packages/core-shared/src/conformance/wire-use-case.ts` — `analytics?` arg + `withAnalytics` composition.
- `packages/core-shared/src/conformance/wire-use-case.test.ts` — analytics path coverage.

## Out of scope

- `assertFeatureConformance` extension (Story 05).
- ESLint rule (Story 07).
- Migrating existing feature manifests (out of scope per PRD).

## Tasks

- [x] Add `analyticsEvents: string[]` (default `[]`) to the use-case schema in `define-feature.ts` and update the feature generator template to emit the field — existing manifests remain valid; all gates pass on this commit.
- [x] Extend `wireUseCase` to accept optional `analytics` arg and compose `withAnalytics` (innermost, before `withAudit`) when provided + update `wire-use-case.test.ts` with analytics path (Analyzed brand present) and no-analytics path (Analyzed brand absent) — all gates pass on this commit.
