redux-simple-analytics
Simple analytics middleware for Redux.
Usage
Unlike redux-analytics, redux-simple-analytics doesn't require a meta
key in your actions and it also doesn't enforce FSA actions through isFSA.
Therefore, all you have to do is to create your regular actions:
// constanst.js
export const MY_ACTION = 'MY_ACTION'
// actions.js
const action = {
type: MY_ACTION
}
Then, write the middleware to handle your analytics tracking:
/* global ga /
import constants from './constants'
import analytics from 'redux-simple-analytics'
const middleware = analytics(({ type, payload }, state) => {
switch(type){
case MY_ACTION:
ga('send', 'whatever', 'you', 'want');
break
}
})
Contributing
- Add tests to your changes.
- Make sure they pass running
npm test
. - Bump the version.
- Add an entry to the
CHANGELOG.md
. - Update the
README.md
if necessary. - Send a PR.