@lunrdigital/react-tracker
v1.0.1
Published
Component level tracking using context
Downloads
4
Readme
react-tracker
Component level tracking using context
Examples
import {withTracker, useTracker} from '@lunrdigital/react-tracker';
const Component = () => {
const { track } = useTracker();
return (
<button onClick={() => track('Button click')}>Track</button>
);
};
const TrackedComponent = withTracker(Component, 'Default Category');
<TrackedComponent />
<TrackedComponent tracking-category="Overidden Category" />
import {withTracker, useTracker} from '@lunrdigital/react-tracker';
const Nested = () => {
const { track } = useTracker();
return (
<button onClick={() => track('Nested button click')}>Track</button>
);
};
const Component = () => {
const { track } = useTracker();
return (
<button onClick={() => track('Button click')}>Track</button>
);
};
const TrackedComponent = withTracker(Component, 'Default Category');
<TrackedComponent />
<TrackedComponent tracking-category="Overidden Category" />