redux-appinsights-middleware
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

Redux AppInsights Middleware (Docs)

styled with prettier Greenkeeper badge Travis Coveralls

This middleware provides a more robust AppInsights API for Redux-based applications.

Installation

At first, install the package:

$ npm install redux-appinsights-middleware

Usage

Then use a middleware and reducer in your redux store:

import { applyMiddleware, combineReducers, compose, createStore } from "redux";
import { setup, createAppInsightsMiddleware, createAppInsightsReducer } from "redux-appinsights-middleware";
import { AppInsights } from "applicationinsights-js";

import * as reducers from "./reducers/";

const composeEnhancers = (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

export const store = createStore<IState>(
    combineReducers<IState>({ ...reducers, appinsights: createAppInsightsReducer() }),
    composeEnhancers(applyMiddleware(createAppInsightsMiddleware(AppInsights) )),
);

// Now you can track events like this:
store.dispatch({
    type: "app/MY_ACTION",
    payload: { ... },
    appinsights: {
        method: "trackPageView",
        data: [ "Page Title", "http://page.url" ],
    }
});

// If you aren't dispatch this action, nothing will be sent to AppInsights
store.dispatch(setup(AI_KEY));

Readme

Keywords

none

Package Sidebar

Install

npm i redux-appinsights-middleware

Weekly Downloads

48

Version

2.0.0

License

MIT

Unpacked Size

19.9 kB

Total Files

10

Last publish

Collaborators

  • zer0latency