Last active
May 6, 2016 07:21
-
-
Save gpoole/6396ed6506f635e2577cc3ceb2838238 to your computer and use it in GitHub Desktop.
This file contains 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
import pushToDataLayer from 'fe-helper'; | |
export default function track(Component) { | |
return (props) => { | |
const trackers = props.trackEvents.reduce((trackers, eventName) => { | |
trackers[eventName] = (...args) => { | |
pushToDataLayer({ event: event }); | |
if (typeof props[eventName] !== 'undefined') { | |
return props[eventName](...args); | |
} | |
}; | |
return trackers; | |
}, {}); | |
return <Component {...props} {...trackers} />; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment