@shopgate/tracking-core 7.30.0-alpha.7 → 7.30.0-alpha.9

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,191 @@
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
+ class AppHandler {
7
+ /**
4
8
  * Log a pageview
5
9
  *
6
10
  * @param {UnifiedPageview} data Tracking data for this event
7
11
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
8
12
  * @returns {AppHandler} Instance of SgTrackingAppHandler
9
- */function viewContent(data,restrictions){SGAction.analyticsLogPageview(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
13
+ */
14
+ viewContent(data, restrictions) {
15
+ SGAction.analyticsLogPageview(AppHandler.prepareTrackingData(data, restrictions));
16
+ return this;
17
+ }
18
+
19
+ /**
10
20
  * AnalyticsLogEvent
11
21
  * @param {UnifiedPageview} data Tracking data for this event
12
22
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
13
23
  * @returns {AppHandler} Instance of SgTrackingAppHandler
14
- */},{key:"logEvent",value:function logEvent(data,restrictions){SGAction.analyticsLogEvent(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
24
+ */
25
+ logEvent(data, restrictions) {
26
+ SGAction.analyticsLogEvent(AppHandler.prepareTrackingData(data, restrictions));
27
+ return this;
28
+ }
29
+
30
+ /**
15
31
  * Log a purchase
16
32
  *
17
33
  * @param {UnifiedPurchase} data Tracking data for this event
18
34
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
19
35
  * @returns {AppHandler} Instance of SgTrackingAppHandler
20
- */},{key:"purchase",value:function purchase(data,restrictions){SGAction.analyticsLogPurchase(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
36
+ */
37
+ purchase(data, restrictions) {
38
+ SGAction.analyticsLogPurchase(AppHandler.prepareTrackingData(data, restrictions));
39
+ return this;
40
+ }
41
+
42
+ /**
21
43
  * Log when a product was added to the cart
22
44
  *
23
45
  * @param {UnifiedAddToCart} data Tracking data for this event
24
46
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
25
47
  * @returns {AppHandler} Instance of SgTrackingAppHandler
26
- */},{key:"addToCart",value:function addToCart(data,restrictions){SGAction.analyticsLogAddToCart(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
48
+ */
49
+ addToCart(data, restrictions) {
50
+ SGAction.analyticsLogAddToCart(AppHandler.prepareTrackingData(data, restrictions));
51
+ return this;
52
+ }
53
+
54
+ /**
27
55
  * Log when a payment info was added
28
56
  *
29
57
  * @param {UnifiedPaymentInfo} data Tracking data for this event
30
58
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
31
59
  * @returns {AppHandler} Instance of SgTrackingAppHandler
32
- */},{key:"addedPaymentInfo",value:function addedPaymentInfo(data,restrictions){SGAction.analyticsLogAddedPaymentInfo(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
60
+ */
61
+ addedPaymentInfo(data, restrictions) {
62
+ SGAction.analyticsLogAddedPaymentInfo(AppHandler.prepareTrackingData(data, restrictions));
63
+ return this;
64
+ }
65
+
66
+ /**
33
67
  * Log when a payment info was selected
34
68
  *
35
69
  * @param {UnifiedPaymentInfo} data Tracking data for this event
36
70
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
37
71
  * @returns {AppHandler} Instance of SgTrackingAppHandler
38
- */},{key:"selectedPaymentInfo",value:function selectedPaymentInfo(data,restrictions){SGAction.analyticsLogAddedPaymentInfo(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
72
+ */
73
+ selectedPaymentInfo(data, restrictions) {
74
+ SGAction.analyticsLogAddedPaymentInfo(AppHandler.prepareTrackingData(data, restrictions));
75
+ return this;
76
+ }
77
+
78
+ /**
39
79
  * Log when a checkout is initiated
40
80
  *
41
81
  * @param {UnifiedInitiatedCheckout} data Tracking data for this event
42
82
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
43
83
  * @returns {AppHandler} Instance of SgTrackingAppHandler
44
- */},{key:"initiatedCheckout",value:function initiatedCheckout(data,restrictions){SGAction.analyticsLogInitiatedCheckout(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
84
+ */
85
+ initiatedCheckout(data, restrictions) {
86
+ SGAction.analyticsLogInitiatedCheckout(AppHandler.prepareTrackingData(data, restrictions));
87
+ return this;
88
+ }
89
+
90
+ /**
45
91
  * Log if a registration was completed
46
92
  *
47
93
  * @param {UnifiedCompletedRegistration} data Tracking data for this event
48
94
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
49
95
  * @returns {AppHandler} Instance of SgTrackingAppHandler
50
- */},{key:"completedRegistration",value:function completedRegistration(data,restrictions){SGAction.analyticsLogCompletedRegistration(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
96
+ */
97
+ completedRegistration(data, restrictions) {
98
+ SGAction.analyticsLogCompletedRegistration(AppHandler.prepareTrackingData(data, restrictions));
99
+ return this;
100
+ }
101
+
102
+ /**
51
103
  * Log when a product was added to the wishlist
52
104
  *
53
105
  * @param {UnifiedAddToWishlist} data Tracking data for this event
54
106
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
55
107
  * @returns {AppHandler} Instance of SgTrackingAppHandler
56
- */},{key:"addToWishlist",value:function addToWishlist(data,restrictions){SGAction.analyticsLogAddToWishlist(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
108
+ */
109
+ addToWishlist(data, restrictions) {
110
+ SGAction.analyticsLogAddToWishlist(AppHandler.prepareTrackingData(data, restrictions));
111
+ return this;
112
+ }
113
+
114
+ /**
57
115
  * Log when a search happened
58
116
  *
59
117
  * @param {UnifiedSearched} data Tracking data for this event
60
118
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
61
119
  * @returns {AppHandler} Instance of SgTrackingAppHandler
62
- */},{key:"search",value:function search(data,restrictions){SGAction.analyticsLogSearch(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
120
+ */
121
+ search(data, restrictions) {
122
+ SGAction.analyticsLogSearch(AppHandler.prepareTrackingData(data, restrictions));
123
+ return this;
124
+ }
125
+
126
+ /**
63
127
  * Log when Deeplink and etc opened
64
128
  * @param {Object} data Tracking data for this event
65
129
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
66
130
  * @returns {AppHandler} Instance of SgTrackingAppHandler
67
- */},{key:"setCampaignWithUrl",value:function setCampaignWithUrl(data,restrictions){SGAction.analyticsSetCampaignWithUrl(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
131
+ */
132
+ setCampaignWithUrl(data, restrictions) {
133
+ SGAction.analyticsSetCampaignWithUrl(AppHandler.prepareTrackingData(data, restrictions));
134
+ return this;
135
+ }
136
+
137
+ /**
68
138
  * Log an itemview
69
139
  *
70
140
  * @param {UnifiedItemView} data Tracking data for this event
71
141
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
72
142
  * @returns {AppHandler} Instance of SgTrackingAppHandler
73
- */},{key:"itemView",value:function itemView(data,restrictions){SGAction.analyticsLogItemView(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
143
+ */
144
+ itemView(data, restrictions) {
145
+ SGAction.analyticsLogItemView(AppHandler.prepareTrackingData(data, restrictions));
146
+ return this;
147
+ }
148
+
149
+ /**
74
150
  * Log a login
75
151
  *
76
152
  * @param {UnifiedLogin} data Tracking data for this event
77
153
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
78
154
  * @returns {AppHandler} Instance of SgTrackingAppHandler
79
- */},{key:"login",value:function login(data,restrictions){SGAction.analyticsLogLogin(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
155
+ */
156
+ login(data, restrictions) {
157
+ SGAction.analyticsLogLogin(AppHandler.prepareTrackingData(data, restrictions));
158
+ return this;
159
+ }
160
+
161
+ /**
80
162
  * Add the properties restriction, blacklist and trackers to the tracking event data if needed
81
163
  *
82
164
  * @param {Object} data The tracking event data
83
165
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
84
166
  * @returns {Object} Tracking data with restrictions
85
167
  * @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();
168
+ */
169
+ static prepareTrackingData(data, restrictions) {
170
+ // Clone the data to avoid issues with references.
171
+ const clonedData = {
172
+ ...data
173
+ };
174
+ if (restrictions && restrictions.trackers) {
175
+ let trackerParamName = 'trackers';
176
+
177
+ // There is a Bug in the iOS app. Lib Version <= 9.0 expects "tracker" as the param name.
178
+ if (window.LibShopgateClient && window.LibShopgateClient.isIos() && window.LibShopgateVersion && window.LibShopgateVersion.isLibVersionAtMost(9)) {
179
+ trackerParamName = 'tracker';
180
+ }
181
+
182
+ // Add the restrictions to the tracking event data.
183
+ clonedData.restrictions = {
184
+ blacklist: restrictions.blacklist,
185
+ [trackerParamName]: restrictions.trackers
186
+ };
187
+ }
188
+ return clonedData;
189
+ }
190
+ }
191
+ export default new AppHandler();