@shopgate/tracking-core 7.29.9 → 7.30.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,89 +1,194 @@
1
- function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}import{SGAction}from"../helpers/helper";/**
1
+ import { SGAction } from "../helpers/helper";
2
+
3
+ /**
2
4
  * Handler for the communication between the tracking plugins and the app.
3
- */var AppHandler=/*#__PURE__*/function(){function AppHandler(){_classCallCheck(this,AppHandler);}return _createClass(AppHandler,[{key:"viewContent",value:/**
5
+ */
6
+ let AppHandler = /*#__PURE__*/function () {
7
+ function AppHandler() {}
8
+ var _proto = AppHandler.prototype;
9
+ /**
4
10
  * Log a pageview
5
11
  *
6
12
  * @param {UnifiedPageview} data Tracking data for this event
7
13
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
8
14
  * @returns {AppHandler} Instance of SgTrackingAppHandler
9
- */function viewContent(data,restrictions){SGAction.analyticsLogPageview(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
15
+ */
16
+ _proto.viewContent = function viewContent(data, restrictions) {
17
+ SGAction.analyticsLogPageview(AppHandler.prepareTrackingData(data, restrictions));
18
+ return this;
19
+ }
20
+
21
+ /**
10
22
  * AnalyticsLogEvent
11
23
  * @param {UnifiedPageview} data Tracking data for this event
12
24
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
13
25
  * @returns {AppHandler} Instance of SgTrackingAppHandler
14
- */},{key:"logEvent",value:function logEvent(data,restrictions){SGAction.analyticsLogEvent(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
26
+ */;
27
+ _proto.logEvent = function logEvent(data, restrictions) {
28
+ SGAction.analyticsLogEvent(AppHandler.prepareTrackingData(data, restrictions));
29
+ return this;
30
+ }
31
+
32
+ /**
15
33
  * Log a purchase
16
34
  *
17
35
  * @param {UnifiedPurchase} data Tracking data for this event
18
36
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
19
37
  * @returns {AppHandler} Instance of SgTrackingAppHandler
20
- */},{key:"purchase",value:function purchase(data,restrictions){SGAction.analyticsLogPurchase(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
38
+ */;
39
+ _proto.purchase = function purchase(data, restrictions) {
40
+ SGAction.analyticsLogPurchase(AppHandler.prepareTrackingData(data, restrictions));
41
+ return this;
42
+ }
43
+
44
+ /**
21
45
  * Log when a product was added to the cart
22
46
  *
23
47
  * @param {UnifiedAddToCart} data Tracking data for this event
24
48
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
25
49
  * @returns {AppHandler} Instance of SgTrackingAppHandler
26
- */},{key:"addToCart",value:function addToCart(data,restrictions){SGAction.analyticsLogAddToCart(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
50
+ */;
51
+ _proto.addToCart = function addToCart(data, restrictions) {
52
+ SGAction.analyticsLogAddToCart(AppHandler.prepareTrackingData(data, restrictions));
53
+ return this;
54
+ }
55
+
56
+ /**
27
57
  * Log when a payment info was added
28
58
  *
29
59
  * @param {UnifiedPaymentInfo} data Tracking data for this event
30
60
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
31
61
  * @returns {AppHandler} Instance of SgTrackingAppHandler
32
- */},{key:"addedPaymentInfo",value:function addedPaymentInfo(data,restrictions){SGAction.analyticsLogAddedPaymentInfo(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
62
+ */;
63
+ _proto.addedPaymentInfo = function addedPaymentInfo(data, restrictions) {
64
+ SGAction.analyticsLogAddedPaymentInfo(AppHandler.prepareTrackingData(data, restrictions));
65
+ return this;
66
+ }
67
+
68
+ /**
33
69
  * Log when a payment info was selected
34
70
  *
35
71
  * @param {UnifiedPaymentInfo} data Tracking data for this event
36
72
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
37
73
  * @returns {AppHandler} Instance of SgTrackingAppHandler
38
- */},{key:"selectedPaymentInfo",value:function selectedPaymentInfo(data,restrictions){SGAction.analyticsLogAddedPaymentInfo(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
74
+ */;
75
+ _proto.selectedPaymentInfo = function selectedPaymentInfo(data, restrictions) {
76
+ SGAction.analyticsLogAddedPaymentInfo(AppHandler.prepareTrackingData(data, restrictions));
77
+ return this;
78
+ }
79
+
80
+ /**
39
81
  * Log when a checkout is initiated
40
82
  *
41
83
  * @param {UnifiedInitiatedCheckout} data Tracking data for this event
42
84
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
43
85
  * @returns {AppHandler} Instance of SgTrackingAppHandler
44
- */},{key:"initiatedCheckout",value:function initiatedCheckout(data,restrictions){SGAction.analyticsLogInitiatedCheckout(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
86
+ */;
87
+ _proto.initiatedCheckout = function initiatedCheckout(data, restrictions) {
88
+ SGAction.analyticsLogInitiatedCheckout(AppHandler.prepareTrackingData(data, restrictions));
89
+ return this;
90
+ }
91
+
92
+ /**
45
93
  * Log if a registration was completed
46
94
  *
47
95
  * @param {UnifiedCompletedRegistration} data Tracking data for this event
48
96
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
49
97
  * @returns {AppHandler} Instance of SgTrackingAppHandler
50
- */},{key:"completedRegistration",value:function completedRegistration(data,restrictions){SGAction.analyticsLogCompletedRegistration(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
98
+ */;
99
+ _proto.completedRegistration = function completedRegistration(data, restrictions) {
100
+ SGAction.analyticsLogCompletedRegistration(AppHandler.prepareTrackingData(data, restrictions));
101
+ return this;
102
+ }
103
+
104
+ /**
51
105
  * Log when a product was added to the wishlist
52
106
  *
53
107
  * @param {UnifiedAddToWishlist} data Tracking data for this event
54
108
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
55
109
  * @returns {AppHandler} Instance of SgTrackingAppHandler
56
- */},{key:"addToWishlist",value:function addToWishlist(data,restrictions){SGAction.analyticsLogAddToWishlist(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
110
+ */;
111
+ _proto.addToWishlist = function addToWishlist(data, restrictions) {
112
+ SGAction.analyticsLogAddToWishlist(AppHandler.prepareTrackingData(data, restrictions));
113
+ return this;
114
+ }
115
+
116
+ /**
57
117
  * Log when a search happened
58
118
  *
59
119
  * @param {UnifiedSearched} data Tracking data for this event
60
120
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
61
121
  * @returns {AppHandler} Instance of SgTrackingAppHandler
62
- */},{key:"search",value:function search(data,restrictions){SGAction.analyticsLogSearch(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
122
+ */;
123
+ _proto.search = function search(data, restrictions) {
124
+ SGAction.analyticsLogSearch(AppHandler.prepareTrackingData(data, restrictions));
125
+ return this;
126
+ }
127
+
128
+ /**
63
129
  * Log when Deeplink and etc opened
64
130
  * @param {Object} data Tracking data for this event
65
131
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
66
132
  * @returns {AppHandler} Instance of SgTrackingAppHandler
67
- */},{key:"setCampaignWithUrl",value:function setCampaignWithUrl(data,restrictions){SGAction.analyticsSetCampaignWithUrl(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
133
+ */;
134
+ _proto.setCampaignWithUrl = function setCampaignWithUrl(data, restrictions) {
135
+ SGAction.analyticsSetCampaignWithUrl(AppHandler.prepareTrackingData(data, restrictions));
136
+ return this;
137
+ }
138
+
139
+ /**
68
140
  * Log an itemview
69
141
  *
70
142
  * @param {UnifiedItemView} data Tracking data for this event
71
143
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
72
144
  * @returns {AppHandler} Instance of SgTrackingAppHandler
73
- */},{key:"itemView",value:function itemView(data,restrictions){SGAction.analyticsLogItemView(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
145
+ */;
146
+ _proto.itemView = function itemView(data, restrictions) {
147
+ SGAction.analyticsLogItemView(AppHandler.prepareTrackingData(data, restrictions));
148
+ return this;
149
+ }
150
+
151
+ /**
74
152
  * Log a login
75
153
  *
76
154
  * @param {UnifiedLogin} data Tracking data for this event
77
155
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
78
156
  * @returns {AppHandler} Instance of SgTrackingAppHandler
79
- */},{key:"login",value:function login(data,restrictions){SGAction.analyticsLogLogin(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
157
+ */;
158
+ _proto.login = function login(data, restrictions) {
159
+ SGAction.analyticsLogLogin(AppHandler.prepareTrackingData(data, restrictions));
160
+ return this;
161
+ }
162
+
163
+ /**
80
164
  * Add the properties restriction, blacklist and trackers to the tracking event data if needed
81
165
  *
82
166
  * @param {Object} data The tracking event data
83
167
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
84
168
  * @returns {Object} Tracking data with restrictions
85
169
  * @private
86
- */}],[{key:"prepareTrackingData",value:function prepareTrackingData(data,restrictions){// Clone the data to avoid issues with references.
87
- var clonedData=_extends({},data);if(restrictions&&restrictions.trackers){var trackerParamName='trackers';// There is a Bug in the iOS app. Lib Version <= 9.0 expects "tracker" as the param name.
88
- if(window.LibShopgateClient&&window.LibShopgateClient.isIos()&&window.LibShopgateVersion&&window.LibShopgateVersion.isLibVersionAtMost(9)){trackerParamName='tracker';}// Add the restrictions to the tracking event data.
89
- clonedData.restrictions=_defineProperty({blacklist:restrictions.blacklist},trackerParamName,restrictions.trackers);}return clonedData;}}]);}();export default new AppHandler();
170
+ */;
171
+ AppHandler.prepareTrackingData = function prepareTrackingData(data, restrictions) {
172
+ // Clone the data to avoid issues with references.
173
+ const clonedData = {
174
+ ...data
175
+ };
176
+ if (restrictions && restrictions.trackers) {
177
+ let trackerParamName = 'trackers';
178
+
179
+ // There is a Bug in the iOS app. Lib Version <= 9.0 expects "tracker" as the param name.
180
+ if (window.LibShopgateClient && window.LibShopgateClient.isIos() && window.LibShopgateVersion && window.LibShopgateVersion.isLibVersionAtMost(9)) {
181
+ trackerParamName = 'tracker';
182
+ }
183
+
184
+ // Add the restrictions to the tracking event data.
185
+ clonedData.restrictions = {
186
+ blacklist: restrictions.blacklist,
187
+ [trackerParamName]: restrictions.trackers
188
+ };
189
+ }
190
+ return clonedData;
191
+ };
192
+ return AppHandler;
193
+ }();
194
+ export default new AppHandler();