Alternative Event Tracking: withTrackedReducer#266
Conversation
…racking and add tests
`withEventsTracking` is failing in some cases, wihch is due to its initial design spec. `withTrackReducer` provides a potential better alternative.
|
I did a preliminary review for now and will give a more formal one in the evening. Looks good though. One piece missing at the moment: some sort of documentation reference |
Co-authored-by: Michael Small <33669563+michael-small@users.noreply.github.com>
|
I see it as temporarily. In the end, we need support for meta-reducers in the core... |
In that respect, I think this code/approach as-is minus the outstanding items seems legit. But with those outstanding items, I defer to @wolfmanfx on the outstanding considerations. I imagine there will be some more reviewing opportunity then. |
Removed withEventsTracking. Use withTrackedReducer instead for automatic DevTools action naming from events. - Remove withEventsTracking feature and its test file - Export withTrackedReducer as the replacement - Remove unused onInit/DevtoolsHookContext from devtools types - Remove devtoolsEventsTracker and eventsTracking option - Update demo app to use withTrackedReducer
|
@rainerhahnekamp I have updated / cleaned the branch. I also vote for the temp solution with the "withTrackedReducer". |
|
Should documentation be rolled into this PR or done in a separate PR? |
@michael-small I'd say separate PR, do you want to do it? |
Yeah |
|
Here's the thing. We do have a type check which verifies that The problem is that no one can decipher the error message. I am playing with the thought of the type error against a runtime error, where end users get a readable error message and understand what they have to do. What are your thoughts @michael-small and @wolfmanfx
|
|
Runtime error seems inline with approached we have used before and seems way less complex. |
|
This is ready. We can even backport it to v20. |

Summary
This PR introduces
withTrackedReduceras an alternative approach to tracking reducer-based state changes in Redux DevTools. It addresses limitations in the originalwithEventsTrackingimplementation.The original implementation (based on #231) attempted to automatically track reducer-based state changes via the glitch tracker. However, this approach has fundamental limitations that cannot be resolved with the specified approach.
Several edge cases are documented in the skipped tests within
with-events-tracking.spec.ts.This PR introduces an alternative way, where end users have to use the wrapperd function
withTrackedReducerwhich calls internallyupdateStateusing the event's name.If we proceed with this approach, the following items need to be completed:
withTrackedReducerusage and when to use it vswithReducerwithEventsTrackingapproach (if applicable)withTrackedReduceris only used with stores that have devtools and glitch tracking enabled