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
Get set up with LogRocket's modern error tracking in minutes:
- Visit https://logrocket.com/signup/ to get an app ID
- Install LogRocket via npm or script tag.
LogRocket.init()must be called client-side, not server-side
- (Optional) Install plugins for deeper integrations with your stack:
- Redux middleware
- NgRx middleware
- Vuex plugin
$ npm i --save logrocket
import LogRocket from 'logrocket';
Add to your HTML:
<script>window.LogRocket && window.LogRocket.init('app/id');</script>