Skip to content

Typed events functionality implemented, tested, and documented#20

Merged
mandla-enkosi merged 5 commits intomainfrom
typed-events
Mar 4, 2026
Merged

Typed events functionality implemented, tested, and documented#20
mandla-enkosi merged 5 commits intomainfrom
typed-events

Conversation

@mandla-enkosi
Copy link
Contributor

@mandla-enkosi mandla-enkosi commented Mar 3, 2026

Implements “typed events” support for Trackkit’s factory API by introducing an event map generic that constrains track() calls at compile time, and adds accompanying tests + documentation.

Changes:

  • Add EventMap / AnyEventMap types and thread a generic E through createAnalytics, AnalyticsFacade, and AnalyticsInstance.track().
  • Add runtime tests for typed vs untyped instances, plus compile-time (.test-d.ts) type tests.
  • Update README + docs (Quickstart + API reference) to document typed events usage.

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

Implements “typed events” support for Trackkit’s factory API by introducing an event map generic that constrains track() calls at compile time, and adds accompanying tests + documentation.

Changes:

  • Add EventMap / AnyEventMap types and thread a generic E through createAnalytics, AnalyticsFacade, and AnalyticsInstance.track().
  • Add runtime tests for typed vs untyped instances, plus compile-time (.test-d.ts) type tests.
  • Update README + docs (Quickstart + API reference) to document typed events usage.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
packages/trackkit/vitest.config.ts Adds Vitest typecheck configuration for .test-d.ts files.
packages/trackkit/test/unit/types/typed-events.test-d.ts Adds compile-time assertions for typed-events constraints.
packages/trackkit/test/unit/facade/typed-events.test.ts Adds runtime verification that typed generics don’t affect runtime dispatch.
packages/trackkit/src/types.ts Introduces EventMap/AnyEventMap and generic AnalyticsInstance<E> w/ typed track().
packages/trackkit/src/factory.ts Makes createAnalytics generic and returns a typed facade instance.
packages/trackkit/src/facade/index.ts Makes AnalyticsFacade generic and types its track() method by event map.
packages/trackkit/README.md Documents how to use typed events with createAnalytics<E>().
docs/reference/api.md Updates API reference to mention typed events and new default type param.
docs/overview/quickstart.md Adds a “Typed events” section and links to API details.

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

mandlamoyo and others added 4 commits March 3, 2026 22:10
* Made doc fixes

* Separation of dispatcher and consent config params

---------

Authored-by: mandlamoyo <mandla.moyo@hotmail.com>
@mandla-enkosi mandla-enkosi merged commit b81b45c into main Mar 4, 2026
1 of 2 checks passed
@mandla-enkosi mandla-enkosi deleted the typed-events branch March 4, 2026 09:31
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