-
Notifications
You must be signed in to change notification settings - Fork 131
Open
Labels
Description
First of all really appreciate the effort on making this library and it saves me a lot of time to implement my own version.
The way I use react-tracking is like the following:
export function tracking(trackingInfo) {
const options = {
dispatch: (data) => {
// send out data to tracking service
},
dispatchOnMount: true
};
return function decorator(...toDecorate) {
const name = annotate(trackingInfo.name);
return track(Object.assign({}, trackingInfo, { name }), options)(...toDecorate);
};
}
...
@tracking({ name: 'counter' })
class Counter extends Component {
@tracking({ name: 'increment' })
increment = () => {
// increment count in global redux state
this.props.dispatch({
type: 'INCREMENT'
})
}
}
i also attach a bunch of metadata from redux store to the optons.dispatch. The problem i'm seeing is that let's say if we have a redux state called count that's going to add 1 everytime increment is fired. react-tracking will always attach the old count as part of metadata instead of count + 1 after increment is fired. I'm assuming this is because react-tracking dispatches first before it actually fires the decorated function? So curious is there anyway around? Thanks and looking forward to any help here!