Created
November 17, 2017 13:29
-
-
Save alexbeletsky/854539a220826566104659ac1739bc27 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
import { client } from '../analytics'; | |
const handleAction = (store, next, action, options) => { | |
if (!action.meta || !action.meta.analytics) { | |
return next(action); | |
} | |
const { eventType, eventPayload } = action.meta.analytics; | |
client(options).track(eventType, eventPayload); | |
return next(action); | |
}; | |
export function createAnalytics(options = {}) { | |
return store => next => action => handleAction(store, next, action, options); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment