---
id: 02-recording-analytics
epic: product-analytics-channel
title: Add RecordingAnalytics to @repo/core-testing
type: technical-story
status: done
feature: core-testing
depends-on: [01-scaffold-core-analytics-package]
blocks: [08-react-provider]
created: 2026-05-18T12:01:00Z
updated: 2026-05-18T11:38:17.680Z
---

## Goal

Add `RecordingAnalytics` to `@repo/core-testing` as an in-memory test double that implements `IAnalytics`, parallel to `RecordingAuditLog`. Consumers use it in unit tests and the React provider test.

## Why

Every story that needs to assert analytics behaviour (including the React provider test in Story 08) requires a deterministic implementation. `RecordingAnalytics` provides the same recording double pattern already established by `RecordingAuditLog`.

## Done when

- `RecordingAnalytics` implements `IAnalytics` and records calls to `tracked`, `identified`, `pageViewed` arrays.
- `flush()` resolves with a microtask and clears or drains the in-memory buffer.
- Exported from `@repo/core-testing`'s barrel.
- Sibling test covers all four methods and the flush drain behaviour.
- All gates pass.

## In scope

- `packages/core-testing/src/recording-analytics.ts` + sibling test.
- Export line in `packages/core-testing/src/index.ts`.

## Out of scope

- React provider wiring (Story 08).
- Any vendor-specific recording behaviour.

## Tasks

- [x] Add `RecordingAnalytics` implementing `IAnalytics` to `@repo/core-testing` — recorded arrays for `track`, `identify`, `pageView`; `flush()` returns `Promise.resolve()`; sibling test covers all methods and flush; export added to barrel — all gates pass on this commit.
