> For the complete documentation index, see [llms.txt](https://isaquediasm.gitbook.io/tracking-middleware/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://isaquediasm.gitbook.io/tracking-middleware/getting-started/introduction.md).

# Introduction

## Installation

```
yarn add redux-tracking-middleware
```

## Setup

Import the middleware, write your configurations and include it in `applyMiddleware` when creating a Redux Store:

```javascript
import trackingMiddleware from 'redux-tracking-middleware'
import mixpanel from 'mixpanel'

const defaultTracking = {
  track: action => {
    mixpanel.track(action.type, action.payload)
  }
}

const tracking = trackingMiddleware(defaultTrack)
const store = createStore(
  rootReducer,
  applyMiddleware(tracking.reduxMiddleware)
)
```

## Use

Dispatch an arbitrary action

```javascript
const foo = () => ({
  type: 'FOO',
  payload: { foo: 'bar' }
})
```

A tracking event will be immedietly dispatched to the `track` fn.

```javascript
action => {
  mixpanel.track(action.type, action.payload)
}
```

Copyright (c) 2020 Isaque Dias. [Code licensed with the MIT License (MIT)](https://github.com/isaquediasm/redux-tracking-middleware/tree/caefe7fcffaffdd1af7ecf0703efa709916b3091/LICENSE/README.md). [Documentation licensed with the CC BY-NC License](https://github.com/isaquediasm/redux-tracking-middleware/tree/caefe7fcffaffdd1af7ecf0703efa709916b3091/docs/LICENSE/README.md).
