Retracked wraps your event recording system in an API optimized for React components.
Somewhere early in execution:
# set the recording function
retracked.setup(myTrackingSystem.push);
In a parent component to set tracking context:
childContextTypes: {
track: React.PropTypes.func,
},
getChildContext: function() {
return {
track: Retracked.makeTracker({
namespace: 'course.welcome_page',
include: {
'course_id': () => this.props.course.get('id'),
'course_slug': () => this.props.course.get('slug'),
}
})
};
},
Then when you want to track events:
render() {
this.context.track('Foo_rendered');
or for a handler:
<a
onClick={this.context.track.handle('instructor_link.click', {'instructor_id': instructor.id})}