Matt Arbesfeld CEO @ LogRocket

Log-Driven Development with Redux

1 min read 496

How many times have you been asked by a product manager “how often is this feature being used?” Or there’s a mysterious crash in your app that you can’t reproduce. Or a user a reports a problem and you have to ask them for a screenshot of the page JavaScript console. It’s happened to me way too many times.
 
Log-Driven Development solves all of these problems. The idea is that by driving the business logic of an app via logs, we are able to automatically capture information that helps us reproduce bugs, resolve user issues, and understand user behavior without additional work.
 
Using Redux makes this very easy: we can just log everything and then search and investigate our logs later.
 
Here are a few examples of how we use Log-Driven Development at LogRocket:

Scenario 1: Reproducing Bugs

We use crash reporting tools and we get a bunch of errors that look something like this:


We don’t have enough information here to reproduce the bug. However, since we are using Redux in our app, we capture the series of events that led to the problem in LogRocket:


Scenario 2: Resolving User Issues

The other day, a user told us that they were having difficulty logging in. Normally I’d have to ask a bunch of clarifying questions: “What account are you using?”, “Can you send us a screenshot?”, “Have you tried incognito mode?” In this case, we had captured all of the information in logs, and we discovered the fix without back-and-forth. Success!


Scenario 3: Understanding User Behavior

Our product manager works really hard to understand what makes our users successful. He set up Heap to be able to retroactively analyze interactions, but we found that there were still a number of events that he had to ask us to manually tag in the app. I set up a Redux middleware to send all of our events to Segment: https://github.com/rangle/redux-segment and we haven’t had a problem since 🙂


Getting Started With Log-Driven Development

  • Use Redux
  • Use Redux libraries for your app’s business logic:

redux-query for REST APIs

apollo-client for GraphQL APIs

redux-saga for asynchronous events

  • Use LogRocket to capture log data in production

Happy logging!


Plug: LogRocket, a DVR for web apps


LogRocket is a frontend logging tool that lets you replay problems as if they happened in your own browser. Instead of guessing why errors happen, or asking users for screenshots and log dumps, LogRocket lets you replay the session to quickly understand what went wrong. It works perfectly with any app, regardless of framework, and has plugins to log additional context from Redux, Vuex, and @ngrx/store.

In addition to logging Redux actions and state, LogRocket records console logs, JavaScript errors, stacktraces, network requests/responses with headers + bodies, browser metadata, and custom logs. It also instruments the DOM to record the HTML and CSS on the page, recreating pixel-perfect videos of even the most complex single page apps.

Matt Arbesfeld CEO @ LogRocket

Leave a Reply