Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //configuration of all events from multiple root level pages
- const eventsRegister = {
- ...SEARCH_EVENTS_CONFIG,
- ...LISTING_EVENTS_CONFIG
- //loads more
- }
- // for example, in `src/views/search/events.ts` file
- export const SEARCH_EVENTS_CONFIG: EventConfigMap = {
- [SEARCH_EVENTS.datedSearch]: [evtCh.GA, evtCh.KSM, evtCh.FB],
- [SEARCH_EVENTS.advancedFiltersClick]: [evtCh.GA, evtCh.KSM, evtCh.DblClick],
- }
- //configure each channel to it's particual service/module file
- const eventProxy = {
- //this is where each specific service handled third party integration
- [evtCh.GA]: gaService.event,
- [evtCh.KSM]: ksmService.event
- }
- const trackEvent = (event: IEvent, data: EventData) => {
- (eventsRegister[event]||[]).forEach(channel => {
- eventProxy[channel](event);
- })
- }
- export const analyticsService = {
- trackEvent,
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement