@workpop/redux-tracer
v0.1.2
Published
Create New Relic Tracers and bind them to React Components
Downloads
3
Readme
redux-tracer
Installation
yarn add @workpop/redux-tracer
API
createTracer
type CreateTracerType = {
invariant?: Function,
tracerName: string,
// Custom Attributes you want to seet in new relic
customAttributes: Object,
log: Function,
}
getNRTracer(state: Object, tracerName: string)
clearTracer(tracerName: string)
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