feat(core-analytics): add React provider and useAnalytics hook

Adds a ./react subpath export to @repo/core-analytics containing
<AnalyticsProvider value={IAnalytics}> and useAnalytics(): IAnalytics.
useAnalytics() throws AnalyticsContextError when called outside a provider.
React Testing Library test verifies track() flows through context using
RecordingAnalytics. Switches vitest config to pick up .tsx test files
via environmentMatchGlobs and extends tsconfig to react-library.json
for JSX support.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-18 15:54:30 +00:00
parent 065ca1b6aa
commit a7e0bf290d
8 changed files with 138 additions and 26 deletions

View File

@@ -1,5 +1,5 @@
{
"extends": "@repo/core-typescript/base.json",
"extends": "@repo/core-typescript/react-library.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": ".",
@@ -7,6 +7,6 @@
"@/*": ["./src/*"]
}
},
"include": ["**/*.ts"],
"include": ["**/*.ts", "**/*.tsx"],
"exclude": ["node_modules", "dist"]
}