npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

redux-ga-screen-tracker

v1.4.0

Published

Redux middleware for screen tracking in google analytics

Downloads

8

Readme

redux-ga-screen-tracker

Inspired by react-navigation guide

Redux middleware to track screens on google analytics in a react-native application using react-navigation The middleware triggers track screen events on desired navigation actions with screen name which it gets from the route stack in the store.

Installation:

npm install redux-ga-screen-tracker --save

Usage: redux-ga-screen-tracker expects the following parameters:

  • tracker: An instance of react-native-google-analytics-bridge
  • nav: Key for store object with navigation stack
  • navActionsToTrack: Array of actions for screen tracking
  • gaRouteMap (optional) : Config map of screen name to business name to be used in google analytics tracker
  • customDimensions (optional) : An object with custom dimensions
  • getCustomDimensions (optional) : Returns custom dimensions
//store.js
import screenTracking from 'redux-ga-screen-tracker';
import screenTrackingConfig from '../screenTrackingConfig.config';
import tracker from '../googleAnalytics.util'; //tracker from react-native-google-analytics-bridge

const middleware = compose(applyMiddleware(..., screenTracking(screenTrackingConfig));

const initStore = () => createStore(rootReducer, {}, middleware);
//screenTrackingConfig.config.js
export const screenTrackingConfig = {
  tracker,
  navStoreKey: 'nav',
  navActions: ['Navigation/NAVIGATE', 'Navigation/BACK', 'Navigation/RESET'],
  gaRouteMap,
  customDimensions
};

const gaRouteMap = {
  LaunchPage: 'Launch Screen',
  LoginPage: 'Login Screen'
}

Usage Dependency:

  1. Set up google analytics for your react native application:
//googleAnalytics.util.js
import {GoogleAnalyticsTracker, GoogleAnalyticsSettings} from 'react-native-google-analytics-bridge';
import env from '../constants/env.config';

GoogleAnalyticsSettings.setDispatchInterval(env.GA_TRACKER_INTERVAL);
const tracker = new GoogleAnalyticsTracker(env.GA_TRACKER_ID);
export default tracker;
  1. Navigation state in store
//reducers: index.js
import Navigator from '../routes/index.routes'; //react-navigation

const nav = (state, action) => (
  Navigator.router.getStateForAction(action, state)
);

const appReducers = combineReducers({ ..., nav });

References: