Releases: nytimes/react-tracking
v4.2.1
v4.2.0 - TrackingPropType and TrackingContextType
In #39 we now export two different proptypes:
TrackingPropType
(new) - This is a proptype you can use for decorated components.TrackingContextType
(renamed) - This is a context proptype you can use if you want to pick offcontext
(this was previously named "TrackingPropType" which would be confusing with the new proptype mentioned above).
v4.1.0 - Available on npm
Same as v4.0.0 but now published to npm as react-tracking
🎉
v4.0.0 - New default dispatch() behavior
Breaking Change
In #35 the default dispatch behavior of emitting a CustomEvent has been removed in favor of pushing tracking objects to window.dataLayer[]
. This is a good default for most pass that use Google Tag Manager for tracking.
If you had previously been relying on CustomEvent, you will need to now import that module into your project and define the call to CustomEvent as your new overriding dispatch()
function on some top-level component. See the main README for details.
If you had previously been defining dispatch()
on some top-level component, then this is not a breaking change from your perspective because any overriding dispatch function declaration will be used instead of the default behavior.
v3.0.0 - New `tracking` prop
New Feature
In #31 we now expose a single tracking
prop that looks like:
{
// tracking prop provided by @track()
tracking: PropTypes.shape({
// function to call to dispatch tracking events
trackEvent: PropTypes.func,
// function to call to grab contextual tracking data
getTrackingData: PropTypes.func,
})
}
This is so that you can grab the contextual tracking data if you need it by calling props.tracking.getTrackingData()
. The previous props.trackEvent()
is now props.tracking.trackEvent()
.
Breaking Changes
props.trackEvent()
is now props.tracking.trackEvent()
v2.2.2
v2.2.1
v2.2.0 - New `process()` option
New Feature
options.process()
( #27 ) can now be defined to selectively dispatch a tracking event when any decorated component mounts, based on the tracking object for each component. This will help clean up the verbosity that's currently required to dispatch PageView events using dispatchOnMount()
previously.
See the README for more details.
v2.1.1
v2.1.0
New Features
options.dispatchOnMount()
as a function (#20) - You can now provide a function instead of just a boolean for dispatchOnMount
. The function provided will be called with a single argument, all of the context tracking data in the app. You can chose to ignore this in order to dispatch exactly the object you want when the component you are decorating mounts (in componentDidMount()
).
See the README for example usage.