• Stars
    star
    668
  • Rank 67,542 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 8 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Analytics integration for Redux and ngrx/store

Redux Beacon

Redux Beacon

Analytics integration for Redux and ngrx/store

Docs

Introduction

If you're using Redux or ngrx/store to manage your app's state, you can use Redux Beacon to tap into your dispatched actions and map them to events that are consumable by an analytics service (e.g. Google Analytics). With Redux Beacon your entire global state life-cycle becomes trackable.

Redux Beacon Diagram

  • Redux Beacon is lightweight. The core Redux Beacon module is tiny (~ 1KB), and each target, extension, and util, is either around the same size or smaller.

  • You can use Redux Beacon with any framework. Redux Beacon doesn't depend on any framework, you can use Redux Beacon with React, Angular, React Native, Vue or just plain JavaScript.

  • You can send analytics anywhere. We have prebuilt targets for the most popular analytics services, you can also build your own custom targets if you need to.

  • You can track analytics offline. Redux Beacon provides extensions for tracking analytics during intermittent outages in connectivity. These extensions save events in a persistent store when offline (e.g indexedDB). When back online, the extensions purge the store and pass the events off to a target. Read more about offline event collection in the docs.

Supported Targets

Version Package
Google npm @redux-beacon/google-analytics
Google npm @redux-beacon/google-analytics-gtag
Google npm @redux-beacon/google-tag-manager
Google npm @redux-beacon/react-native-google-analytics
Google npm @redux-beacon/react-native-google-tag-manager
Amplitude npm @redux-beacon/amplitude
Segment npm @redux-beacon/segment
Segment npm @redux-beacon/react-native-segment

Third-Party Targets

Version Package
Matomo npm redux-beacon-matomo-tag-manager
Appsflyer npm redux-beacon-react-native-appsflyer

Other Targets

If you don't see your analytics target listed it might be worth a shot doing a quick search on npmjs.org. If all else fails you can always build and provide your own custom Targets!

Integrations

Integration Integrates with Description
redux-dynamic-modules-beacon redux-dynamic-modules Redux Dynamic Modules is a library that allows to modularize redux code. With help of this extension events do not have to be defined in one central location but can be defined for each module individually.

Usage

  • Step 1. Pick out a target (see above)

  • Step 2. Pick out some events you want to track from your target's Event Definitions section

  • Step 3. Match the events to action types (see below)

Examples

Track a page view on each ROUTE_CHANGED action

const eventsMap = {
  'ROUTE_CHANGED': trackPageView(action => ({
    page: action.payload.routerState.url,
  })),
}

Track an event on each VIDEO_SELECTED action, use the state before the action and the state after the action to hydrate the analytics event

const eventsMap = {
  'VIDEO_SELECTED': trackEvent((action, prevState, nextState) => ({
    category: 'Videos',
    action: action.type,
    label: prevState.videos.currentCampaign,
    value: nextState.videos.numVideosSelected,
  }))
}

Track an event on every action using the special '*' key

const eventsMap = {
  '*': trackEvent(action => ({
    category: 'redux',
    action: action.type,
  })),
}

Track multiple events on each VIDEO_PLAYED action using the combineEvents util

const eventsMap = {
  'VIDEO_PLAYED': combineEvents(
    trackTiming(action => ({
      category: 'Videos',
      action: 'load',
      value: action.payload.loadTime,
    }))
    trackEvent(() => ({
      category: 'Videos',
      action: 'play'
    })),
  ),
}

Track an event on each 'VIDEO_SEARCHED' action, but throttle it with the debounceEvent util so it doesn't fire as often

const eventsMap = {
  'VIDEO_SEARCHED': debounceEvent(300,
     trackEvent(action => ({
       category: 'Videos',
       action: 'search',
       label: action.payload.searchTerm,
     }))
   ),
}

The trackPageView, trackEvent, and trackTiming functions used above are called eventDefinitions and are what you use to create events that are consumable by an analytics service (a.k.a "target"). Each target will have its own set of eventDefinitions that you can use and customize.

Don't like the idea of using an object to map actions?

You can use a function...

const pageView = trackPageView(action => ({
  page: action.payload.routerState.url,
}));

const videoLoadTime = trackTiming(action => ({
   category: 'Videos',
   action: 'load',
   value: action.payload.loadTime,
}));

const videoPlayed = trackEvent(() => ({
  category: 'Videos',
  action: 'play'
}));

const eventsMapper = (action) => {
  switch(action.type) {
    case 'ROUTE_CHANGED':
      return pageView;
    case 'VIDEO_PLAYED':
      return [videoLoadTime, videoPlayed]
    default:
      return [];
  }
}

More Examples & Recipes

Extensions & Plugins

Version Package
πŸ”Œ npm @redux-beacon/logger
πŸ”§ npm @redux-beacon/combine-events
πŸ”§ npm @redux-beacon/ensure
πŸ”§ npm @redux-beacon/debounce-event
πŸ”Œ npm @redux-beacon/offline-web
πŸ”Œ npm @redux-beacon/offline-react-native

More Repositories

1

augury

Angular Debugging and Visualization Tools
TypeScript
2,008
star
2

angular-2-aot-sandbox

Sandbox for testing Angular 2's AoT specifically what expressions break it
TypeScript
297
star
3

angular-ssr

Angular 4+ server-side rendering solution compatible with @angular/material, jQuery, and other libraries that touch the DOM (as well as providing a rich feature set!)
TypeScript
279
star
4

angular-devtools

Moved to the Angular organization.
TypeScript
255
star
5

ngCourse2

An Angular Course from Rangle.io
TypeScript
184
star
6

radius

A design system accelerator
TypeScript
173
star
7

augury-labs

Experimental Angular developer tools
TypeScript
89
star
8

stripe-eventbridge

Connect Stripe events to AWS EventBridge
JavaScript
72
star
9

angular2-starter

Angular 2 Starter Repo
JavaScript
60
star
10

radius-tracker

Measure adoption of your design system
TypeScript
56
star
11

rangle-starter

JavaScript
48
star
12

mibank-micro-frontends

Demonstration of Micro Frontend Architecture.
JavaScript
43
star
13

jwt-role-based-authentication-examples

Implement the same backend using graphql, nestjs and deno.
TypeScript
34
star
14

schematics-angular

Angular Schematics for adding features to an existing angular project to improve productivity and organization-wide consistency
TypeScript
34
star
15

hackstack

A library for building AngularJS apps with broken APIs that are delivered late.
JavaScript
32
star
16

angular-training-slides

Slides for the Angular 2 training
HTML
29
star
17

angular-ngrx-example

Angular @ngrx example illustrating best practices
TypeScript
28
star
18

federated-modules-typescript

Use Webpack5 Module Federation with TS/React - Type-safe MonoRepo setup
JavaScript
18
star
19

pgdays-codepush-demo

JavaScript
14
star
20

angular-training-examples

Blog application for Angular 2 training
TypeScript
13
star
21

code-push-demo

An example of how to use CodePush with an Ionic/Cordova app.
JavaScript
11
star
22

react-native-workshop

JavaScript
10
star
23

radius-monorepo-react

Radius Monorepo Configuration for React
TypeScript
9
star
24

Stripe-shop-backend

A starter kit for Stripe Payments running on AWS lambda's with DynamoDB. Implements a basic Catalog and payment. Support Terminal and Stripe Elements.
TypeScript
8
star
25

augury-examples

A repo containing the augury example apps.
TypeScript
7
star
26

react-native-example

React-native and redux example package
JavaScript
7
star
27

serve-webpack-client

Helper module for serving webpack-related client code from a nodejs server.
JavaScript
6
star
28

rangle-investing

RangleBank Investing App
TypeScript
5
star
29

radius-angular

TypeScript
4
star
30

express-jwt-jwks

Simple JWT auth using JWKS key sets for Express. Wraps express-jwt and jwks-rsa. AWS Cognito compatible.
JavaScript
4
star
31

custom-angular-schematic-demo

Custom schematics for libraries
TypeScript
4
star
32

headless-workshop

TypeScript
4
star
33

radius-workspace

Main workspace for the new version of Radius
TypeScript
4
star
34

figma-plugin-missing-library-usage-finder

Figma Plugin to find instances or styles by name, e.g. to find missing library usage
TypeScript
4
star
35

vue-3d

3D visualization demo for Hack Western 5.
Vue
3
star
36

bridge-transit-app-cohort-2

JavaScript
3
star
37

react-native-netflix-clone

Basic Netflix clone app built with React Native
TypeScript
3
star
38

augury-site

Augury's Documentation Site
JavaScript
3
star
39

invision-dsm-utlities

Utility scripts to help integrate InVision Design System Manager (DSM) into your front-end codebase.
TypeScript
3
star
40

catch-webhooks

A webhook catcher with a web UI. See a transcript log of webhook events that reach your endpoint in a nice annotatable web interface.
JavaScript
3
star
41

rangle-academy-unit-testing

Workshop for Unit Testing
JavaScript
3
star
42

angular-18-demos

TypeScript
3
star
43

stripe-ts-react-redux-saga

Demo of Stripe Elements & Terminal in React/Redux/Sagas using Typescript
TypeScript
3
star
44

react-training-oct-2

JavaScript
2
star
45

angular-training

Integrated Angular training materials
Shell
2
star
46

angular-testing-workshop

TypeScript
2
star
47

react-native-workshop-1

Objective-C
2
star
48

react-training-sep-25

JavaScript
2
star
49

gitub-action-template-example

Example of setting up Github action workflow templates within Organization
2
star
50

a11y-violations-crawler

A performant webpage-crawler that will run each page through axe-core to display and/or store violations related to it for reporting.
CSS
2
star
51

rangle-type-scale

JavaScript
2
star
52

angular-performance-meetup

Sample application to show how to improve performance in an Angular app
CSS
2
star
53

bridge-photo-map-app

JavaScript
2
star
54

angular-training-app

Sample application for learning Angular 2
JavaScript
2
star
55

ng-apollo-story

TypeScript
2
star
56

angular-headless-cms

TypeScript
2
star
57

test-automation

Any code related to testing such as automation frameworks or utilities for manual testing.
HTML
1
star
58

koast-db-utils

JavaScript
1
star
59

koast-admin-app

client app to admin a koast server
JavaScript
1
star
60

radius-token-tango

Suite of tools to connect Design Tokens to Repositories, facilitating Figma workflows
TypeScript
1
star
61

a11y-test-automation

TypeScript
1
star
62

angular-schematic-patterns

TypeScript
1
star
63

stripe-payment-demo

Vue
1
star
64

ng-blog-live-code

Live Coded Blog For Teaching Angular
TypeScript
1
star
65

react-native-training

Rangle.io React Native Training
JavaScript
1
star
66

playingHere

JavaScript
1
star
67

graphql-pt1-workshop-slides

Slides and speaker notes for GraphQL Part 1 workshop
CSS
1
star
68

jekyll-starter

A Gulp based Jekyll Starter
JavaScript
1
star
69

contentful-custom-map-editor

Custom Image Map Editor for Contentful
TypeScript
1
star
70

angular-book-examples

TypeScript
1
star
71

apollo-rest-example

Apollo Rest API Server Adaptor Example
TypeScript
1
star
72

serverless-app-poc

A serverless application that provides subscription-based online learning content managed by headless CMS.
JavaScript
1
star
73

bridge-lcbo-app-cohort-2

JavaScript
1
star
74

ai-alt-text-generator

TypeScript
1
star
75

styled-system-workshop

Programming Design Systems with Styled-System Workshop
JavaScript
1
star