1 | "use strict";
|
2 |
|
3 | require("core-js/modules/es.object.define-property");
|
4 |
|
5 | Object.defineProperty(exports, "__esModule", {
|
6 | value: true
|
7 | });
|
8 | exports["default"] = useTracking;
|
9 |
|
10 | var _react = require("react");
|
11 |
|
12 | var _withTrackingComponentDecorator = require("./withTrackingComponentDecorator");
|
13 |
|
14 | function useTracking() {
|
15 | var trackingContext = (0, _react.useContext)(_withTrackingComponentDecorator.ReactTrackingContext);
|
16 |
|
17 | if (!(trackingContext && trackingContext.tracking)) {
|
18 | throw new Error('Attempting to call `useTracking` ' + 'without a ReactTrackingContext present. Did you forget to wrap the top of ' + 'your component tree with `track`?');
|
19 | }
|
20 |
|
21 | return (0, _react.useMemo)(function () {
|
22 | return {
|
23 | getTrackingData: trackingContext.tracking.getTrackingData,
|
24 | trackEvent: trackingContext.tracking.dispatch
|
25 | };
|
26 | }, [trackingContext.tracking.getTrackingData, trackingContext.tracking.dispatch]);
|
27 | } |
\ | No newline at end of file |