@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.
package/core/Core.js CHANGED
@@ -1,87 +1,229 @@
1
- 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;}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;}import{logger}from'@shopgate/pwa-core/helpers';import errorManager from'@shopgate/pwa-core/classes/ErrorManager';import{SOURCE_TRACKING,CODE_TRACKING}from'@shopgate/pwa-core/constants/ErrorManager';import{optOut as _optOut,isOptOut}from"../helpers/optOut";import trackingEvents,{REMOVE_TRACKER,ADD_TRACKER,scannerEvents}from"../helpers/events";/**
1
+ import { logger } from '@shopgate/pwa-core/helpers';
2
+ import errorManager from '@shopgate/pwa-core/classes/ErrorManager';
3
+ import { SOURCE_TRACKING, CODE_TRACKING } from '@shopgate/pwa-core/constants/ErrorManager';
4
+ import { optOut, isOptOut } from "../helpers/optOut";
5
+ import trackingEvents, { REMOVE_TRACKER, ADD_TRACKER, scannerEvents } from "../helpers/events";
6
+
7
+ /**
2
8
  * Core for our tracking system. Plugins can use the core to register for events. Pub/sub pattern.
3
- */var Core=/*#__PURE__*/function(){/**
9
+ */
10
+ class Core {
11
+ /**
4
12
  * Constructor
5
- */function Core(){var _this=this;_classCallCheck(this,Core);/**
6
- * Check if the opt-out state is set
7
- *
8
- * @returns {boolean} Information about the opt out state
9
- */_defineProperty(this,"isOptOut",function(){return isOptOut();});/**
10
- * Returns scanner (adscanner and QR) event action constants.
11
- *
12
- * @returns {Object} Scanner events
13
- */_defineProperty(this,"getScannerEvents",function(){return scannerEvents;});/**
14
- * Helper function to create ad scanner opt_label from pageTitle and pageId
15
- *
16
- * @param {string} pageTitle Name of the Page
17
- * @param {string} id ID of the ad
18
- * @returns {string} String from pageTitle and pageId
19
- */_defineProperty(this,"buildAdImageIdentifierName",function(pageTitle,id){var name=pageTitle?"".concat(pageTitle," "):'';return"".concat(name,"(id: ").concat(id,")");});/**
20
- * This function will handle the cross domain tracking, depending on which sdks are there
21
- * @param {string} originalUrl url of the link
22
- * @param {HTMLFormElement} [formElement] Form element if we do a POST
23
- * @returns {boolean|string} Tells if the function executed the steps that are necessary
24
- * for domain transitions via tracking plugins. In a sg cloud app it returns the new url.
25
- */_defineProperty(this,"crossDomainTracking",function(originalUrl,formElement){if(window.sgData&&window.sgData.device.access==='App'){return false;}var newUrl=originalUrl;// Add econda params
26
- if(typeof window.getEmosCrossUrlParams==='function'){newUrl+=(!newUrl.includes('?')?'?':'&')+window.getEmosCrossUrlParams();}// If there is no sgData, we are in sg cloud app and have to return the new url
27
- if(!window.sgData){return newUrl;}// Universal
28
- try{window.ga(function(){var tracker=window.ga.getByName('shopgate');var linker=new window.gaplugins.Linker(tracker);// Add ?_ga parameter to the url
29
- newUrl=linker.decorate(newUrl);});}catch(e){}// Ignore errors
30
- // Check if there is the classic sdk
31
- if(typeof _gaq==='undefined'){// No classic sdk
32
- if(formElement){/**
33
- * The no-param-reassign rule is deactivated on purpose,
34
- * since the form action has to be replaced in this situation
35
- */ // eslint-disable-next-line no-param-reassign
36
- formElement.action=newUrl;}else{window.location.href=newUrl;}}else if(formElement){// eslint-disable-next-line no-underscore-dangle
37
- window._gaq.push(['merchant_._linkByPost',formElement]);}else{// eslint-disable-next-line no-underscore-dangle
38
- window._gaq.push(['merchant_._link',newUrl]);}return true;});// Store for the registered events
39
- this.events={};// Store for all triggered events
40
- this.triggeredEvents=[];this.registerFinish=false;/**
13
+ */
14
+ constructor() {
15
+ /**
16
+ * Check if the opt-out state is set
17
+ *
18
+ * @returns {boolean} Information about the opt out state
19
+ */
20
+ this.isOptOut = () => isOptOut();
21
+ /**
22
+ * Returns scanner (adscanner and QR) event action constants.
23
+ *
24
+ * @returns {Object} Scanner events
25
+ */
26
+ this.getScannerEvents = () => scannerEvents;
27
+ /**
28
+ * Helper function to create ad scanner opt_label from pageTitle and pageId
29
+ *
30
+ * @param {string} pageTitle Name of the Page
31
+ * @param {string} id ID of the ad
32
+ * @returns {string} String from pageTitle and pageId
33
+ */
34
+ this.buildAdImageIdentifierName = (pageTitle, id) => {
35
+ const name = pageTitle ? `${pageTitle} ` : '';
36
+ return `${name}(id: ${id})`;
37
+ };
38
+ /**
39
+ * This function will handle the cross domain tracking, depending on which sdks are there
40
+ * @param {string} originalUrl url of the link
41
+ * @param {HTMLFormElement} [formElement] Form element if we do a POST
42
+ * @returns {boolean|string} Tells if the function executed the steps that are necessary
43
+ * for domain transitions via tracking plugins. In a sg cloud app it returns the new url.
44
+ */
45
+ this.crossDomainTracking = (originalUrl, formElement) => {
46
+ if (window.sgData && window.sgData.device.access === 'App') {
47
+ return false;
48
+ }
49
+ let newUrl = originalUrl;
50
+
51
+ // Add econda params
52
+ if (typeof window.getEmosCrossUrlParams === 'function') {
53
+ newUrl += (!newUrl.includes('?') ? '?' : '&') + window.getEmosCrossUrlParams();
54
+ }
55
+
56
+ // If there is no sgData, we are in sg cloud app and have to return the new url
57
+ if (!window.sgData) {
58
+ return newUrl;
59
+ }
60
+
61
+ // Universal
62
+ try {
63
+ window.ga(() => {
64
+ const tracker = window.ga.getByName('shopgate');
65
+ const linker = new window.gaplugins.Linker(tracker);
66
+ // Add ?_ga parameter to the url
67
+ newUrl = linker.decorate(newUrl);
68
+ });
69
+ } catch (e) {
70
+ // Ignore errors
71
+ }
72
+
73
+ // Check if there is the classic sdk
74
+ if (typeof _gaq === 'undefined') {
75
+ // No classic sdk
76
+
77
+ if (formElement) {
78
+ /**
79
+ * The no-param-reassign rule is deactivated on purpose,
80
+ * since the form action has to be replaced in this situation
81
+ */
82
+ // eslint-disable-next-line no-param-reassign
83
+ formElement.action = newUrl;
84
+ } else {
85
+ window.location.href = newUrl;
86
+ }
87
+ } else if (formElement) {
88
+ // eslint-disable-next-line no-underscore-dangle
89
+ window._gaq.push(['merchant_._linkByPost', formElement]);
90
+ } else {
91
+ // eslint-disable-next-line no-underscore-dangle
92
+ window._gaq.push(['merchant_._link', newUrl]);
93
+ }
94
+ return true;
95
+ };
96
+ // Store for the registered events
97
+ this.events = {};
98
+
99
+ // Store for all triggered events
100
+ this.triggeredEvents = [];
101
+ this.registerFinish = false;
102
+
103
+ /**
41
104
  * Storage for functions to register tracking event callbacks
42
105
  * @type {Object}
43
- */this.register={};// Create the register functions for every available event
44
- trackingEvents.forEach(function(event){/**
106
+ */
107
+ this.register = {};
108
+
109
+ // Create the register functions for every available event
110
+ trackingEvents.forEach(event => {
111
+ /**
45
112
  * Register for event
46
113
  * @param {Function} callback Function that is called if the event occurs
47
114
  * @param {Object} options Additional options
48
115
  * @returns {RemoveListener} Function to remove the listener
49
- */_this.register[event]=function(callback,options){return _this.registerHelper(callback,event,options);};});/**
116
+ */
117
+ this.register[event] = (callback, options) => this.registerHelper(callback, event, options);
118
+ });
119
+
120
+ /**
50
121
  * Storage for functions that trigger tracking events
51
122
  * @type {Object}
52
- */this.track={};// Create the track functions for every available event
53
- trackingEvents.forEach(function(event){// Don't create track functions for those events
54
- if([REMOVE_TRACKER,ADD_TRACKER].indexOf(event)!==-1){return;}/**
123
+ */
124
+ this.track = {};
125
+
126
+ // Create the track functions for every available event
127
+ trackingEvents.forEach(event => {
128
+ // Don't create track functions for those events
129
+ if ([REMOVE_TRACKER, ADD_TRACKER].indexOf(event) !== -1) {
130
+ return;
131
+ }
132
+
133
+ /**
55
134
  * Track event
56
135
  * @param {Object} rawData Raw data from sgData Object
57
136
  * @param {string} [page] Identifier of the page
58
137
  * @param {Object} [scope] Scope for the event
59
138
  * @param {Object} [state] The redux state
60
139
  * @returns {Core} Instance of Core
61
- */_this.track[event]=function(rawData,page,scope,state){return _this.notifyPlugins(_extends({},rawData),event,page,scope,state);};});}/**
140
+ */
141
+ this.track[event] = (rawData, page, scope, state) => this.notifyPlugins({
142
+ ...rawData
143
+ }, event, page, scope, state);
144
+ });
145
+ }
146
+
147
+ /**
62
148
  * Returns and creates event store if needed
63
149
  *
64
150
  * @param {string} eventName Name of the event
65
151
  * @param {string} [page] Identifier of the page
66
152
  * @returns {Object} The event store for the given eventName and page
67
- */return _createClass(Core,[{key:"getEventStore",value:function getEventStore(eventName,page){if(!this.events.hasOwnProperty(eventName)){// Create a new event store entry for the current event name, if no one is already present
68
- this.events[eventName]={// Events for every page
69
- global:[],// Events only for specific pages
70
- specific:{}};}// Get the global events for the current event name
71
- var eventStore=this.events[eventName].global;if(page){// A page name was provided, which means that we have to use the page specific sub store
72
- eventStore=this.events[eventName].specific;if(!eventStore.hasOwnProperty(page)){// There is no entry for the current page, so we initialize it
73
- eventStore[page]=[];}// Prepare the specific event store for the provided page as return value
74
- eventStore=eventStore[page];}return eventStore;}/**
153
+ */
154
+ getEventStore(eventName, page) {
155
+ if (!this.events.hasOwnProperty(eventName)) {
156
+ // Create a new event store entry for the current event name, if no one is already present
157
+ this.events[eventName] = {
158
+ // Events for every page
159
+ global: [],
160
+ // Events only for specific pages
161
+ specific: {}
162
+ };
163
+ }
164
+
165
+ // Get the global events for the current event name
166
+ let eventStore = this.events[eventName].global;
167
+ if (page) {
168
+ // A page name was provided, which means that we have to use the page specific sub store
169
+ eventStore = this.events[eventName].specific;
170
+ if (!eventStore.hasOwnProperty(page)) {
171
+ // There is no entry for the current page, so we initialize it
172
+ eventStore[page] = [];
173
+ }
174
+
175
+ // Prepare the specific event store for the provided page as return value
176
+ eventStore = eventStore[page];
177
+ }
178
+ return eventStore;
179
+ }
180
+
181
+ /**
75
182
  * Register a tracking event callback for a plugin
76
183
  *
77
184
  * @param {Function} callback Function that is called if the event occurs
78
185
  * @param {string} eventName Name of the event
79
186
  * @param {Object} options Additional options
80
187
  * @returns {RemoveListener} Function to remove the listener
81
- */},{key:"registerHelper",value:function registerHelper(callback,eventName){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var defaults={trackerName:'',page:null,merchant:true,shopgate:true,options:{}};var pluginOptions=_extends({},defaults,{},options);if(!pluginOptions.trackerName){logger.warn("'SgTrackingCore': Attempt to register for event \"".concat(eventName,"\" by a nameless tracker"));}// Get the correct store
82
- var store=this.getEventStore(eventName,pluginOptions.page);// Add the callback to queue
83
- var index=store.push({callback:callback,trackerName:pluginOptions.trackerName,useNativeSdk:pluginOptions.options.useNativeSdk,overrideUnified:pluginOptions.options.overrideUnified,merchant:pluginOptions.merchant,shopgate:pluginOptions.shopgate})-1;// Provide handle back for removal of event
84
- return{remove:function remove(){delete store[index];}};}/**
188
+ */
189
+ registerHelper(callback, eventName, options = {}) {
190
+ const defaults = {
191
+ trackerName: '',
192
+ page: null,
193
+ merchant: true,
194
+ shopgate: true,
195
+ options: {}
196
+ };
197
+ const pluginOptions = {
198
+ ...defaults,
199
+ ...options
200
+ };
201
+ if (!pluginOptions.trackerName) {
202
+ logger.warn(`'SgTrackingCore': Attempt to register for event "${eventName}" by a nameless tracker`);
203
+ }
204
+
205
+ // Get the correct store
206
+ const store = this.getEventStore(eventName, pluginOptions.page);
207
+
208
+ // Add the callback to queue
209
+ const index = store.push({
210
+ callback,
211
+ trackerName: pluginOptions.trackerName,
212
+ useNativeSdk: pluginOptions.options.useNativeSdk,
213
+ overrideUnified: pluginOptions.options.overrideUnified,
214
+ merchant: pluginOptions.merchant,
215
+ shopgate: pluginOptions.shopgate
216
+ }) - 1;
217
+
218
+ // Provide handle back for removal of event
219
+ return {
220
+ remove() {
221
+ delete store[index];
222
+ }
223
+ };
224
+ }
225
+
226
+ /**
85
227
  * Notify plugins helper
86
228
  *
87
229
  * @param {Object} rawData Object with tracking data for the event
@@ -90,24 +232,83 @@ return{remove:function remove(){delete store[index];}};}/**
90
232
  * @param {Object} [scope] Scope of the event
91
233
  * @param {Object} [state] The redux state
92
234
  * @returns {void}
93
- */},{key:"notifyHelper",value:function notifyHelper(rawData,eventName,page){var _this2=this;var scope=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};var state=arguments.length>4?arguments[4]:undefined;// Exit if the user opt out. But not for the explicit add or remove tracker events
94
- if([REMOVE_TRACKER,ADD_TRACKER].indexOf(eventName)===-1&&isOptOut()){return;}// Default scope
95
- var scopeOptions=_extends({shopgate:true,merchant:true},scope);// Get the global list of registered callbacks for the event name
96
- var storeGlobal=this.getEventStore(eventName);// Get the page specific list of registered callbacks
97
- var storePage=page?this.getEventStore(eventName,page):[];// Initialize the event payload
98
- var eventData=typeof rawData!=='undefined'?rawData:{};// Merge the global with the page specific callbacks
99
- var combinedStorage=storeGlobal.concat(storePage);var blacklist=[];var useBlacklist=false;/**
235
+ */
236
+ notifyHelper(rawData, eventName, page, scope = {}, state) {
237
+ // Exit if the user opt out. But not for the explicit add or remove tracker events
238
+ if ([REMOVE_TRACKER, ADD_TRACKER].indexOf(eventName) === -1 && isOptOut()) {
239
+ return;
240
+ }
241
+
242
+ // Default scope
243
+ const scopeOptions = {
244
+ shopgate: true,
245
+ merchant: true,
246
+ ...scope
247
+ };
248
+
249
+ // Get the global list of registered callbacks for the event name
250
+ const storeGlobal = this.getEventStore(eventName);
251
+
252
+ // Get the page specific list of registered callbacks
253
+ const storePage = page ? this.getEventStore(eventName, page) : [];
254
+
255
+ // Initialize the event payload
256
+ const eventData = typeof rawData !== 'undefined' ? rawData : {};
257
+
258
+ // Merge the global with the page specific callbacks
259
+ const combinedStorage = storeGlobal.concat(storePage);
260
+ const blacklist = [];
261
+ let useBlacklist = false;
262
+
263
+ /**
100
264
  * Loop through the queue and check if there is a unified and other plugins.
101
265
  * Registered callbacks of plugins not equal to the unified one, have to be added to a
102
266
  * blacklist, so that the app does not propagate the unified data, but the custom one
103
267
  * to the related trackers.
104
- */combinedStorage.forEach(function(entry){if(entry.trackerName!=='unified'&&entry.useNativeSdk){blacklist.push(entry.trackerName.slice(0));}else{// If there is a unified plugin registered for this event -> use the blacklist
105
- useBlacklist=true;}});// Only use the blacklist if it contains elements
106
- if(useBlacklist){useBlacklist=!!blacklist.length;}// Cycle through events queue, fire!
107
- combinedStorage.forEach(function(entry){// Merchant only command
108
- if(scopeOptions.merchant&&!scopeOptions.shopgate&&!entry.merchant){return;// Shopgate only command
109
- }if(!scopeOptions.merchant&&scopeOptions.shopgate&&!entry.shopgate){return;}var params=[eventData,scopeOptions,undefined,state];if(entry.trackerName==='unified'&&useBlacklist){// Pass the unifiedBlacklist to the plugin if the plugin is the unified one
110
- params[2]=blacklist;}try{entry.callback.apply(_this2,params);}catch(err){logger.error("'SgTrackingCore': Error in plugin [".concat(entry.trackerName,"]"),err);err.code=CODE_TRACKING;err.source=SOURCE_TRACKING;err.context=entry.trackerName;errorManager.queue(err);}});}/**
268
+ */
269
+ combinedStorage.forEach(entry => {
270
+ if (entry.trackerName !== 'unified' && entry.useNativeSdk) {
271
+ blacklist.push(entry.trackerName.slice(0));
272
+ } else {
273
+ // If there is a unified plugin registered for this event -> use the blacklist
274
+ useBlacklist = true;
275
+ }
276
+ });
277
+
278
+ // Only use the blacklist if it contains elements
279
+ if (useBlacklist) {
280
+ useBlacklist = !!blacklist.length;
281
+ }
282
+
283
+ // Cycle through events queue, fire!
284
+ combinedStorage.forEach(entry => {
285
+ // Merchant only command
286
+ if (scopeOptions.merchant && !scopeOptions.shopgate && !entry.merchant) {
287
+ return;
288
+
289
+ // Shopgate only command
290
+ }
291
+ if (!scopeOptions.merchant && scopeOptions.shopgate && !entry.shopgate) {
292
+ return;
293
+ }
294
+ const params = [eventData, scopeOptions, undefined, state];
295
+ if (entry.trackerName === 'unified' && useBlacklist) {
296
+ // Pass the unifiedBlacklist to the plugin if the plugin is the unified one
297
+ params[2] = blacklist;
298
+ }
299
+ try {
300
+ entry.callback.apply(this, params);
301
+ } catch (err) {
302
+ logger.error(`'SgTrackingCore': Error in plugin [${entry.trackerName}]`, err);
303
+ err.code = CODE_TRACKING;
304
+ err.source = SOURCE_TRACKING;
305
+ err.context = entry.trackerName;
306
+ errorManager.queue(err);
307
+ }
308
+ });
309
+ }
310
+
311
+ /**
111
312
  * Notify plugins
112
313
  *
113
314
  * @param {Object} rawData Object with tracking data for the event
@@ -116,23 +317,77 @@ params[2]=blacklist;}try{entry.callback.apply(_this2,params);}catch(err){logger.
116
317
  * @param {Object} [scope] Scope of the event
117
318
  * @param {Object} [state] The redux state
118
319
  * @returns {Core} Instance of the core instance
119
- */},{key:"notifyPlugins",value:function notifyPlugins(rawData,eventName,page,scope,state){// If registration is finished
120
- if(this.registerFinish){this.notifyHelper(rawData,eventName,page,scope,state);}else{// Store the event if not
121
- this.triggeredEvents.push({"function":this.notifyHelper,params:[rawData,eventName,page,scope,state]});}return this;}/**
320
+ */
321
+ notifyPlugins(rawData, eventName, page, scope, state) {
322
+ // If registration is finished
323
+ if (this.registerFinish) {
324
+ this.notifyHelper(rawData, eventName, page, scope, state);
325
+ } else {
326
+ // Store the event if not
327
+ this.triggeredEvents.push({
328
+ function: this.notifyHelper,
329
+ params: [rawData, eventName, page, scope, state]
330
+ });
331
+ }
332
+ return this;
333
+ }
334
+
335
+ /**
122
336
  * Opt out mechanism for all tracking tools
123
337
  *
124
338
  * @param {boolean} [optOutParam = true] If false -> revert the opt out (enable tracking)
125
339
  * @returns {boolean|null} State which was set
126
- */},{key:"optOut",value:function optOut(optOutParam){var out=optOutParam;if(typeof optOutParam==='undefined'){out=true;}if(out){// Notify Plugins about the removal.
127
- this.notifyPlugins(null,REMOVE_TRACKER);}else{// Notify Plugins about the adding
128
- this.notifyPlugins(null,ADD_TRACKER);}return _optOut(out);}},{key:"registerFinished",value:/**
340
+ */
341
+ optOut(optOutParam) {
342
+ let out = optOutParam;
343
+ if (typeof optOutParam === 'undefined') {
344
+ out = true;
345
+ }
346
+ if (out) {
347
+ // Notify Plugins about the removal.
348
+ this.notifyPlugins(null, REMOVE_TRACKER);
349
+ } else {
350
+ // Notify Plugins about the adding
351
+ this.notifyPlugins(null, ADD_TRACKER);
352
+ }
353
+ return optOut(out);
354
+ }
355
+ /**
129
356
  * Called from the outside when all plugins are registered
130
357
  * @return {Core}
131
- */function registerFinished(){var _this3=this;if(this.registerFinish){return this;}// Trigger all events that happened till now
132
- this.triggeredEvents.forEach(function(entry){entry["function"].apply(_this3,entry.params);});this.registerFinish=true;// Reset the event store
133
- this.triggeredEvents=[];return this;}/**
358
+ */
359
+ registerFinished() {
360
+ if (this.registerFinish) {
361
+ return this;
362
+ }
363
+
364
+ // Trigger all events that happened till now
365
+ this.triggeredEvents.forEach(entry => {
366
+ entry.function.apply(this, entry.params);
367
+ });
368
+ this.registerFinish = true;
369
+
370
+ // Reset the event store
371
+ this.triggeredEvents = [];
372
+ return this;
373
+ }
374
+
375
+ /**
134
376
  * Remove all registered callbacks. Only used and needed for unit tests
135
377
  * @returns {Core}
136
- */},{key:"reset",value:function reset(){this.events={};this.triggeredEvents=[];this.registerFinish=false;return this;}}]);}();/**
378
+ */
379
+ reset() {
380
+ this.events = {};
381
+ this.triggeredEvents = [];
382
+ this.registerFinish = false;
383
+ return this;
384
+ }
385
+ }
386
+
387
+ /**
137
388
  * Fix to prevent multiple instances of this class caused by two node_modules folders
138
- */if(!window.SgTrackingCore){window.SgTrackingCore=new Core();}export default window.SgTrackingCore;
389
+ */
390
+ if (!window.SgTrackingCore) {
391
+ window.SgTrackingCore = new Core();
392
+ }
393
+ export default window.SgTrackingCore;
package/helpers/events.js CHANGED
@@ -1,8 +1,47 @@
1
1
  // List of available tracking events
2
- export var TRACK_PAGEVIEW='pageview';export var TRACK_VARIANT_SELECTED='variantSelected';export var TRACK_VIEW_CONTENT='viewContent';export var TRACK_PURCHASE='purchase';export var TRACK_ADD_TO_CART='addToCart';export var TRACK_ADD_TO_WISHLIST='addToWishlist';export var TRACK_INITIATED_CHECKOUT='initiatedCheckout';export var TRACK_COMPLETED_REGISTRATION='completedRegistration';export var TRACK_SEARCH='search';export var TRACK_SCROLL_TOP='scrollTop';export var TRACK_ADDED_PAYMENT_INFO='addedPaymentInfo';export var TRACK_SELECTED_PAYMENT_INFO='selectedPaymentInfo';export var TRACK_SMARTBANNER='smartbanner';export var TRACK_FILTER_LIVE_SUGGEST='filterLiveSuggest';export var TRACK_QR_SCANNER='qrScanner';export var TRACK_AD_SCANNER='adScanner';export var TRACK_CC_SCANNER='ccScanner';export var TRACK_OPEN_DEEP_LINK='openDeepLink';export var TRACK_OPEN_UNIVERSAL_LINK='openUniversalLink';export var TRACK_OPEN_DEFERRED_DEEP_LINK='openDeferredDeepLink';export var TRACK_OPEN_SMART_APP_DOWNLOAD_LINK='openSmartAppDownloadLink';export var TRACK_OPEN_PUSH_NOTIFICATION='openPushNotification';export var TRACK_APP_REVIEW_PROMPT='appReviewPrompt';export var TRACK_SET_CAMPAIGN_WITH_URL='setCampaignWithUrl';export var TRACK_LOGIN_SUCCESS='loginSuccess';export var TRACK_LOGIN_FAILED='loginFailed';export var TRACK_CUSTOM_EVENT='customEvent';export var REMOVE_TRACKER='removeTracker';export var ADD_TRACKER='addTracker';export var COOKIE_CONSENT_UPDATED='cookieConsentUpdated';export var scannerEvents={// Scan type is activated
3
- SCAN_ACTIVATED:'scan_activated',// The actual scan stated (for QR scanner same as activated)
4
- SCAN_STARTED:'scan_started',// Scanning process cancelled
5
- SCAN_CANCELED:'scan_canceled',// Scan ended with success
6
- SCAN_SUCCESS:'scan_success',// Scan ended with no result
7
- SCAN_FAIL:'scan_fail',// User interact with scanning result (click on link)
8
- SCAN_USER_LINK_INTERACTION:'scan_user_link_interaction'};export var customEvents=[TRACK_SMARTBANNER,TRACK_FILTER_LIVE_SUGGEST,TRACK_QR_SCANNER,TRACK_AD_SCANNER,TRACK_CC_SCANNER,TRACK_SCROLL_TOP,TRACK_OPEN_DEEP_LINK,TRACK_OPEN_UNIVERSAL_LINK,TRACK_OPEN_DEFERRED_DEEP_LINK,TRACK_OPEN_SMART_APP_DOWNLOAD_LINK,TRACK_OPEN_PUSH_NOTIFICATION,TRACK_APP_REVIEW_PROMPT,TRACK_CUSTOM_EVENT];export default[TRACK_PAGEVIEW,TRACK_VIEW_CONTENT,TRACK_VARIANT_SELECTED,TRACK_PURCHASE,TRACK_ADD_TO_CART,TRACK_ADD_TO_WISHLIST,TRACK_INITIATED_CHECKOUT,TRACK_COMPLETED_REGISTRATION,TRACK_SEARCH,TRACK_SCROLL_TOP,TRACK_ADDED_PAYMENT_INFO,TRACK_SELECTED_PAYMENT_INFO,TRACK_SMARTBANNER,TRACK_FILTER_LIVE_SUGGEST,TRACK_QR_SCANNER,TRACK_AD_SCANNER,TRACK_CC_SCANNER,TRACK_OPEN_DEEP_LINK,TRACK_OPEN_UNIVERSAL_LINK,TRACK_OPEN_DEFERRED_DEEP_LINK,TRACK_OPEN_SMART_APP_DOWNLOAD_LINK,TRACK_OPEN_PUSH_NOTIFICATION,TRACK_APP_REVIEW_PROMPT,TRACK_SET_CAMPAIGN_WITH_URL,REMOVE_TRACKER,ADD_TRACKER,TRACK_LOGIN_SUCCESS,TRACK_LOGIN_FAILED,TRACK_CUSTOM_EVENT,COOKIE_CONSENT_UPDATED];
2
+ export const TRACK_PAGEVIEW = 'pageview';
3
+ export const TRACK_VARIANT_SELECTED = 'variantSelected';
4
+ export const TRACK_VIEW_CONTENT = 'viewContent';
5
+ export const TRACK_PURCHASE = 'purchase';
6
+ export const TRACK_ADD_TO_CART = 'addToCart';
7
+ export const TRACK_ADD_TO_WISHLIST = 'addToWishlist';
8
+ export const TRACK_INITIATED_CHECKOUT = 'initiatedCheckout';
9
+ export const TRACK_COMPLETED_REGISTRATION = 'completedRegistration';
10
+ export const TRACK_SEARCH = 'search';
11
+ export const TRACK_SCROLL_TOP = 'scrollTop';
12
+ export const TRACK_ADDED_PAYMENT_INFO = 'addedPaymentInfo';
13
+ export const TRACK_SELECTED_PAYMENT_INFO = 'selectedPaymentInfo';
14
+ export const TRACK_SMARTBANNER = 'smartbanner';
15
+ export const TRACK_FILTER_LIVE_SUGGEST = 'filterLiveSuggest';
16
+ export const TRACK_QR_SCANNER = 'qrScanner';
17
+ export const TRACK_AD_SCANNER = 'adScanner';
18
+ export const TRACK_CC_SCANNER = 'ccScanner';
19
+ export const TRACK_OPEN_DEEP_LINK = 'openDeepLink';
20
+ export const TRACK_OPEN_UNIVERSAL_LINK = 'openUniversalLink';
21
+ export const TRACK_OPEN_DEFERRED_DEEP_LINK = 'openDeferredDeepLink';
22
+ export const TRACK_OPEN_SMART_APP_DOWNLOAD_LINK = 'openSmartAppDownloadLink';
23
+ export const TRACK_OPEN_PUSH_NOTIFICATION = 'openPushNotification';
24
+ export const TRACK_APP_REVIEW_PROMPT = 'appReviewPrompt';
25
+ export const TRACK_SET_CAMPAIGN_WITH_URL = 'setCampaignWithUrl';
26
+ export const TRACK_LOGIN_SUCCESS = 'loginSuccess';
27
+ export const TRACK_LOGIN_FAILED = 'loginFailed';
28
+ export const TRACK_CUSTOM_EVENT = 'customEvent';
29
+ export const REMOVE_TRACKER = 'removeTracker';
30
+ export const ADD_TRACKER = 'addTracker';
31
+ export const COOKIE_CONSENT_UPDATED = 'cookieConsentUpdated';
32
+ export const scannerEvents = {
33
+ // Scan type is activated
34
+ SCAN_ACTIVATED: 'scan_activated',
35
+ // The actual scan stated (for QR scanner same as activated)
36
+ SCAN_STARTED: 'scan_started',
37
+ // Scanning process cancelled
38
+ SCAN_CANCELED: 'scan_canceled',
39
+ // Scan ended with success
40
+ SCAN_SUCCESS: 'scan_success',
41
+ // Scan ended with no result
42
+ SCAN_FAIL: 'scan_fail',
43
+ // User interact with scanning result (click on link)
44
+ SCAN_USER_LINK_INTERACTION: 'scan_user_link_interaction'
45
+ };
46
+ export const customEvents = [TRACK_SMARTBANNER, TRACK_FILTER_LIVE_SUGGEST, TRACK_QR_SCANNER, TRACK_AD_SCANNER, TRACK_CC_SCANNER, TRACK_SCROLL_TOP, TRACK_OPEN_DEEP_LINK, TRACK_OPEN_UNIVERSAL_LINK, TRACK_OPEN_DEFERRED_DEEP_LINK, TRACK_OPEN_SMART_APP_DOWNLOAD_LINK, TRACK_OPEN_PUSH_NOTIFICATION, TRACK_APP_REVIEW_PROMPT, TRACK_CUSTOM_EVENT];
47
+ export default [TRACK_PAGEVIEW, TRACK_VIEW_CONTENT, TRACK_VARIANT_SELECTED, TRACK_PURCHASE, TRACK_ADD_TO_CART, TRACK_ADD_TO_WISHLIST, TRACK_INITIATED_CHECKOUT, TRACK_COMPLETED_REGISTRATION, TRACK_SEARCH, TRACK_SCROLL_TOP, TRACK_ADDED_PAYMENT_INFO, TRACK_SELECTED_PAYMENT_INFO, TRACK_SMARTBANNER, TRACK_FILTER_LIVE_SUGGEST, TRACK_QR_SCANNER, TRACK_AD_SCANNER, TRACK_CC_SCANNER, TRACK_OPEN_DEEP_LINK, TRACK_OPEN_UNIVERSAL_LINK, TRACK_OPEN_DEFERRED_DEEP_LINK, TRACK_OPEN_SMART_APP_DOWNLOAD_LINK, TRACK_OPEN_PUSH_NOTIFICATION, TRACK_APP_REVIEW_PROMPT, TRACK_SET_CAMPAIGN_WITH_URL, REMOVE_TRACKER, ADD_TRACKER, TRACK_LOGIN_SUCCESS, TRACK_LOGIN_FAILED, TRACK_CUSTOM_EVENT, COOKIE_CONSENT_UPDATED];