Releases: nytimes/react-tracking
v7.2.1
v7.2.0
Thanks to @bgergen in #142 react-tracking now uses React Hooks under the hood 🎉
This means better compatibility with libraries that use the Legacy Context API and helps pave the way for more advanced feature support in the useTracking()
hook (E.g. allowing for adding to the tracking context via the hook without having to use the higher-order component/decorator, #138 ).
v7.1.0 - Performance upgrade
Performance upgrade
Thanks to @BRKalow and @jacekradko in #129 react-tracking now makes better use of the context API to avoid unnecessary re-renders. If you're on v6 or above, be sure to upgrade! 🔥
Other changes in this release:
- We no longer export
ReactTrackingContext
, user-land shouldn't need this export given theuseTracking
hook andtrack
higher-order component (please open an issue if you have a use case!) - In addition to the default export, you can now also
import { track } from 'react-tracking';
v7.0.2
v7.0.1
v7.0.0 - React Hooks support
2 Breaking Changes, although the syntax/API has not changed:
New Feature: React Hooks
Thanks to @damassi in #124 we now support React Hooks 🎉
import { useTracking } from 'react-tracking';
const SomeChild = () => {
const tracking = useTracking();
return (
<div
onClick={() => {
tracking.trackEvent({ action: 'click' });
}}
/>
);
};
useTracking
returns the same { getTrackingData, trackEvent }
methods that the @track()
wrapper injects into props (as props.tracking
). For now, you still need to use the wrapper in order to add contextual tracking data.
Technically the syntax is backwards compatible, but because of our use of React Hooks we now require React >
v16.8
, hence the breaking change.
peerDependencies Update: core-js@3
Thanks to @mckernanin in #125 we've upgraded our babel and core-js dependencies.
For more on this upgrade and how this might affect your app's build/configuration, please see: https://github.com/zloirock/core-js/blob/master/docs/2019-03-19-core-js-3-babel-and-a-look-into-the-future.md
Again, syntax is backwards compatible, but peerDeps now specified an update to core-js@3 if you didn't already have it.
v6.0.0 - Use new React Context API
There are no breaking API changes, but we now use the new React Context API under the hood so the minimum React version is now 16.3+
If you're on an old version of React (<16.3) you can still use react-tracking v5.7.x
v5.7.0
v5.6.0
Thanks to @williardx in #105 we now avoid dispatching a tracking event when your decorated class member tracking call returns a falsy value:
@track({ module: 'button' })
class Thing extends Component {
@track(() => {
// some logic that eventually returns:
return false; // won't dispatch
})
handleClick = () => { ... }
render() {
return <button onClick={this.handleClick}>Click me</button>
}
}