Closed omerlh closed 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
I do think that we should move createEventModel externally, index.js should be minimal.
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).
In TS annotation: createRootDispatcher(writer:(EventModel)=>{}, context?: AnalyticsContext):AnalyticsDispatcher;
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.