Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@workpop/analytics-middleware

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@workpop/analytics-middleware

Redux middleware for Workpop Analytics

  • 0.0.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Workpop Redux Analytics Middleware

Analytics middleware for Redux.

Installation

$ npm install --save @workpop/analytics-middleware

Usage

Whenever we want to track analytics events we usually are required to supply our analytics library 2 things:

type AnalyticsEventType = {
    name: string,
    metadata: Object
}
  1. name - Name of the analytics event
  2. metadata - any additional data sent along with the event.

A sample action creator:

function addSparksAction(sparkCount, uiSource) {
    return {
        type: "ADD_SPARKS",
        data: sparkCount,
        analytics: {
            name: "Track Sparks",
            metadata: {
                sparkCount,
                "UI Source": uiSource
            }
        }
    }
}

Setup

To enable the Redux Store to start dispatching analytics tracking, we need to setup our middleware.

import { createStore, applyMiddleware } from 'redux';
import rootReducer from './rootReducer';
import { analyticsMiddleware } from '@workpop/analytics-middleware';
import { event } from '@workpop/analytics-core';

export const store = createStore(rootReducer, {}, applyMiddleware(analyticsMiddleware(event));

The analytics middleware takes one argument, which is your event tracking implementation:

analyticsMiddleware(track)

  1. track - Function - analytics implementation from whatever library.

The middleware will call this track function with 2 params, name, and metadata.

Keywords

FAQs

Package last updated on 20 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc