track-action-middleware
A middleware for interfacing actions with some other event tracking or analytics system.
Usage
;; { // YOUR CODE HERE // fire off requests put data somewhere} const trackActionMiddleware = ;
Using a selector
In many cases, you'll want to grab some extra state to send along in the payload.
In a redux app, the abstraction for this is a selector. If you pass makeTrackActionMiddleware
a
selector function, we'll call it with the store state and splat the result onto the second argument
to trackAction
.
const trackActionMiddleware = ;
The selector will also be passed the action itself, so you can switch on the action to provide different selections.
const trackActionMiddleware = ;
Custom event names
By default, the action type will be passed as the event name. If you want to map action types to a different event name, pass getEventName
to makeTrackActionMiddleware
.
const trackActionMiddleware = ;