Skip to content

Implemented typed events#22

Merged
mandla-enkosi merged 10 commits intomainfrom
typed-events
Mar 17, 2026
Merged

Implemented typed events#22
mandla-enkosi merged 10 commits intomainfrom
typed-events

Conversation

@mandla-enkosi
Copy link
Contributor

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class typed events support to Trackkit’s factory API by introducing an EventMap generic that type-checks track() event names and properties at compile time, while keeping the default (untyped) behavior unchanged. The PR also adds Vitest typecheck tests and updates docs/examples to reflect the newer configuration and API shapes.

Changes:

  • Introduce EventMap / AnyEventMap and generic track() signatures on AnalyticsInstance and AnalyticsFacade.
  • Add Vitest typecheck configuration plus compile-time .test-d.ts coverage for typed events.
  • Update docs/examples and stabilize a batching-related network dispatcher unit test.

Reviewed changes

Copilot reviewed 25 out of 26 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/trackkit/vitest.config.ts Enables Vitest typecheck runs for .test-d.ts files.
packages/trackkit/test/unit/types/typed-events.test-d.ts Adds compile-time type tests for typed events.
packages/trackkit/test/unit/facade/typed-events.test.ts Adds runtime tests to confirm generics don’t affect behavior.
packages/trackkit/test/unit/dispatcher/network-dispatcher.test.ts Reduces flakiness by waiting for async dispatch rather than sleeping.
packages/trackkit/src/types.ts Defines EventMap/AnyEventMap and makes AnalyticsInstance generic with conditional track() args.
packages/trackkit/src/factory.ts Makes createAnalytics generic and returns AnalyticsFacade<E>.
packages/trackkit/src/facade/index.ts Makes AnalyticsFacade generic and applies typed track() signature.
packages/trackkit/package.json Adds test:typecheck script for typecheck-only Vitest runs.
packages/trackkit/README.md Documents typed events usage and clarifies singleton limitations.
examples/react-spa-umami/README.md Expands example documentation and explains features/flow.
examples/next-ssr-ga4/pages/index.tsx Replaces commented stub with a working SSR + client demo page.
examples/next-ssr-ga4/pages/_document.tsx Replaces commented stub with working SSR queue capture/injection.
examples/next-ssr-ga4/README.md Rewrites README to explain SSR queue/hydration behavior.
docs/reference/configuration.md Updates config docs to reflect dispatcher nesting (dispatcher.*).
docs/reference/api.md Updates API reference for typed events and current signatures.
docs/providers/umami.md Removes mention of unsupported metadata config.
docs/providers/ga4.md Removes defaultProps mention and updates best-practices guidance.
docs/overview/quickstart.md Adds “typed events” section to quickstart.
docs/overview/architecture.md Corrects config module references.
docs/index.md Adds npm “Download Now” link on docs landing page.
docs/guides/resilience-and-transports.md Updates resilience docs to match dispatcher.resilience.*.
docs/guides/queue-management.md Updates diagnostics snapshot format and wording.
docs/guides/custom-providers.md Updates provider configuration examples to provider: { name, ... }.
docs/guides/consent-management.md Fixes consent examples to use createAnalytics(...) and current option names.
README.md Updates top-level positioning and flow explanation.
.gitignore Adds .audit ignore entry.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mandla-enkosi mandla-enkosi merged commit 543de14 into main Mar 17, 2026
4 checks passed
@mandla-enkosi mandla-enkosi deleted the typed-events branch March 17, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants