All Projects → aholachek → redux-usage-report

aholachek / redux-usage-report

Licence: other
A Redux Devtools monitor to audit your app's usage of the store

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to redux-usage-report

ReSwiftMonitor
ReSwift+redeux dev tools
Stars: ✭ 13 (-68.29%)
Mutual labels:  monitor, redux-devtools
pf-azure-sentinel
Parse pfSense/OPNSense logs using Logstash, GeoIP tag entities, add additional context to logs, then send to Azure Sentinel for analysis.
Stars: ✭ 24 (-41.46%)
Mutual labels:  monitor
Refactor Nrepl
nREPL middleware to support refactorings in an editor agnostic way
Stars: ✭ 213 (+419.51%)
Mutual labels:  refactoring
fastdash
FastDash = FastAPI + DashBoard.
Stars: ✭ 23 (-43.9%)
Mutual labels:  monitor
Best Of Python Dev
🏆 A ranked list of awesome python developer tools and libraries. Updated weekly.
Stars: ✭ 243 (+492.68%)
Mutual labels:  refactoring
atom-refactoring
Atom package that provides refactoring capabilities for your PHP source code.
Stars: ✭ 16 (-60.98%)
Mutual labels:  refactoring
Abracadabra
Automated refactorings for VS Code (JS & TS) ✨ It's magic ✨
Stars: ✭ 204 (+397.56%)
Mutual labels:  refactoring
rubocop-auto-correct
Auto-correct ruby source code by using rubocop in Atom.
Stars: ✭ 29 (-29.27%)
Mutual labels:  refactoring
AirPodsDesktop
☄️ AirPods desktop user experience enhancement program, for Windows and Linux (WIP)
Stars: ✭ 462 (+1026.83%)
Mutual labels:  monitor
QuickTraceiOSLogger
A real time iOS log trace tool, view iOS log with pc web browser under local area network, which will automatically scroll like xcode. 一个实时的iOS日志跟踪工具,在局域网中使用 PC Web 浏览器查看 iOS 日志,它将像xcode一样自动滚动。
Stars: ✭ 16 (-60.98%)
Mutual labels:  monitor
wowstat
A World of Warcraft realm status monitor
Stars: ✭ 20 (-51.22%)
Mutual labels:  monitor
Escape From Callback Mountain
Example Project & Guide for mastering Promises in Node/JavaScript. Feat. proposed 'Functional River' pattern
Stars: ✭ 249 (+507.32%)
Mutual labels:  refactoring
ExDeMon
A general purpose metrics monitor implemented with Apache Spark. Kafka source, Elastic sink, aggregate metrics, different analysis, notifications, actions, live configuration update, missing metrics, ...
Stars: ✭ 19 (-53.66%)
Mutual labels:  monitor
Quiz App
A repository reflecting the progress made on the "How to Build iOS Apps with Swift, TDD & Clean Architecture" YouTube series, by Caio & Mike.
Stars: ✭ 230 (+460.98%)
Mutual labels:  refactoring
electrom
Electrom is a resource management solution for Electron applications, which is convenient for performance management and friendly debugging of multiple windows.
Stars: ✭ 20 (-51.22%)
Mutual labels:  monitor
Learning Oop In Php
A collection of resources to learn object-oriented programming and related concepts for PHP developers.
Stars: ✭ 2,359 (+5653.66%)
Mutual labels:  refactoring
perf-monitor
Kernel profiler based on perf_event and ebpf
Stars: ✭ 28 (-31.71%)
Mutual labels:  monitor
Huhnitor
Intergalactic serial monitor for ESP8266 Deauther
Stars: ✭ 265 (+546.34%)
Mutual labels:  monitor
styled-media-helper
💅 Helps manage media queries with styled components
Stars: ✭ 76 (+85.37%)
Mutual labels:  breakpoint
guardkit
基于Java的监控框架
Stars: ✭ 25 (-39.02%)
Mutual labels:  monitor

Redux Usage Report

This library tracks the way your app is actually using the data in your Redux store. By setting up the monitor in devtools you can see a live view of when different parts of your store are accessed:

Redux usage monitor in action

To find out exactly when a certain value is being accessed, you can set a breakpoint to explore the call stack when the app touches that particular value.

You can also use redux-usage-report as a performance tool to find unnecessarily fetched data in your app.

Demo

Try it out on the TodoMVC app here.

Quickstart

1. Install the required libs

yarn add redux-usage-report redux-devtools redux-devtools-dock-monitor

2. Create the DevTools component

Create a file called DevTools.js (or whatever you'd like to call it) and paste the following code in:

import React from "react";
import { createDevTools } from "redux-devtools";
import DockMonitor from "redux-devtools-dock-monitor";
import { UsageMonitor } from "redux-usage-report";

export default createDevTools(
  <DockMonitor
    toggleVisibilityKey="ctrl-h"
    changePositionKey="ctrl-q"
    changeMonitorKey="ctrl-m"
  >
    <UsageMonitor />
  </DockMonitor>
);

3. Add the generateReduxReport and the DevTools.instrument store enhancers to your store:

Make sure to put the DevTools.instrument() call last in the order of composed functions.

Your code might look something like this:

configureStore.js

import { createStore, applyMiddleware, compose } from "redux"
import thunk from 'redux-thunk'
import generateReduxReport from "redux-usage-report"

import rootReducer from "./reducers"
import DevTools from './DevTools';

const enhancer = compose(
  applyMiddleware(thunk),
  generateReduxReport(),
  // DevTools.instrument() must go last
  DevTools.instrument()
  )

const store = createStore(rootReducer, initialState, enhancer)

3. Render <DevTools/> into the app

The easiest way to do this is just render the <DevTools/> component in your App component.

Read more about setting up redux devtools in the official documentation.

Please make sure to only include the devtools for your development build!

4. Temporarily disable the Redux Devtools browser extension

For the in-app Redux Devtools monitor to work, your Redux DevTools browser extension must be disabled (otherwise there are 2 copies trying to run at the same time).

How to use it

The json view of your store will show the parts that have been not accessed at reduced opacity, as well as an estimate of the total percentage of your store that has been used so far by your app. (The percentage is calculated by comparing the string length of the json comprising the used portion of the store, with the json string containing the entire store.)

Set a breakpoint

You can set a breakpoint by doing shift + click on any key in the json view. The next time the key is accessed, the debugger will stop execution. Feel free to reload the page, the breakpoint will persist until you remove it by holding shift and clicking it again.

Setting a breakpoint

Find unused data

Note: This works best in Chrome.

Load the monitor in the app as described above, and visit all pages you want to test. Make sure to perform any required UI interactions to trigger data fetching or data usage. Then, open your browser console and type

copy(reduxReport.generate().unused)

You can now paste that JSON object into a file to see which parts of your redux store have remained completely untouched. You might be able to get rid of some data fetching entirely, or simply be more thoughtful about when data is fetched, in order to speed up your app.

How it works

The generateReduxReport enhancer wraps the store in a proxy, so that each object access can be tracked.

It tries to be smart about ignoring object accesses that come from outside your app's code. For instance, if you're also using the persistStore Devtools plugin, even though that plugin accesses every key in your store, you shouldn't see that reflected in the Usage Report monitor. The monitor attempts to filter out object access that originates in any module located in the node_modules folder or from a browser extension. This filtering logic only works in Chrome, or failing that, if you are using something like the eval option or some other lightweight type of source map that preserves file pathnames in stacktraces.

If you are curious as to why a value is marked "accessed", you can always shift + click the relevant key in the monitor to set a breakpoint.

Performance

If you notice any performance issues, (you probably will in an app with a larger redux store) you can speed things up by turning off the most expensive check (whether to ignore object access that originates from node_modules) by typing in the console:

reduxReport.__skipAccessOriginCheck = true
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].