1 | "use strict";
|
2 |
|
3 | require("core-js/modules/es.function.bind");
|
4 |
|
5 | require("core-js/modules/es.object.define-property");
|
6 |
|
7 | require("core-js/modules/es.object.to-string");
|
8 |
|
9 | require("core-js/modules/es.promise");
|
10 |
|
11 | require("core-js/modules/es.reflect.apply");
|
12 |
|
13 | Object.defineProperty(exports, "__esModule", {
|
14 | value: true
|
15 | });
|
16 | exports["default"] = trackEventMethodDecorator;
|
17 |
|
18 | var _makeClassMemberDecorator = _interopRequireDefault(require("./makeClassMemberDecorator"));
|
19 |
|
20 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
21 |
|
22 | function trackEventMethodDecorator() {
|
23 | var trackingData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
24 | return (0, _makeClassMemberDecorator["default"])(function (decoratedFn) {
|
25 | return function decorateClassMember() {
|
26 | var _this = this;
|
27 |
|
28 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
29 | args[_key] = arguments[_key];
|
30 | }
|
31 |
|
32 | var trackEvent = function trackEvent() {
|
33 | if (_this.props && _this.props.tracking && typeof _this.props.tracking.trackEvent === 'function') {
|
34 | for (var _len2 = arguments.length, promiseArguments = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
35 | promiseArguments[_key2] = arguments[_key2];
|
36 | }
|
37 |
|
38 | var thisTrackingData = typeof trackingData === 'function' ? trackingData(_this.props, _this.state, args, promiseArguments) : trackingData;
|
39 |
|
40 | if (thisTrackingData) {
|
41 | _this.props.tracking.trackEvent(thisTrackingData);
|
42 | }
|
43 | }
|
44 | };
|
45 |
|
46 | var fn = Reflect.apply(decoratedFn, this, args);
|
47 |
|
48 | if (Promise && Promise.resolve(fn) === fn) {
|
49 | return fn.then(trackEvent.bind(this))["catch"](function (error) {
|
50 | trackEvent(null, error);
|
51 | throw error;
|
52 | });
|
53 | }
|
54 |
|
55 | trackEvent();
|
56 | return fn;
|
57 | };
|
58 | });
|
59 | } |
\ | No newline at end of file |