Releases: nytimes/react-tracking
v9.3.2
What's Changed
- Fix compatibility issue with React Native environment by @kimskovhusandersen in #220
New Contributors
- @kimskovhusandersen made their first contribution in #220
Full Changelog: v9.3.1...v9.3.2
v9.3.1
What's Changed
- Re-enable support for Node 16.9+ by @nathanchapman in #215
New Contributors
- @nathanchapman made their first contribution in #215
Full Changelog: v9.3.0...v9.3.1
v9.3.0 - `mergeOptions` added
New Features
- feat: Add mergeOptions config option by @BenLorantfy in #187
You can now pass in mergeOptions as part of your config option to control exactly how react-tracking merges your tracking objects.
Example using isMergeableObject:
const { Track } = useTracking({}, { mergeOptions: { isMergeableObject: obj => !(obj instanceof Error) } });
Thanks @BenLorantfy for the implementation in #187 and @tizmagik for the documentation in #212
What's Changed
- chore: create .nvmrc, add engines field by @glebpigulevsky in #205
- chore: upgrade husky@8 and lint-staged@13 by @chimurai in #206
- test: Enhance e2e test suite by @tizmagik in #208
- chore: Drop node 12, add node 18 by @tizmagik in #210
- chore: Update dependencies by @tizmagik in #209
- docs: Document
mergeOptions
by @tizmagik in #212
New Contributors
- @glebpigulevsky made their first contribution in #205
- @chimurai made their first contribution in #206
- @BenLorantfy made their first contribution in #187
Full Changelog: v9.2.1...v9.3.0
v9.2.1 - React 18 peerDep
Added React 18 as an acceptable peerDep, thanks @AnthonyCrowcroft in #203
v9.2.0 - deepmerge re-export
v9.1.0 - New Debug Feature
Notable: New Debug Feature
π Thanks to @bgergen in #193 we now display a useful debug value when inspecting tracked components in the React Devtools
What's Changed
- Update drone yml to reference main by @bgergen in #184
- Add options.process caveat to readme by @bgergen in #192
- Take advantage of useDebugValue to display data in devtools by @bgergen in #193
Full Changelog: v9.0.0...v9.1.0
v9.0.0
No new features but this version drops core-js for a smaller build. Now polyfills are left up to userland which follows community best practices. See #167
Many thanks to @adi518 for kicking off this work π and the support from @antciccone @gedeagas and @bgergen π
v8.1.0 - Full React Hooks support
Thanks to @bgergen in #168 and #171 (testing support from @tizmagik in #165 and #170 ) react-tracking now fully supports React Hooks for all features (e.g. Hooks can be used completely instead of, or in addition to, the HoC/decorator API).
import { useTracking } from 'react-tracking';
const FooPage = () => {
const { Track, trackEvent } = useTracking({ page: 'FooPage' });
return (
<Track>
<div
onClick={() => {
trackEvent({ action: 'click' });
}}
/>
</Track>
);
};
See the full docs in the main README starting here.
v8.0.0 - forwardRef support
Added forwardRef support in #153 thanks to @ParadeTo π . If you'd like to access the internal ref
of a tracked component, just add the forwardRef option as part of the second param options object:
@track({}, { forwardRef: true })
Technically the API surface has not changed, we just added a new forwardRef: bool
option. But React docs recommend bumping semver major when introducing such a change.
Example:
const focusFn = () => {};
@track({}, { forwardRef: true })
class Child extends React.Component {
focus = focusFn;
render() {
return 'child';
}
}
class Parent extends React.Component {
componentDidMount() {
this.child.focus();
}
render() {
return (
<Child
ref={el => {
this.child = el;
}}
/>
);
}
}
v7.3.0
Fixed
2 closely related fixed having to do with decorating async methods:
Fixed by @rickh18 in #147 we now correctly return the underlying decorated method when decorating async functions (or functions that return promises).
Fixed by @tizmagik in #149 we now call trackEvent with an empty object {}
instead of null
so as not to throw TypeErrors in case userland is destructuring on the decorator, e.g. this method signature works fine now, even in the event of an error:
@track((props, state, methodArgs, [{ value }, err]) => {
return {
status: err || value,
};
})
handleAsyncAction = async () => {
return Math.random() > 0.5
? Promise.resolve({ value: 'some value' })
: Promise.reject(new Error('some error'));
};
Minor changes
Fixed by @bgergen in #146 we now no longer export TrackingContextType
since we switched to the new React Context API. This export was unlikely to be used in userland anyway so we kept this a semver minor instead of semver major.