Created
June 15, 2019 09:20
-
-
Save tiagogm/7b66f199f9b9910e158a19af5ec7399b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment