Soluto / shisell-js

A service agnostic library for building immutable scoped analytic event dispatchers with extra data, identities and lazy filters.
MIT License
41 stars 3 forks source link

index.js refactor #6

Closed omerlh closed 9 years ago

omerlh commented 9 years ago

Today index.js contains some decorator around analytics dispatcher: it run the filters and it convert from analytics context to analytics model. I think this should be an inner implementation of analytics dispatcher, or at least be in a relevant file. Also, I think we should not export the default analytics dispatcher without that decoration.

Yshayy commented 9 years ago

I think the idea is that AnalyticsContext->AnalyticsEventModel is external to dispatcher. Beside decoupling, I think since analytics filters are asynchronous (Promise), such change might create to add support for promises on the dispatcher level which can make things more complicated.
I do think that we should move createEventModel externally, index.js should be minimal.

odedw commented 9 years ago

After some discussion, the main interface to the lib should be createRootDispatcher which receives a writer (delegate that receives an AnalyticsEventModel). More advanced users can create a dispatcher themselves that converts a context to an event (not AnalyticsEventModel which is internal to the lib).

Yshayy commented 9 years ago

In TS annotation: createRootDispatcher(writer:(EventModel)=>{}, context?: AnalyticsContext):AnalyticsDispatcher;