0.0.3 • Published 8 years ago

@klarna/redux-simple-analytics v0.0.3

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
8 years ago

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

  1. Add tests to your changes.
  2. Make sure they pass running npm test.
  3. Bump the version.
  4. Add an entry to the CHANGELOG.md.
  5. Update the README.md if necessary.
  6. Send a PR.