Options
All
  • Public
  • Public/Protected
  • All
Menu

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));

Index

Type aliases

InsightsEvent

InsightsEvent: object

Type declaration

  • data: any
  • method: keyof IAppInsights

Variables

Const SETUP

SETUP: "appinsights/SETUP" = "appinsights/SETUP"

Functions

createAppInsightsMiddleware

  • createAppInsightsMiddleware(ai: IAppInsights, propName?: string): Middleware
  • Middleware's creator

    Parameters

    • ai: IAppInsights

      AppInsights instance

    • Default value propName: string = "appinsights"

      Property name to read from your Actions

    Returns Middleware

createAppInsightsReducer

  • createAppInsightsReducer(propName?: string): (Anonymous function)
  • Reducer's creator

    Parameters

    • Default value propName: string = "appinsights"

      Property name to read from your Actions

    Returns (Anonymous function)

setup

  • setup(key: string): object

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc