@shopgate/tracking-core 7.30.0-alpha.10 → 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.
@@ -3,7 +3,9 @@ import { SGAction } from "../helpers/helper";
3
3
  /**
4
4
  * Handler for the communication between the tracking plugins and the app.
5
5
  */
6
- class AppHandler {
6
+ let AppHandler = /*#__PURE__*/function () {
7
+ function AppHandler() {}
8
+ var _proto = AppHandler.prototype;
7
9
  /**
8
10
  * Log a pageview
9
11
  *
@@ -11,7 +13,7 @@ class AppHandler {
11
13
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
12
14
  * @returns {AppHandler} Instance of SgTrackingAppHandler
13
15
  */
14
- viewContent(data, restrictions) {
16
+ _proto.viewContent = function viewContent(data, restrictions) {
15
17
  SGAction.analyticsLogPageview(AppHandler.prepareTrackingData(data, restrictions));
16
18
  return this;
17
19
  }
@@ -21,8 +23,8 @@ class AppHandler {
21
23
  * @param {UnifiedPageview} data Tracking data for this event
22
24
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
23
25
  * @returns {AppHandler} Instance of SgTrackingAppHandler
24
- */
25
- logEvent(data, restrictions) {
26
+ */;
27
+ _proto.logEvent = function logEvent(data, restrictions) {
26
28
  SGAction.analyticsLogEvent(AppHandler.prepareTrackingData(data, restrictions));
27
29
  return this;
28
30
  }
@@ -33,8 +35,8 @@ class AppHandler {
33
35
  * @param {UnifiedPurchase} data Tracking data for this event
34
36
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
35
37
  * @returns {AppHandler} Instance of SgTrackingAppHandler
36
- */
37
- purchase(data, restrictions) {
38
+ */;
39
+ _proto.purchase = function purchase(data, restrictions) {
38
40
  SGAction.analyticsLogPurchase(AppHandler.prepareTrackingData(data, restrictions));
39
41
  return this;
40
42
  }
@@ -45,8 +47,8 @@ class AppHandler {
45
47
  * @param {UnifiedAddToCart} data Tracking data for this event
46
48
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
47
49
  * @returns {AppHandler} Instance of SgTrackingAppHandler
48
- */
49
- addToCart(data, restrictions) {
50
+ */;
51
+ _proto.addToCart = function addToCart(data, restrictions) {
50
52
  SGAction.analyticsLogAddToCart(AppHandler.prepareTrackingData(data, restrictions));
51
53
  return this;
52
54
  }
@@ -57,8 +59,8 @@ class AppHandler {
57
59
  * @param {UnifiedPaymentInfo} data Tracking data for this event
58
60
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
59
61
  * @returns {AppHandler} Instance of SgTrackingAppHandler
60
- */
61
- addedPaymentInfo(data, restrictions) {
62
+ */;
63
+ _proto.addedPaymentInfo = function addedPaymentInfo(data, restrictions) {
62
64
  SGAction.analyticsLogAddedPaymentInfo(AppHandler.prepareTrackingData(data, restrictions));
63
65
  return this;
64
66
  }
@@ -69,8 +71,8 @@ class AppHandler {
69
71
  * @param {UnifiedPaymentInfo} data Tracking data for this event
70
72
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
71
73
  * @returns {AppHandler} Instance of SgTrackingAppHandler
72
- */
73
- selectedPaymentInfo(data, restrictions) {
74
+ */;
75
+ _proto.selectedPaymentInfo = function selectedPaymentInfo(data, restrictions) {
74
76
  SGAction.analyticsLogAddedPaymentInfo(AppHandler.prepareTrackingData(data, restrictions));
75
77
  return this;
76
78
  }
@@ -81,8 +83,8 @@ class AppHandler {
81
83
  * @param {UnifiedInitiatedCheckout} data Tracking data for this event
82
84
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
83
85
  * @returns {AppHandler} Instance of SgTrackingAppHandler
84
- */
85
- initiatedCheckout(data, restrictions) {
86
+ */;
87
+ _proto.initiatedCheckout = function initiatedCheckout(data, restrictions) {
86
88
  SGAction.analyticsLogInitiatedCheckout(AppHandler.prepareTrackingData(data, restrictions));
87
89
  return this;
88
90
  }
@@ -93,8 +95,8 @@ class AppHandler {
93
95
  * @param {UnifiedCompletedRegistration} data Tracking data for this event
94
96
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
95
97
  * @returns {AppHandler} Instance of SgTrackingAppHandler
96
- */
97
- completedRegistration(data, restrictions) {
98
+ */;
99
+ _proto.completedRegistration = function completedRegistration(data, restrictions) {
98
100
  SGAction.analyticsLogCompletedRegistration(AppHandler.prepareTrackingData(data, restrictions));
99
101
  return this;
100
102
  }
@@ -105,8 +107,8 @@ class AppHandler {
105
107
  * @param {UnifiedAddToWishlist} data Tracking data for this event
106
108
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
107
109
  * @returns {AppHandler} Instance of SgTrackingAppHandler
108
- */
109
- addToWishlist(data, restrictions) {
110
+ */;
111
+ _proto.addToWishlist = function addToWishlist(data, restrictions) {
110
112
  SGAction.analyticsLogAddToWishlist(AppHandler.prepareTrackingData(data, restrictions));
111
113
  return this;
112
114
  }
@@ -117,8 +119,8 @@ class AppHandler {
117
119
  * @param {UnifiedSearched} data Tracking data for this event
118
120
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
119
121
  * @returns {AppHandler} Instance of SgTrackingAppHandler
120
- */
121
- search(data, restrictions) {
122
+ */;
123
+ _proto.search = function search(data, restrictions) {
122
124
  SGAction.analyticsLogSearch(AppHandler.prepareTrackingData(data, restrictions));
123
125
  return this;
124
126
  }
@@ -128,8 +130,8 @@ class AppHandler {
128
130
  * @param {Object} data Tracking data for this event
129
131
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
130
132
  * @returns {AppHandler} Instance of SgTrackingAppHandler
131
- */
132
- setCampaignWithUrl(data, restrictions) {
133
+ */;
134
+ _proto.setCampaignWithUrl = function setCampaignWithUrl(data, restrictions) {
133
135
  SGAction.analyticsSetCampaignWithUrl(AppHandler.prepareTrackingData(data, restrictions));
134
136
  return this;
135
137
  }
@@ -140,8 +142,8 @@ class AppHandler {
140
142
  * @param {UnifiedItemView} data Tracking data for this event
141
143
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
142
144
  * @returns {AppHandler} Instance of SgTrackingAppHandler
143
- */
144
- itemView(data, restrictions) {
145
+ */;
146
+ _proto.itemView = function itemView(data, restrictions) {
145
147
  SGAction.analyticsLogItemView(AppHandler.prepareTrackingData(data, restrictions));
146
148
  return this;
147
149
  }
@@ -152,8 +154,8 @@ class AppHandler {
152
154
  * @param {UnifiedLogin} data Tracking data for this event
153
155
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
154
156
  * @returns {AppHandler} Instance of SgTrackingAppHandler
155
- */
156
- login(data, restrictions) {
157
+ */;
158
+ _proto.login = function login(data, restrictions) {
157
159
  SGAction.analyticsLogLogin(AppHandler.prepareTrackingData(data, restrictions));
158
160
  return this;
159
161
  }
@@ -165,8 +167,8 @@ class AppHandler {
165
167
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
166
168
  * @returns {Object} Tracking data with restrictions
167
169
  * @private
168
- */
169
- static prepareTrackingData(data, restrictions) {
170
+ */;
171
+ AppHandler.prepareTrackingData = function prepareTrackingData(data, restrictions) {
170
172
  // Clone the data to avoid issues with references.
171
173
  const clonedData = {
172
174
  ...data
@@ -186,6 +188,7 @@ class AppHandler {
186
188
  };
187
189
  }
188
190
  return clonedData;
189
- }
190
- }
191
+ };
192
+ return AppHandler;
193
+ }();
191
194
  export default new AppHandler();
package/core/Core.js CHANGED
@@ -1,17 +1,17 @@
1
1
  import { logger } from '@shopgate/pwa-core/helpers';
2
2
  import errorManager from '@shopgate/pwa-core/classes/ErrorManager';
3
3
  import { SOURCE_TRACKING, CODE_TRACKING } from '@shopgate/pwa-core/constants/ErrorManager';
4
- import { optOut, isOptOut } from "../helpers/optOut";
4
+ import { optOut as _optOut, isOptOut } from "../helpers/optOut";
5
5
  import trackingEvents, { REMOVE_TRACKER, ADD_TRACKER, scannerEvents } from "../helpers/events";
6
6
 
7
7
  /**
8
8
  * Core for our tracking system. Plugins can use the core to register for events. Pub/sub pattern.
9
9
  */
10
- class Core {
10
+ let Core = /*#__PURE__*/function () {
11
11
  /**
12
12
  * Constructor
13
13
  */
14
- constructor() {
14
+ function Core() {
15
15
  /**
16
16
  * Check if the opt-out state is set
17
17
  *
@@ -151,7 +151,8 @@ class Core {
151
151
  * @param {string} [page] Identifier of the page
152
152
  * @returns {Object} The event store for the given eventName and page
153
153
  */
154
- getEventStore(eventName, page) {
154
+ var _proto = Core.prototype;
155
+ _proto.getEventStore = function getEventStore(eventName, page) {
155
156
  if (!this.events.hasOwnProperty(eventName)) {
156
157
  // Create a new event store entry for the current event name, if no one is already present
157
158
  this.events[eventName] = {
@@ -185,8 +186,8 @@ class Core {
185
186
  * @param {string} eventName Name of the event
186
187
  * @param {Object} options Additional options
187
188
  * @returns {RemoveListener} Function to remove the listener
188
- */
189
- registerHelper(callback, eventName, options = {}) {
189
+ */;
190
+ _proto.registerHelper = function registerHelper(callback, eventName, options = {}) {
190
191
  const defaults = {
191
192
  trackerName: '',
192
193
  page: null,
@@ -232,8 +233,8 @@ class Core {
232
233
  * @param {Object} [scope] Scope of the event
233
234
  * @param {Object} [state] The redux state
234
235
  * @returns {void}
235
- */
236
- notifyHelper(rawData, eventName, page, scope = {}, state) {
236
+ */;
237
+ _proto.notifyHelper = function notifyHelper(rawData, eventName, page, scope = {}, state) {
237
238
  // Exit if the user opt out. But not for the explicit add or remove tracker events
238
239
  if ([REMOVE_TRACKER, ADD_TRACKER].indexOf(eventName) === -1 && isOptOut()) {
239
240
  return;
@@ -317,8 +318,8 @@ class Core {
317
318
  * @param {Object} [scope] Scope of the event
318
319
  * @param {Object} [state] The redux state
319
320
  * @returns {Core} Instance of the core instance
320
- */
321
- notifyPlugins(rawData, eventName, page, scope, state) {
321
+ */;
322
+ _proto.notifyPlugins = function notifyPlugins(rawData, eventName, page, scope, state) {
322
323
  // If registration is finished
323
324
  if (this.registerFinish) {
324
325
  this.notifyHelper(rawData, eventName, page, scope, state);
@@ -337,8 +338,8 @@ class Core {
337
338
  *
338
339
  * @param {boolean} [optOutParam = true] If false -> revert the opt out (enable tracking)
339
340
  * @returns {boolean|null} State which was set
340
- */
341
- optOut(optOutParam) {
341
+ */;
342
+ _proto.optOut = function optOut(optOutParam) {
342
343
  let out = optOutParam;
343
344
  if (typeof optOutParam === 'undefined') {
344
345
  out = true;
@@ -350,13 +351,13 @@ class Core {
350
351
  // Notify Plugins about the adding
351
352
  this.notifyPlugins(null, ADD_TRACKER);
352
353
  }
353
- return optOut(out);
354
- }
354
+ return _optOut(out);
355
+ };
355
356
  /**
356
357
  * Called from the outside when all plugins are registered
357
358
  * @return {Core}
358
359
  */
359
- registerFinished() {
360
+ _proto.registerFinished = function registerFinished() {
360
361
  if (this.registerFinish) {
361
362
  return this;
362
363
  }
@@ -375,15 +376,15 @@ class Core {
375
376
  /**
376
377
  * Remove all registered callbacks. Only used and needed for unit tests
377
378
  * @returns {Core}
378
- */
379
- reset() {
379
+ */;
380
+ _proto.reset = function reset() {
380
381
  this.events = {};
381
382
  this.triggeredEvents = [];
382
383
  this.registerFinish = false;
383
384
  return this;
384
- }
385
- }
386
-
385
+ };
386
+ return Core;
387
+ }();
387
388
  /**
388
389
  * Fix to prevent multiple instances of this class caused by two node_modules folders
389
390
  */
@@ -264,7 +264,7 @@ dataFormatHelpers.viewContent = rawData => {
264
264
  * In splittedPath we have the action as the first array entry
265
265
  * to get the id/action params we remove the action from the array
266
266
  */
267
- const splittedPath = [...link.splittedPath];
267
+ const splittedPath = [].concat(link.splittedPath);
268
268
  splittedPath.shift();
269
269
 
270
270
  /**
package/helpers/helper.js CHANGED
@@ -43,12 +43,12 @@ export function sendDataRequest(url) {
43
43
  * Object representation of URI(RFC2396) string
44
44
  * Made for general purpose. Feel free to extend it for your needs.
45
45
  */
46
- export class SGLink {
46
+ export let SGLink = /*#__PURE__*/function () {
47
47
  /**
48
48
  * Constructor
49
49
  * @param {string} url Url to creating SGLink from
50
50
  */
51
- constructor(url) {
51
+ function SGLink(url) {
52
52
  // Complete url string
53
53
  this.url = '';
54
54
  // Any scheme we support (ex. https|shopgate-{$number}|sgapi)
@@ -91,7 +91,7 @@ export class SGLink {
91
91
  * @param {string} string - string to be encoded
92
92
  * @return {string}
93
93
  */
94
- static encodeURIComponentSafe(string) {
94
+ SGLink.encodeURIComponentSafe = function encodeURIComponentSafe(string) {
95
95
  const decoded = decodeURIComponent(string);
96
96
  if (decoded !== string) {
97
97
  return string;
@@ -103,8 +103,8 @@ export class SGLink {
103
103
  * Encode the url and takes care of double encoding
104
104
  * @param {string} string String to be encoded
105
105
  * @returns {string} encoded string
106
- */
107
- static encodeURISafe(string) {
106
+ */;
107
+ SGLink.encodeURISafe = function encodeURISafe(string) {
108
108
  const decoded = decodeURI(string);
109
109
  if (decoded !== string) {
110
110
  return string;
@@ -116,8 +116,9 @@ export class SGLink {
116
116
  * Parses url and extracts path, query, action, splittedPath, ...
117
117
  *
118
118
  * @param {string} incomingUrl The url that shall be parsed.
119
- */
120
- parseUrl(incomingUrl) {
119
+ */;
120
+ var _proto = SGLink.prototype;
121
+ _proto.parseUrl = function parseUrl(incomingUrl) {
121
122
  let urlToSanitize = incomingUrl;
122
123
  if (!urlToSanitize) {
123
124
  urlToSanitize = '';
@@ -171,8 +172,8 @@ export class SGLink {
171
172
  * Gets a param
172
173
  * @param {string} name name of param
173
174
  * @return {string|undefined}
174
- */
175
- getParam(name) {
175
+ */;
176
+ _proto.getParam = function getParam(name) {
176
177
  if (!(name in this.params)) {
177
178
  return undefined;
178
179
  }
@@ -183,8 +184,8 @@ export class SGLink {
183
184
  * Sets param.
184
185
  * @param {string} name Name of param
185
186
  * @param {string} [value] Value of param - if empty, the parameter will be deleted from the query
186
- */
187
- setParam(name, value) {
187
+ */;
188
+ _proto.setParam = function setParam(name, value) {
188
189
  if (typeof value === 'undefined') {
189
190
  this.deleteParam(name);
190
191
  } else {
@@ -197,8 +198,8 @@ export class SGLink {
197
198
  * Sets params array
198
199
  *
199
200
  * @param {Object} [newParams] New Params to be set
200
- */
201
- setParams(newParams) {
201
+ */;
202
+ _proto.setParams = function setParams(newParams) {
202
203
  const newQueryArr = [];
203
204
  if (typeof newParams !== 'undefined') {
204
205
  this.params = newParams;
@@ -214,8 +215,8 @@ export class SGLink {
214
215
  *
215
216
  * @param {string} name name of param
216
217
  * @returns {boolean}
217
- */
218
- deleteParam(name) {
218
+ */;
219
+ _proto.deleteParam = function deleteParam(name) {
219
220
  if (!(name in this.params)) {
220
221
  return false;
221
222
  }
@@ -228,8 +229,8 @@ export class SGLink {
228
229
  * Converts the object to string
229
230
  *
230
231
  * @return {string}
231
- */
232
- toString() {
232
+ */;
233
+ _proto.toString = function toString() {
233
234
  let outputUrl = '';
234
235
  const notNavigatorSchema = ['mailto', 'tel'].indexOf(this.scheme) > -1;
235
236
  if (this.scheme) {
@@ -260,13 +261,13 @@ export class SGLink {
260
261
  }
261
262
  outputUrl += this.toRelativeString(false);
262
263
  return outputUrl;
263
- }
264
+ };
264
265
  /**
265
266
  * Sets utm param from event.
266
267
  * @param {Object} data event data
267
268
  * @param {Object} raw event raw data
268
269
  */
269
- setUtmParams(data, raw) {
270
+ _proto.setUtmParams = function setUtmParams(data, raw) {
270
271
  // Add fake params, only if it didn't come from branch.io
271
272
  if (raw.type !== 'branchio') {
272
273
  this.setParam('utm_source', 'shopgate');
@@ -282,5 +283,6 @@ export class SGLink {
282
283
  }
283
284
  this.setParam('utm_campaign', `push-${notificationId}`);
284
285
  }
285
- }
286
- }
286
+ };
287
+ return SGLink;
288
+ }();
@@ -3,8 +3,6 @@ import "core-js/modules/es.string.replace.js";
3
3
  * Data modifier for urls
4
4
  */
5
5
 
6
- /* eslint-disable camelcase */
7
-
8
6
  // Contains a list of url parameter names that will be removed from the url
9
7
  const urlParameterBlacklist = [
10
8
  // Tracking parameters that come after switching from http to https
@@ -118,6 +116,4 @@ function sgTrackingUrlMapper(url, data) {
118
116
  private: mappedUrls
119
117
  };
120
118
  }
121
- export default sgTrackingUrlMapper;
122
-
123
- /* eslint-enable camelcase */
119
+ export default sgTrackingUrlMapper;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/tracking-core",
3
- "version": "7.30.0-alpha.10",
3
+ "version": "7.30.0-alpha.11",
4
4
  "description": "Tracking core library for the Shopgate Connect PWA.",
5
5
  "author": "Shopgate <support@shopgate.com>",
6
6
  "license": "Apache-2.0",
@@ -16,8 +16,8 @@
16
16
  "connect"
17
17
  ],
18
18
  "devDependencies": {
19
- "@shopgate/eslint-config": "7.30.0-alpha.10",
20
- "@shopgate/pwa-core": "7.30.0-alpha.10",
19
+ "@shopgate/eslint-config": "7.30.0-alpha.11",
20
+ "@shopgate/pwa-core": "7.30.0-alpha.11",
21
21
  "lodash": "^4.17.21"
22
22
  }
23
23
  }
package/plugins/Base.js CHANGED
@@ -6,7 +6,7 @@ import eventNames from "../helpers/events";
6
6
  /**
7
7
  * Parent class for all tracking plugins that contains common public functions
8
8
  */
9
- class Base {
9
+ let Base = /*#__PURE__*/function () {
10
10
  /**
11
11
  * Constructor
12
12
  * @param {string} trackerName The name of the tracker that is represented by the plugin
@@ -14,7 +14,7 @@ class Base {
14
14
  * @param {Object} extendedDefaults Additional default options that are
15
15
  * needed by the inherited class
16
16
  */
17
- constructor(trackerName, options = {}, extendedDefaults = {}) {
17
+ function Base(trackerName, options = {}, extendedDefaults = {}) {
18
18
  const defaults = {
19
19
  overrideUnified: false,
20
20
  useNativeSdk: false,
@@ -56,7 +56,7 @@ class Base {
56
56
  * @param {Object} rawData Raw data from the core
57
57
  * @returns {*} The converted data
58
58
  */
59
- static formatData(eventName, rawData) {
59
+ Base.formatData = function formatData(eventName, rawData) {
60
60
  // Check if a suitable conversion function is available
61
61
  if (typeof dataFormatHelpers[eventName] !== 'function') {
62
62
  return rawData;
@@ -74,8 +74,9 @@ class Base {
74
74
  * @param {Object} options Additional options that will be passed to the core
75
75
  * @returns {RemoveListener} Function to remove the listener
76
76
  * @private
77
- */
78
- registerHelper(eventName, callback, options) {
77
+ */;
78
+ var _proto = Base.prototype;
79
+ _proto.registerHelper = function registerHelper(eventName, callback, options) {
79
80
  // Register the tracking event of the plugin at the core
80
81
  return this.trackingCore.register[eventName]((data, scope, blacklist, state) => {
81
82
  // Convert the tracking data into the unified format
@@ -106,8 +107,8 @@ class Base {
106
107
  * Disables the tracking for the plugin
107
108
  *
108
109
  * @returns {Base} The instance of the plugin
109
- */
110
- disableTracking() {
110
+ */;
111
+ _proto.disableTracking = function disableTracking() {
111
112
  this.trackingDisabled = true;
112
113
  return this;
113
114
  }
@@ -116,10 +117,11 @@ class Base {
116
117
  * Enables the tracking for the plugin
117
118
  *
118
119
  * @returns {Base} The instance of the plugin
119
- */
120
- enableTracking() {
120
+ */;
121
+ _proto.enableTracking = function enableTracking() {
121
122
  this.trackingDisabled = false;
122
123
  return this;
123
- }
124
- }
124
+ };
125
+ return Base;
126
+ }();
125
127
  export default Base;
@@ -1,3 +1,5 @@
1
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
2
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
1
3
  /* global fbq */
2
4
  import { logger } from '@shopgate/pwa-core/helpers';
3
5
  import BasePlugin from "../Base";
@@ -5,7 +7,7 @@ import BasePlugin from "../Base";
5
7
  /**
6
8
  * Tracking plugin for Facebook
7
9
  */
8
- class FbPixel extends BasePlugin {
10
+ let FbPixel = /*#__PURE__*/function (_BasePlugin) {
9
11
  /**
10
12
  * Constructor
11
13
  *
@@ -16,29 +18,33 @@ class FbPixel extends BasePlugin {
16
18
  * @param {Object} [options.config] Configuration for facebook pixel tracking
17
19
  * @param {Array} [options.config.pixelIds] List of Facebook pixels
18
20
  */
19
- constructor(options) {
21
+ function FbPixel(options) {
22
+ var _this;
20
23
  const trackerName = 'facebookPixel';
21
24
  const extendedDefaults = {
22
25
  config: {
23
26
  pixelIds: []
24
27
  }
25
28
  };
26
- super(trackerName, options, extendedDefaults);
27
- if (this.options.useNativeSdk) {
29
+ _this = _BasePlugin.call(this, trackerName, options, extendedDefaults) || this;
30
+ if (_this.options.useNativeSdk) {
28
31
  logger.warn('SgFbPixelTracking: no native SDK support for this plugin');
29
- return;
32
+ return _assertThisInitialized(_this);
30
33
  }
31
- if (!this.options.config.pixelIds.length) {
34
+ if (!_this.options.config.pixelIds.length) {
32
35
  logger.warn('SgFbPixelTracking: pixels missing');
33
- return;
36
+ return _assertThisInitialized(_this);
34
37
  }
35
- this.initPlugin();
38
+ _this.initPlugin();
39
+ return _this;
36
40
  }
37
41
 
38
42
  /**
39
43
  * Initiate and setup the SDK
40
44
  */
41
- initPlugin() {
45
+ _inheritsLoose(FbPixel, _BasePlugin);
46
+ var _proto = FbPixel.prototype;
47
+ _proto.initPlugin = function initPlugin() {
42
48
  // Load the fb pixel tracking sdk
43
49
  /* eslint-disable eslint-comments/no-unlimited-disable */
44
50
  /* eslint-disable */
@@ -79,7 +85,7 @@ class FbPixel extends BasePlugin {
79
85
  FbPixel.sendToFb('PageView');
80
86
 
81
87
  // Register for some events
82
- /* eslint-disable camelcase */
88
+
83
89
  this.register.completedRegistration(data => {
84
90
  FbPixel.sendToFb('CompleteRegistration', {
85
91
  content_name: data.registrationMethod
@@ -153,8 +159,8 @@ class FbPixel extends BasePlugin {
153
159
  * @param {Object} [params] Params for the event
154
160
  * @param {string} [typeParam] Type of the tracker call
155
161
  * @returns {void}
156
- */
157
- static sendToFb(eventName, params, typeParam) {
162
+ */;
163
+ FbPixel.sendToFb = function sendToFb(eventName, params, typeParam) {
158
164
  const type = typeParam || 'track';
159
165
  fbq(type, eventName, params);
160
166
  }
@@ -164,8 +170,8 @@ class FbPixel extends BasePlugin {
164
170
  *
165
171
  * @param {Array} products Array with products
166
172
  * @returns {Array} Array of product Ids
167
- */
168
- static getProductIds(products) {
173
+ */;
174
+ FbPixel.getProductIds = function getProductIds(products) {
169
175
  return products.map(product => product.productNumber || product.uid || product.id);
170
176
  }
171
177
 
@@ -174,8 +180,8 @@ class FbPixel extends BasePlugin {
174
180
  *
175
181
  * @param {Object} amount Price Object
176
182
  * @returns {number|string} net or gross price
177
- */
178
- getPrice(amount) {
183
+ */;
184
+ _proto.getPrice = function getPrice(amount) {
179
185
  if (this.options.useNetPrices) {
180
186
  return amount.priceNet || amount.valueNet || amount.net || amount.revenueNet;
181
187
  }
@@ -187,14 +193,14 @@ class FbPixel extends BasePlugin {
187
193
  *
188
194
  * @param {Object} data Converted data from the parent plugin
189
195
  * @returns {Object} Params for the fb event
190
- */
191
- getParamsForAddToCartAndWishlist(data) {
196
+ */;
197
+ _proto.getParamsForAddToCartAndWishlist = function getParamsForAddToCartAndWishlist(data) {
192
198
  const productIds = FbPixel.getProductIds(data.items);
193
199
  let value = 0;
194
200
  let currency = 'EUR';
195
201
  data.items.forEach(item => {
196
202
  value += this.getPrice(item);
197
- currency = item.currency; // eslint-disable-line prefer-destructuring
203
+ currency = item.currency;
198
204
  });
199
205
  const fbParams = {
200
206
  content_ids: productIds,
@@ -206,8 +212,8 @@ class FbPixel extends BasePlugin {
206
212
  fbParams.content_name = data.items[0].name;
207
213
  }
208
214
  return fbParams;
209
- }
210
- /* eslint-enable camelcase */
211
- }
215
+ };
216
+ return FbPixel;
217
+ }(BasePlugin);
212
218
  window.SgFbPixelTracking = FbPixel;
213
219
  export default FbPixel;
@@ -1,3 +1,4 @@
1
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
1
2
  import BasePlugin from "../Base";
2
3
  import SgGAUniversalTracking from "./GaUniversal";
3
4
  import SgGAClassicTracking from "./GaClassic";
@@ -38,18 +39,20 @@ commandMapping[TRACK_REQUIRE] = [undefined, 'require'];
38
39
  /**
39
40
  * Parent Tracking plugin for Google Analytics
40
41
  */
41
- class GaBase extends BasePlugin {
42
+ let GaBase = /*#__PURE__*/function (_BasePlugin) {
42
43
  /**
43
44
  * Constructor
44
45
  */
45
- constructor() {
46
- super('GAcore', {});
46
+ function GaBase() {
47
+ var _this;
48
+ _this = _BasePlugin.call(this, 'GAcore', {}) || this;
47
49
 
48
50
  // Universal and classic merchant and shopgate accounts
49
- this.accounts = [];
50
- this.isRegistered = false;
51
- this.universalPlugin = null;
52
- this.classicPlugin = null;
51
+ _this.accounts = [];
52
+ _this.isRegistered = false;
53
+ _this.universalPlugin = null;
54
+ _this.classicPlugin = null;
55
+ return _this;
53
56
  }
54
57
 
55
58
  /**
@@ -65,7 +68,8 @@ class GaBase extends BasePlugin {
65
68
  * }}
66
69
  * @private
67
70
  */
68
- static getEventData(name, data) {
71
+ _inheritsLoose(GaBase, _BasePlugin);
72
+ GaBase.getEventData = function getEventData(name, data) {
69
73
  return {
70
74
  eventCategory: name,
71
75
  eventAction: data.eventAction,
@@ -84,8 +88,9 @@ class GaBase extends BasePlugin {
84
88
  * @param {Object} [scope] Scope (merchant or shopgate account)
85
89
  * @param {string} [account] Which account to use, classic or universal
86
90
  * @private
87
- */
88
- sendCommand(command, payload, scope, account) {
91
+ */;
92
+ var _proto = GaBase.prototype;
93
+ _proto.sendCommand = function sendCommand(command, payload, scope, account) {
89
94
  if (typeof commandMapping[command] === 'undefined') {
90
95
  return;
91
96
  }
@@ -104,8 +109,8 @@ class GaBase extends BasePlugin {
104
109
  /**
105
110
  * Helper to register for some events
106
111
  * @private
107
- */
108
- registerEvents() {
112
+ */;
113
+ _proto.registerEvents = function registerEvents() {
109
114
  if (this.isRegistered) {
110
115
  return;
111
116
  }
@@ -253,9 +258,10 @@ class GaBase extends BasePlugin {
253
258
  * Creates an ga universals child tracker
254
259
  * @param {Object} tracker Tracker configuration data
255
260
  * @returns {GaUniversal} plugin instance
256
- */
257
- createUniversal(tracker) {
258
- this.accounts.push(...tracker.config.merchant, tracker.config.shopgate);
261
+ */;
262
+ _proto.createUniversal = function createUniversal(tracker) {
263
+ var _this$accounts;
264
+ (_this$accounts = this.accounts).push.apply(_this$accounts, tracker.config.merchant.concat([tracker.config.shopgate]));
259
265
  this.universalPlugin = new SgGAUniversalTracking(tracker);
260
266
  this.registerEvents();
261
267
  return this.universalPlugin;
@@ -265,15 +271,15 @@ class GaBase extends BasePlugin {
265
271
  * Creates a ga classic child tracker
266
272
  * @param {Object} tracker Tracker configuration data
267
273
  * @returns {GaClassic} plugin instance
268
- */
269
- createClassic(tracker) {
270
- this.accounts.push(...tracker.config.merchant);
274
+ */;
275
+ _proto.createClassic = function createClassic(tracker) {
276
+ var _this$accounts2;
277
+ (_this$accounts2 = this.accounts).push.apply(_this$accounts2, tracker.config.merchant);
271
278
  this.classicPlugin = new SgGAClassicTracking(tracker);
272
279
  this.registerEvents();
273
280
  return this.classicPlugin;
274
- }
275
- }
276
-
277
- // Export and create global instance
281
+ };
282
+ return GaBase;
283
+ }(BasePlugin); // Export and create global instance
278
284
  window.SgGATrackingInstance = new GaBase();
279
285
  export default window.SgGATrackingInstance;
@@ -1,9 +1,8 @@
1
1
  /* global _gaq */
2
-
3
2
  /**
4
3
  * Tracking plugin for google analytics classic accounts
5
4
  */
6
- class GaClassic {
5
+ let GaClassic = /*#__PURE__*/function () {
7
6
  /**
8
7
  * Constructor
9
8
  * @param {Object} options Common Tracking Configuration
@@ -12,7 +11,7 @@ class GaClassic {
12
11
  * to the native sdk
13
12
  * @param {Object} [options.config] Configuration for google analytics classic tracking
14
13
  */
15
- constructor(options) {
14
+ function GaClassic(options) {
16
15
  // eslint-disable-next-line no-underscore-dangle
17
16
  window._gaq = window._gaq || [];
18
17
  this.merchantAccounts = options.config.merchant;
@@ -40,7 +39,8 @@ class GaClassic {
40
39
  /**
41
40
  * Initiate and setup the SDK
42
41
  */
43
- initPlugin() {
42
+ var _proto = GaClassic.prototype;
43
+ _proto.initPlugin = function initPlugin() {
44
44
  // Load the SDK
45
45
  /* eslint-disable eslint-comments/no-unlimited-disable */
46
46
  /* eslint-disable */
@@ -71,8 +71,8 @@ class GaClassic {
71
71
  *
72
72
  * @param {string} id Id of the account
73
73
  * @returns {string} Prefix for the account
74
- */
75
- static buildMerchantPrefix(id) {
74
+ */;
75
+ GaClassic.buildMerchantPrefix = function buildMerchantPrefix(id) {
76
76
  return `merchant_${id}`;
77
77
  }
78
78
 
@@ -82,8 +82,8 @@ class GaClassic {
82
82
  * @param {Object|Array|string|Function} payload Data for the command,
83
83
  * or a function that returns data
84
84
  * @param {Object} [scope={}] Info if the event is for merchant and/or shopgate account
85
- */
86
- send(command, payload, scope = {}) {
85
+ */;
86
+ _proto.send = function send(command, payload, scope = {}) {
87
87
  const defaults = {
88
88
  merchant: true,
89
89
  shopgate: true
@@ -103,12 +103,13 @@ class GaClassic {
103
103
  data = typeof this.filters[command] !== 'undefined' ? this.filters[command](data) : data;
104
104
  const cmd = `${GaClassic.buildMerchantPrefix(index ? account.id : '')}._${command}`;
105
105
  if (Array.isArray(data)) {
106
- _gaq.push([cmd, ...data]);
106
+ _gaq.push([cmd].concat(data));
107
107
  } else {
108
108
  _gaq.push([cmd, data]);
109
109
  }
110
110
  });
111
111
  }
112
- }
113
- }
112
+ };
113
+ return GaClassic;
114
+ }();
114
115
  export default GaClassic;
@@ -14,7 +14,7 @@ const DIMENSION_CODEBASE_VERSION = 'dimension2';
14
14
  /**
15
15
  * Tracking plugin for google analytics classic accounts
16
16
  */
17
- class GaUniversal {
17
+ let GaUniversal = /*#__PURE__*/function () {
18
18
  /**
19
19
  * Constructor
20
20
  *
@@ -26,7 +26,7 @@ class GaUniversal {
26
26
  * to the native sdk
27
27
  * @param {Object} [options.config] Configuration for facebook pixel tracking
28
28
  */
29
- constructor(options) {
29
+ function GaUniversal(options) {
30
30
  this.options = options;
31
31
  this.merchantAccounts = options.config.merchant;
32
32
  this.shopgateAccount = options.config.shopgate;
@@ -59,7 +59,8 @@ class GaUniversal {
59
59
  /**
60
60
  * Initiate and setup the SDK
61
61
  */
62
- initPlugin() {
62
+ var _proto = GaUniversal.prototype;
63
+ _proto.initPlugin = function initPlugin() {
63
64
  // Load the SDK (if the code is executed form a unit test, always load the sdk)
64
65
  if (typeof window.ga !== 'function' || typeof global !== 'undefined' && typeof global.it === 'function') {
65
66
  /* eslint-disable eslint-comments/no-unlimited-disable */
@@ -113,8 +114,8 @@ class GaUniversal {
113
114
  *
114
115
  * @param {string} code Google Analytics Property ID
115
116
  * @returns {string} sanitized merchantCode
116
- */
117
- getCleanUniversalMerchantCode(code) {
117
+ */;
118
+ _proto.getCleanUniversalMerchantCode = function getCleanUniversalMerchantCode(code) {
118
119
  if (!this.universalCleanCodesCache.hasOwnProperty(code)) {
119
120
  this.universalCleanCodesCache[code] = code.replace(/-/g, '');
120
121
  }
@@ -126,8 +127,8 @@ class GaUniversal {
126
127
  *
127
128
  * @param {string} id Id of the account
128
129
  * @returns {string} Prefix for the account
129
- */
130
- buildMerchantPrefix(id) {
130
+ */;
131
+ _proto.buildMerchantPrefix = function buildMerchantPrefix(id) {
131
132
  return `merchant_${this.getCleanUniversalMerchantCode(id)}`;
132
133
  }
133
134
 
@@ -137,8 +138,8 @@ class GaUniversal {
137
138
  * @param {Object|Array|string|Function} payload Data for the command,
138
139
  * or a function that returns data
139
140
  * @param {Object} [scope={}] Info if the event is for merchant and/or shopgate account
140
- */
141
- send(command, payload, scope = {}) {
141
+ */;
142
+ _proto.send = function send(command, payload, scope = {}) {
142
143
  const defaults = {
143
144
  merchant: true,
144
145
  shopgate: true
@@ -161,11 +162,11 @@ class GaUniversal {
161
162
  cmd[0] = `${merchantPrefix}.${cmd[0]}`;
162
163
  }
163
164
  if (typeof data === 'undefined') {
164
- ga(...cmd.slice());
165
+ ga.apply(void 0, cmd.slice());
165
166
  } else if (Array.isArray(data)) {
166
- ga(...cmd.slice(), ...data);
167
+ ga.apply(void 0, cmd.slice().concat(data));
167
168
  } else {
168
- ga(...cmd.slice(), data);
169
+ ga.apply(void 0, cmd.slice().concat([data]));
169
170
  }
170
171
  });
171
172
  }
@@ -180,13 +181,14 @@ class GaUniversal {
180
181
  cmd[0] = `shopgate.${cmd[0]}`;
181
182
  }
182
183
  if (typeof data === 'undefined') {
183
- ga(...cmd.slice());
184
+ ga.apply(void 0, cmd.slice());
184
185
  } else if (Array.isArray(data)) {
185
- ga(...cmd.slice(), ...data);
186
+ ga.apply(void 0, cmd.slice().concat(data));
186
187
  } else {
187
- ga(...cmd.slice(), data);
188
+ ga.apply(void 0, cmd.slice().concat([data]));
188
189
  }
189
190
  }
190
- }
191
- }
191
+ };
192
+ return GaUniversal;
193
+ }();
192
194
  export default GaUniversal;
@@ -1,41 +1,44 @@
1
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
1
2
  import { sendDataRequest } from "../../helpers/helper";
2
3
  import BasePlugin from "../Base";
3
4
 
4
5
  /**
5
6
  * Tracking Plugin for our unified tracking system
6
7
  */
7
- class Unified extends BasePlugin {
8
+ let Unified = /*#__PURE__*/function (_BasePlugin) {
8
9
  /**
9
10
  * @param {Object} [options] configuration
10
11
  */
11
- constructor(options = {}) {
12
+ function Unified(options = {}) {
13
+ var _this;
12
14
  const trackerName = options.trackerName || 'unified';
13
15
 
14
16
  // Invoke the parent constructor
15
- super(trackerName, options);
16
- this.register.viewContent(data => data);
17
- this.register.setCampaignWithUrl(data => data);
18
- this.register.purchase(data => data);
19
- this.register.addToCart(data => data);
20
- this.register.initiatedCheckout(data => data);
21
- this.register.completedRegistration(data => data);
22
- this.register.addToWishlist(data => data);
23
- this.register.search(data => data);
24
- this.register.addedPaymentInfo(data => data);
25
- this.trackingCore.register.removeTracker(() => {
17
+ _this = _BasePlugin.call(this, trackerName, options) || this;
18
+ _this.register.viewContent(data => data);
19
+ _this.register.setCampaignWithUrl(data => data);
20
+ _this.register.purchase(data => data);
21
+ _this.register.addToCart(data => data);
22
+ _this.register.initiatedCheckout(data => data);
23
+ _this.register.completedRegistration(data => data);
24
+ _this.register.addToWishlist(data => data);
25
+ _this.register.search(data => data);
26
+ _this.register.addedPaymentInfo(data => data);
27
+ _this.trackingCore.register.removeTracker(() => {
26
28
  // Send request to server to remove the tracker
27
29
  sendDataRequest('remove_unified_trackers');
28
30
  }, {
29
- trackerName: this.trackerName,
30
- options: this.options
31
+ trackerName: _this.trackerName,
32
+ options: _this.options
31
33
  });
32
- this.trackingCore.register.addTracker(() => {
34
+ _this.trackingCore.register.addTracker(() => {
33
35
  // Send request to server to add the tracker again
34
36
  sendDataRequest('add_unified_trackers');
35
37
  }, {
36
- trackerName: this.trackerName,
37
- options: this.options
38
+ trackerName: _this.trackerName,
39
+ options: _this.options
38
40
  });
41
+ return _this;
39
42
  }
40
43
 
41
44
  /**
@@ -47,7 +50,9 @@ class Unified extends BasePlugin {
47
50
  * @returns {RemoveListener} Function to remove the listener
48
51
  * @private
49
52
  */
50
- registerHelper(eventName, callback) {
53
+ _inheritsLoose(Unified, _BasePlugin);
54
+ var _proto = Unified.prototype;
55
+ _proto.registerHelper = function registerHelper(eventName, callback) {
51
56
  // Register the tracking event of the plugin at the core
52
57
  return this.trackingCore.register[eventName]((data, scope, blacklist, state) => {
53
58
  if (typeof this.appHandler[eventName] !== 'function') {
@@ -70,7 +75,8 @@ class Unified extends BasePlugin {
70
75
  trackerName: this.trackerName,
71
76
  options: this.options
72
77
  });
73
- }
74
- }
78
+ };
79
+ return Unified;
80
+ }(BasePlugin);
75
81
  window.SgUnifiedTracking = Unified;
76
82
  export default Unified;