redux-tracer
Installation
yarn add @workpop/redux-tracer
API
type CreateTracerType = {
invariant?: Function,
tracerName: string,
customAttributes: Object,
log: Function,
}
Basic Usage
1.Setup in combineReducers
import { createStore } from 'redux';
import { newRelicTracerReducer } from '@workpop/redux-tracer';
...
const store = createStore({
...reducers,
newRelicTracerReducer,
});
- Dispatch createTracer action
import { createTracer } from '@workpop/redux-tracer';
store.dispatch(
createTracer({
tracerName: 'testTracer',
})
);
- Connect and execute tracer
import React from 'react';
import { connect } from 'react-redux';
import { getNRTracer } from '@workpop/redux-tracer';
function Test({ testTracer }) {
return <p onClick={function () { return testTracer(); }}>Hello</h1>
}
function mapStateToProps(state) {
return getNRTracer(state, 'testTracer');
}
export default connect(mapStateToProps)(Test)
License
MIT