Registry /
observability / redux-action-analytics-middleware
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default
✓ import AnalyticsMiddleware from 'redux-action-analytics-middleware'
✗ const AnalyticsMiddleware = require('redux-action-analytics-middleware')
The package exports a single default export, the AnalyticsMiddleware function. CommonJS require works but TypeScript users should use default import.
AnalyticsMiddleware
✓ import AnalyticsMiddleware from 'redux-action-analytics-middleware'
✗ import { AnalyticsMiddleware } from 'redux-action-analytics-middleware'
This is a default export, not a named export. Using curly braces will result in undefined.
TrackableActionType
✓ import AnalyticsMiddleware from 'redux-action-analytics-middleware'
TrackableActionType is a type alias (string) used internally; it is not exported. Import only the default export.
Configures the analytics middleware with a simple console.log callback and a whitelist of action types, then creates a Redux store with it.
import AnalyticsMiddleware from 'redux-action-analytics-middleware'
import { createStore, applyMiddleware } from 'redux'
const trackCallback = (action, preState, postState) => {
console.log('Tracked action:', action)
console.log('State change:', preState, '->', postState)
}
const trackableActions = ['USER_LOGIN', 'PURCHASE_ITEM']
const middleware = AnalyticsMiddleware({
trackCallback,
trackableActions
})
const reducer = (state = { count: 0 }, action) => {
switch (action.type) {
case 'INCREMENT':
return { ...state, count: state.count + 1 }
default:
return state
}
}
const store = createStore(reducer, applyMiddleware(middleware))
store.dispatch({ type: 'USER_LOGIN' }) // Triggers analytics
store.dispatch({ type: 'INCREMENT' }) // Not tracked
Errors
Common errors & fixes
AnalyticsMiddleware is not a function
The import statement used named import instead of default import.
fixChange to: import AnalyticsMiddleware from 'redux-action-analytics-middleware'
Cannot read property 'type' of undefined in trackCallback
The trackableActions array is empty or the action type does not match any whitelisted type.
fixEnsure trackableActions contains the exact action type strings and that the dispatched action has a 'type' property.
TypeError: preActionState is not an object
The middleware is applied incorrectly or the reducer returns a non-object state (e.g., null or primitive).
fixMake sure the reducer returns an object and the middleware is properly passed to applyMiddleware.
Audit
Dependencies
No dependency data recorded yet.