# 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).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://isaquediasm.gitbook.io/tracking-middleware/getting-started/introduction.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
