@repo/analytics-core is a framework-agnostic analytics interface. It exports an abstract AnalyticsClient class with initialize(), identify(userId, properties), and trackEvent(event, properties?) methods, plus the AnalyticsEvent type. It also ships a LoggerAnalyticsClient default implementation that logs analytics calls through @repo/logger (useful for development).
flowchart LR
analyticsCore["@repo/analytics-core"]
logger["@repo/logger"]
ts["@repo/typescript-config"]
vitest["@repo/vitest-config"]
analyticsCore -.-> logger
analyticsCore -.-> ts
analyticsCore -.-> vitestimport { AnalyticsClient } from "@repo/analytics-core";
class MixpanelClient extends AnalyticsClient {
async initialize() {
/* ... */
}
async identify(userId: string, properties: Record<string, unknown>) {
/* ... */
}
async trackEvent(event: string, properties?: Record<string, unknown>) {
/* ... */
}
}
Or use the built-in logger client for development:
import { loggerAnalyticsClient } from "@repo/analytics-core";
await loggerAnalyticsClient.trackEvent("page_view", { page: "/dashboard" });
| Script | Description |
|---|---|
test |
Run Vitest with coverage |
test:watch |
Run Vitest in watch mode |
check-types |
Typecheck with tsc --noEmit |