Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@alexbeletsky
Created November 17, 2017 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexbeletsky/854539a220826566104659ac1739bc27 to your computer and use it in GitHub Desktop.
Save alexbeletsky/854539a220826566104659ac1739bc27 to your computer and use it in GitHub Desktop.
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