Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. //configuration of all events from multiple root level pages
  2. const eventsRegister = {
  3. ...SEARCH_EVENTS_CONFIG,
  4. ...LISTING_EVENTS_CONFIG
  5. //loads more
  6. }
  7.  
  8. // for example, in `src/views/search/events.ts` file
  9. export const SEARCH_EVENTS_CONFIG: EventConfigMap = {
  10. [SEARCH_EVENTS.datedSearch]: [evtCh.GA, evtCh.KSM, evtCh.FB],
  11. [SEARCH_EVENTS.advancedFiltersClick]: [evtCh.GA, evtCh.KSM, evtCh.DblClick],
  12. }
  13.  
  14.  
  15. //configure each channel to it's particual service/module file
  16. const eventProxy = {
  17. //this is where each specific service handled third party integration
  18. [evtCh.GA]: gaService.event,
  19. [evtCh.KSM]: ksmService.event
  20. }
  21.  
  22. const trackEvent = (event: IEvent, data: EventData) => {
  23. (eventsRegister[event]||[]).forEach(channel => {
  24. eventProxy[channel](event);
  25. })
  26. }
  27.  
  28. export const analyticsService = {
  29. trackEvent,
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement