Releases: nytimes/react-tracking
v5.5.3
v5.5.2
v5.5.1
v5.5.0 - Now on Babel 7
Thanks to @damassi in #94 react-tracking now uses Babel 7
6bf2c3a Upgrade to babel 7 (#94)
759879f Update deepmerge, fix vulns (#96)
698e18c Fix lint (#95)
59c45f1 (damassi/master) Update README.md
a4a74db Fix test as a result of enzyme upgrade
81feee0 Update deps
c922ca4 Update README.md (typo) (#90)
v5.4.1
v5.4.0 - Now supports Promises/Async methods
Thanks to @spencewood in #82 react-tracking now supports async
functions (or functions that return a Promise
)
@track()
async handleEvent() {
return await asyncCall(); // returns a promise
}
See the main README documentation for more details, including how to conditionally dispatch a tracking event only when the promise resolves and/or rejects.
v5.3.0
v5.2.1 - Swap lodash.merge for deepmerge
Thanks to @dortzur in #62 Now uses deepmerge for a ~65% smaller bundle size! π
v5.1.0 - Updating props now properly changes tracking data
Before #60 by @tanhauhau changes to props on intermediate components would not be updated when descendent components fired off tracking events. They would instead use the values that they were initialized with. They now properly update as their props update.
This is a bit of an edge case, but the usage feels natural enough that it makes sense to fix. It should not affect any current semantics or API. Take a look at the test cases added as part of the PR ( #60 ) for an example.
Much thanks to @tanhauhau for finding and fixing this bug! π
v5.0.0 - State now available to decorated class methods
New Feature (Breaking Change)
Thanks to @mennenia in #45 π
The signature of decorated class methods changes from:
(props, args) => { }
to:
(props, state, args) => { }
This is so that you can access Class runtime state information within the decorator, like so:
// Reminder, to decorate class methods, you need to decorate the class itself
@track()
export default class FooButton extends React.Component {
// In this case the tracking data depends on
// some unknown (until runtime) value (state and event)
@track((props, state, [event]) => ({
action: 'click',
inModal: state.isModalShowing,
label: event.currentTarget.title || event.currentTarget.textContent
}))
handleClick = (event) => {
if (this.props.onClick) {
this.props.onClick(event);
}
}
render() {
return (
<button onClick={this.handleClick}>
{this.props.children}
</button>
);
}
}
NOTE: This was technically possible in previous versions, but required you to use the imperative this.props.tracking.trackEvent()
API so that you had access to Class state, this.state
. Now it's possible to keep the tracking logic declaratively in the decorator thanks to @mennenia ! πͺ