@shopgate/tracking-core 7.12.3 → 7.20.0-beta.2

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,12 +1,12 @@
1
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";/**
2
2
  * Handler for the communication between the tracking plugins and the app.
3
- */var AppHandler=/*#__PURE__*/function(){function AppHandler(){_classCallCheck(this,AppHandler);}_createClass(AppHandler,[{key:"viewContent",/**
3
+ */var AppHandler=/*#__PURE__*/function(){function AppHandler(){_classCallCheck(this,AppHandler);}return _createClass(AppHandler,[{key:"viewContent",value:/**
4
4
  * Log a pageview
5
5
  *
6
6
  * @param {UnifiedPageview} data Tracking data for this event
7
7
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
8
8
  * @returns {AppHandler} Instance of SgTrackingAppHandler
9
- */value:function viewContent(data,restrictions){SGAction.analyticsLogPageview(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
9
+ */function viewContent(data,restrictions){SGAction.analyticsLogPageview(AppHandler.prepareTrackingData(data,restrictions));return this;}/**
10
10
  * AnalyticsLogEvent
11
11
  * @param {UnifiedPageview} data Tracking data for this event
12
12
  * @param {UnifiedRestrictions} [restrictions] Info about the restrictions
@@ -86,4 +86,4 @@ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj
86
86
  */}],[{key:"prepareTrackingData",value:function prepareTrackingData(data,restrictions){// Clone the data to avoid issues with references.
87
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
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;}}]);return AppHandler;}();export default new AppHandler();
89
+ clonedData.restrictions=_defineProperty({blacklist:restrictions.blacklist},trackerParamName,restrictions.trackers);}return clonedData;}}]);}();export default new AppHandler();
package/core/Core.js CHANGED
@@ -2,7 +2,27 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
2
2
  * Core for our tracking system. Plugins can use the core to register for events. Pub/sub pattern.
3
3
  */var Core=/*#__PURE__*/function(){/**
4
4
  * Constructor
5
- */function Core(){var _this=this;_classCallCheck(this,Core);_defineProperty(this,"isOptOut",function(){return isOptOut();});_defineProperty(this,"getScannerEvents",function(){return scannerEvents;});_defineProperty(this,"buildAdImageIdentifierName",function(pageTitle,id){var name=pageTitle?"".concat(pageTitle," "):'';return"".concat(name,"(id: ").concat(id,")");});_defineProperty(this,"crossDomainTracking",function(originalUrl,formElement){if(window.sgData&&window.sgData.device.access==='App'){return false;}var newUrl=originalUrl;// Add econda params
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
6
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
7
27
  if(!window.sgData){return newUrl;}// Universal
8
28
  try{window.ga(function(){var tracker=window.ga.getByName('shopgate');var linker=new window.gaplugins.Linker(tracker);// Add ?_ga parameter to the url
@@ -44,7 +64,7 @@ if([REMOVE_TRACKER,ADD_TRACKER].indexOf(event)!==-1){return;}/**
44
64
  * @param {string} eventName Name of the event
45
65
  * @param {string} [page] Identifier of the page
46
66
  * @returns {Object} The event store for the given eventName and page
47
- */_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
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
48
68
  this.events[eventName]={// Events for every page
49
69
  global:[],// Events only for specific pages
50
70
  specific:{}};}// Get the global events for the current event name
@@ -105,18 +125,14 @@ this.triggeredEvents.push({"function":this.notifyHelper,params:[rawData,eventNam
105
125
  * @returns {boolean|null} State which was set
106
126
  */},{key:"optOut",value:function optOut(optOutParam){var out=optOutParam;if(typeof optOutParam==='undefined'){out=true;}if(out){// Notify Plugins about the removal.
107
127
  this.notifyPlugins(null,REMOVE_TRACKER);}else{// Notify Plugins about the adding
108
- this.notifyPlugins(null,ADD_TRACKER);}return _optOut(out);}/**
109
- * Check if the opt-out state is set
110
- *
111
- * @returns {boolean} Information about the opt out state
112
- */},{key:"registerFinished",/**
128
+ this.notifyPlugins(null,ADD_TRACKER);}return _optOut(out);}},{key:"registerFinished",value:/**
113
129
  * Called from the outside when all plugins are registered
114
130
  * @return {Core}
115
- */value:function registerFinished(){var _this3=this;if(this.registerFinish){return this;}// Trigger all events that happened till now
131
+ */function registerFinished(){var _this3=this;if(this.registerFinish){return this;}// Trigger all events that happened till now
116
132
  this.triggeredEvents.forEach(function(entry){entry["function"].apply(_this3,entry.params);});this.registerFinish=true;// Reset the event store
117
133
  this.triggeredEvents=[];return this;}/**
118
134
  * Remove all registered callbacks. Only used and needed for unit tests
119
135
  * @returns {Core}
120
- */},{key:"reset",value:function reset(){this.events={};this.triggeredEvents=[];this.registerFinish=false;return this;}}]);return Core;}();/**
136
+ */},{key:"reset",value:function reset(){this.events={};this.triggeredEvents=[];this.registerFinish=false;return this;}}]);}();/**
121
137
  * Fix to prevent multiple instances of this class caused by two node_modules folders
122
138
  */if(!window.SgTrackingCore){window.SgTrackingCore=new Core();}export default window.SgTrackingCore;
package/helpers/helper.js CHANGED
@@ -12,24 +12,28 @@ return String.fromCharCode.apply(String,ret);};/**
12
12
  */export function sendDataRequest(url){new DataRequest(url).dispatch().then(function(result){return logger.info(url,result);})["catch"](function(err){return err&&logger.error(err);});}/**
13
13
  * Object representation of URI(RFC2396) string
14
14
  * Made for general purpose. Feel free to extend it for your needs.
15
- */export var SGLink=/*#__PURE__*/function(){// Complete url string
16
- // Any scheme we support (ex. https|shopgate-{$number}|sgapi)
17
- // Endpoint - safe for shopgate (ex. no endpoint is converted to "index")
18
- /**
15
+ */export var SGLink=/*#__PURE__*/function(){/**
19
16
  * Constructor
20
17
  * @param {string} url Url to creating SGLink from
21
- */function SGLink(url){var _this=this;_classCallCheck(this,SGLink);_defineProperty(this,"url",'');_defineProperty(this,"scheme",'');_defineProperty(this,"authority",'');_defineProperty(this,"path",'');_defineProperty(this,"splittedPath",[]);_defineProperty(this,"query",'');_defineProperty(this,"action",'');_defineProperty(this,"params",{});_defineProperty(this,"isDeepLink",false);_defineProperty(this,"toRelativeString",function(){var leadingSlash=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var outputUrl='';if(leadingSlash&&_this.path[0]!=='/'){outputUrl='/';}if(_this.path){outputUrl+=SGLink.encodeURISafe(_this.path);}if(_this.query){// .query is always encoded
18
+ */function SGLink(url){var _this=this;_classCallCheck(this,SGLink);// Complete url string
19
+ _defineProperty(this,"url",'');// Any scheme we support (ex. https|shopgate-{$number}|sgapi)
20
+ _defineProperty(this,"scheme",'');_defineProperty(this,"authority",'');_defineProperty(this,"path",'');_defineProperty(this,"splittedPath",[]);_defineProperty(this,"query",'');// Endpoint - safe for shopgate (ex. no endpoint is converted to "index")
21
+ _defineProperty(this,"action",'');_defineProperty(this,"params",{});_defineProperty(this,"isDeepLink",false);/**
22
+ * Converts the object to relative url
23
+ * @param {boolean} [leadingSlash=true] Tells if the url shall start with a leading slash
24
+ * @return {string}
25
+ */_defineProperty(this,"toRelativeString",function(){var leadingSlash=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var outputUrl='';if(leadingSlash&&_this.path[0]!=='/'){outputUrl='/';}if(_this.path){outputUrl+=SGLink.encodeURISafe(_this.path);}if(_this.query){// .query is always encoded
22
26
  outputUrl+="?".concat(_this.query);}return outputUrl;});this.url=url;this.parseUrl(url);}/**
23
27
  * Encode the url with encodeURIComponent and
24
28
  * takes care of double encoding
25
29
  *
26
30
  * @param {string} string - string to be encoded
27
31
  * @return {string}
28
- */_createClass(SGLink,[{key:"parseUrl",/**
32
+ */return _createClass(SGLink,[{key:"parseUrl",value:/**
29
33
  * Parses url and extracts path, query, action, splittedPath, ...
30
34
  *
31
35
  * @param {string} incomingUrl The url that shall be parsed.
32
- */value:function parseUrl(incomingUrl){var urlToSanitize=incomingUrl;if(!urlToSanitize){urlToSanitize='';}var commonSchemas=['http','https','tel','mailto'];// Based on the regex in RFC2396 Appendix B.
36
+ */function parseUrl(incomingUrl){var urlToSanitize=incomingUrl;if(!urlToSanitize){urlToSanitize='';}var commonSchemas=['http','https','tel','mailto'];// Based on the regex in RFC2396 Appendix B.
33
37
  var parser=/^(?:([^:/?#]+):)?(?:\/\/([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/;var result=urlToSanitize.match(parser);if(!this.isDeepLink&&result[1]&&commonSchemas.indexOf(result[1])===-1){this.isDeepLink=true;var scheme="".concat(result[1],"://");/**
34
38
  * Add slash so that we can parse the attributes properly
35
39
  * (for shopgate-standalone://cart we would get e.g. "authority: cart" which is wrong)
@@ -58,18 +62,14 @@ this.setParams({});for(var i=0;i<queryPartsLength;i+=1){var queryPair=queryParts
58
62
  * @return {string}
59
63
  */},{key:"toString",value:function toString(){var outputUrl='';var notNavigatorSchema=['mailto','tel'].indexOf(this.scheme)>-1;if(this.scheme){outputUrl+=this.scheme;// The sgapi-links don't need further scheme parsing since the scheme is 'sgapi:'
60
64
  if(this.scheme!=='sgapi'){if(notNavigatorSchema){if(this.scheme.indexOf(':')===-1){outputUrl+=':';}}else{if(this.scheme.indexOf(':/')===-1){// If the scheme already contains :/ we don't want to add it again
61
- outputUrl+=':/';this.scheme=outputUrl;}if(!this.isDeepLink){outputUrl+='/';}}}else if(this.scheme.indexOf(':')===-1){outputUrl+=':';}}if(this.authority){outputUrl+=this.authority;}outputUrl+=this.toRelativeString(false);return outputUrl;}/**
62
- * Converts the object to relative url
63
- * @param {boolean} [leadingSlash=true] Tells if the url shall start with a leading slash
64
- * @return {string}
65
- */},{key:"setUtmParams",/**
65
+ outputUrl+=':/';this.scheme=outputUrl;}if(!this.isDeepLink){outputUrl+='/';}}}else if(this.scheme.indexOf(':')===-1){outputUrl+=':';}}if(this.authority){outputUrl+=this.authority;}outputUrl+=this.toRelativeString(false);return outputUrl;}},{key:"setUtmParams",value:/**
66
66
  * Sets utm param from event.
67
67
  * @param {Object} data event data
68
68
  * @param {Object} raw event raw data
69
- */value:function setUtmParams(data,raw){// Add fake params, only if it didn't come from branch.io
69
+ */function setUtmParams(data,raw){// Add fake params, only if it didn't come from branch.io
70
70
  if(raw.type!=='branchio'){this.setParam('utm_source','shopgate');this.setParam('utm_medium',raw.type);}if(raw.type==='push_message'){var campaigns=['cart_reminder','inactive_app_user'];var notificationId=raw.notificationId||'not-provided';var campaignName=this.getParam('utm_campaign');if(campaigns.indexOf(campaignName)!==-1){// Set utm_content to distinguish the cart reminders from "normal" push messages
71
71
  this.setParam('utm_content',campaignName);}this.setParam('utm_campaign',"push-".concat(notificationId));}}}],[{key:"encodeURIComponentSafe",value:function encodeURIComponentSafe(string){var decoded=decodeURIComponent(string);if(decoded!==string){return string;}return encodeURIComponent(string);}/**
72
72
  * Encode the url and takes care of double encoding
73
73
  * @param {string} string String to be encoded
74
74
  * @returns {string} encoded string
75
- */},{key:"encodeURISafe",value:function encodeURISafe(string){var decoded=decodeURI(string);if(decoded!==string){return string;}return encodeURI(string);}}]);return SGLink;}();
75
+ */},{key:"encodeURISafe",value:function encodeURISafe(string){var decoded=decodeURI(string);if(decoded!==string){return string;}return encodeURI(string);}}]);}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/tracking-core",
3
- "version": "7.12.3",
3
+ "version": "7.20.0-beta.2",
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.12.3",
20
- "@shopgate/pwa-core": "7.12.3",
19
+ "@shopgate/eslint-config": "7.20.0-beta.2",
20
+ "@shopgate/pwa-core": "7.20.0-beta.2",
21
21
  "chai": "^3.5.0",
22
22
  "jsdom": "^10.0.0",
23
23
  "mocha": "^3.1.0",
package/plugins/Base.js CHANGED
@@ -22,7 +22,7 @@ this.options=_extends({},defaults,{},extendedDefaults,{},options);this.trackingD
22
22
  * @param {string} eventName Name of the tracking event
23
23
  * @param {Object} rawData Raw data from the core
24
24
  * @returns {*} The converted data
25
- */_createClass(Base,[{key:"registerHelper",/**
25
+ */return _createClass(Base,[{key:"registerHelper",value:/**
26
26
  * Helper function to register a plugin for a specific event. Can be overwritten in the plugins.
27
27
  *
28
28
  * @param {string} eventName Name of the event
@@ -30,7 +30,7 @@ this.options=_extends({},defaults,{},extendedDefaults,{},options);this.trackingD
30
30
  * @param {Object} options Additional options that will be passed to the core
31
31
  * @returns {RemoveListener} Function to remove the listener
32
32
  * @private
33
- */value:function registerHelper(eventName,callback,options){var _this2=this;// Register the tracking event of the plugin at the core
33
+ */function registerHelper(eventName,callback,options){var _this2=this;// Register the tracking event of the plugin at the core
34
34
  return this.trackingCore.register[eventName](function(data,scope,blacklist,state){// Convert the tracking data into the unified format
35
35
  var unifiedData=Base.formatData(eventName,data);// Invoke the event callback of the plugin to enable it to extend the data
36
36
  var finalData=callback(unifiedData,data,scope,state);// If final data is explicitly false, it means further processing is up to the plugin only.
@@ -45,4 +45,4 @@ _this2.appHandler[eventName](finalData,{blacklist:false,trackers:[_this2.tracker
45
45
  * @returns {Base} The instance of the plugin
46
46
  */},{key:"enableTracking",value:function enableTracking(){this.trackingDisabled=false;return this;}}],[{key:"formatData",value:function formatData(eventName,rawData){// Check if a suitable conversion function is available
47
47
  if(typeof dataFormatHelpers[eventName]!=='function'){return rawData;}// Convert the raw data
48
- return dataFormatHelpers[eventName](rawData);}}]);return Base;}();export default Base;
48
+ return dataFormatHelpers[eventName](rawData);}}]);}();export default Base;
@@ -1,6 +1,6 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}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 _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}/* global fbq */import{logger}from'@shopgate/pwa-core/helpers';import BasePlugin from"../Base";/**
1
+ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}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 _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}/* global fbq */import{logger}from'@shopgate/pwa-core/helpers';import BasePlugin from"../Base";/**
2
2
  * Tracking plugin for Facebook
3
- */var FbPixel=/*#__PURE__*/function(_BasePlugin){_inherits(FbPixel,_BasePlugin);/**
3
+ */var FbPixel=/*#__PURE__*/function(_BasePlugin){/**
4
4
  * Constructor
5
5
  *
6
6
  * @param {Object} options Common Tracking Configuration
@@ -9,9 +9,9 @@ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="s
9
9
  * to the native sdk
10
10
  * @param {Object} [options.config] Configuration for facebook pixel tracking
11
11
  * @param {Array} [options.config.pixelIds] List of Facebook pixels
12
- */function FbPixel(options){var _this;_classCallCheck(this,FbPixel);var trackerName='facebookPixel';var extendedDefaults={config:{pixelIds:[]}};_this=_possibleConstructorReturn(this,_getPrototypeOf(FbPixel).call(this,trackerName,options,extendedDefaults));if(_this.options.useNativeSdk){logger.warn('SgFbPixelTracking: no native SDK support for this plugin');return _possibleConstructorReturn(_this);}if(!_this.options.config.pixelIds.length){logger.warn('SgFbPixelTracking: pixels missing');return _possibleConstructorReturn(_this);}_this.initPlugin();return _this;}/**
12
+ */function FbPixel(options){var _this2;_classCallCheck(this,FbPixel);var trackerName='facebookPixel';var extendedDefaults={config:{pixelIds:[]}};_this2=_callSuper(this,FbPixel,[trackerName,options,extendedDefaults]);if(_this2.options.useNativeSdk){logger.warn('SgFbPixelTracking: no native SDK support for this plugin');return _possibleConstructorReturn(_this2);}if(!_this2.options.config.pixelIds.length){logger.warn('SgFbPixelTracking: pixels missing');return _possibleConstructorReturn(_this2);}_this2.initPlugin();return _this2;}/**
13
13
  * Initiate and setup the SDK
14
- */_createClass(FbPixel,[{key:"initPlugin",value:function initPlugin(){var _this2=this;// Load the fb pixel tracking sdk
14
+ */_inherits(FbPixel,_BasePlugin);return _createClass(FbPixel,[{key:"initPlugin",value:function initPlugin(){var _this3=this;// Load the fb pixel tracking sdk
15
15
  /* eslint-disable eslint-comments/no-unlimited-disable */ /* eslint-disable */!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments);};if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s);}(window,document,'script','https://connect.facebook.net/en_US/fbevents.js');/* eslint-enable */var pixelsForInit=this.options.config.pixelIds.slice(0);var firstPixel=pixelsForInit.shift();FbPixel.sendToFb(firstPixel.toString(),undefined,'init');/*
16
16
  * Add multiple pixel Ids.
17
17
  * Warning: This is not official supported by facebook, but seems to work
@@ -19,26 +19,26 @@ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="s
19
19
  * The pixel tracking have a PageView und ViewContent Event. The PageView event should be called
20
20
  * on every page. It has no params
21
21
  */FbPixel.sendToFb('PageView');// Register for some events
22
- /* eslint-disable camelcase */this.register.completedRegistration(function(data){FbPixel.sendToFb('CompleteRegistration',{content_name:data.registrationMethod});});this.register.viewContent(function(data,rawData){var fbParams={content_type:data.type};if(data.type==='product'&&typeof rawData!=='undefined'){fbParams.content_ids=[data.id];fbParams.content_name=rawData.product.name;fbParams.value=parseFloat(_this2.getPrice(rawData.product.amount));fbParams.currency=rawData.product.amount.currency;}else{fbParams.content_ids=[data.id];fbParams.content_name=data.name;}FbPixel.sendToFb('ViewContent',fbParams);});this.register.addedPaymentInfo(function(){FbPixel.sendToFb('AddPaymentInfo');});this.register.purchase(function(data){var productIds=FbPixel.getProductIds(data.items);var fbParams={content_ids:productIds,content_type:data.type,value:_this2.getPrice(data),currency:data.currency};if(productIds.length===1){fbParams.content_name=data.items[0].name;}FbPixel.sendToFb('Purchase',fbParams);});this.register.initiatedCheckout(function(data,rawData){var productIds=FbPixel.getProductIds(rawData.cart.products);var fbParams={content_ids:productIds,content_type:'product',value:_this2.getPrice(data),currency:data.currency,num_items:data.numItems};if(productIds.length===1){fbParams.content_name=rawData.cart.products[0].name;}FbPixel.sendToFb('InitiateCheckout',fbParams);});this.register.addToCart(function(data){FbPixel.sendToFb('AddToCart',_this2.getParamsForAddToCartAndWishlist(data));});this.register.addToWishlist(function(data){FbPixel.sendToFb('AddToWishlist',_this2.getParamsForAddToCartAndWishlist(data));});this.register.search(function(data,rawData){var productIds=FbPixel.getProductIds(rawData.products);var fbParams={content_ids:productIds,content_type:data.type,search_string:data.query};FbPixel.sendToFb('Search',fbParams);});}/**
22
+ /* eslint-disable camelcase */this.register.completedRegistration(function(data){FbPixel.sendToFb('CompleteRegistration',{content_name:data.registrationMethod});});this.register.viewContent(function(data,rawData){var fbParams={content_type:data.type};if(data.type==='product'&&typeof rawData!=='undefined'){fbParams.content_ids=[data.id];fbParams.content_name=rawData.product.name;fbParams.value=parseFloat(_this3.getPrice(rawData.product.amount));fbParams.currency=rawData.product.amount.currency;}else{fbParams.content_ids=[data.id];fbParams.content_name=data.name;}FbPixel.sendToFb('ViewContent',fbParams);});this.register.addedPaymentInfo(function(){FbPixel.sendToFb('AddPaymentInfo');});this.register.purchase(function(data){var productIds=FbPixel.getProductIds(data.items);var fbParams={content_ids:productIds,content_type:data.type,value:_this3.getPrice(data),currency:data.currency};if(productIds.length===1){fbParams.content_name=data.items[0].name;}FbPixel.sendToFb('Purchase',fbParams);});this.register.initiatedCheckout(function(data,rawData){var productIds=FbPixel.getProductIds(rawData.cart.products);var fbParams={content_ids:productIds,content_type:'product',value:_this3.getPrice(data),currency:data.currency,num_items:data.numItems};if(productIds.length===1){fbParams.content_name=rawData.cart.products[0].name;}FbPixel.sendToFb('InitiateCheckout',fbParams);});this.register.addToCart(function(data){FbPixel.sendToFb('AddToCart',_this3.getParamsForAddToCartAndWishlist(data));});this.register.addToWishlist(function(data){FbPixel.sendToFb('AddToWishlist',_this3.getParamsForAddToCartAndWishlist(data));});this.register.search(function(data,rawData){var productIds=FbPixel.getProductIds(rawData.products);var fbParams={content_ids:productIds,content_type:data.type,search_string:data.query};FbPixel.sendToFb('Search',fbParams);});}/**
23
23
  * Send data to the facebook tracker
24
24
  * @param {string} eventName Name of the event
25
25
  * @param {Object} [params] Params for the event
26
26
  * @param {string} [typeParam] Type of the tracker call
27
27
  * @returns {void}
28
- */},{key:"getPrice",/**
28
+ */},{key:"getPrice",value:/**
29
29
  * Returns the correct price net or gross price. Depending on this.options.useNetPrices
30
30
  *
31
31
  * @param {Object} amount Price Object
32
32
  * @returns {number|string} net or gross price
33
- */value:function getPrice(amount){if(this.options.useNetPrices){return amount.priceNet||amount.valueNet||amount.net||amount.revenueNet;}return amount.priceGross||amount.valueGross||amount.gross||amount.revenueGross;}/**
33
+ */function getPrice(amount){if(this.options.useNetPrices){return amount.priceNet||amount.valueNet||amount.net||amount.revenueNet;}return amount.priceGross||amount.valueGross||amount.gross||amount.revenueGross;}/**
34
34
  * Returns the params for the AddToCart and AddToWishlist events
35
35
  *
36
36
  * @param {Object} data Converted data from the parent plugin
37
37
  * @returns {Object} Params for the fb event
38
- */},{key:"getParamsForAddToCartAndWishlist",value:function getParamsForAddToCartAndWishlist(data){var _this3=this;var productIds=FbPixel.getProductIds(data.items);var value=0;var currency='EUR';data.items.forEach(function(item){value+=_this3.getPrice(item);currency=item.currency;// eslint-disable-line prefer-destructuring
38
+ */},{key:"getParamsForAddToCartAndWishlist",value:function getParamsForAddToCartAndWishlist(data){var _this4=this;var productIds=FbPixel.getProductIds(data.items);var value=0;var currency='EUR';data.items.forEach(function(item){value+=_this4.getPrice(item);currency=item.currency;// eslint-disable-line prefer-destructuring
39
39
  });var fbParams={content_ids:productIds,content_type:data.type,value:value,currency:currency};if(productIds.length===1){fbParams.content_name=data.items[0].name;}return fbParams;}/* eslint-enable camelcase */}],[{key:"sendToFb",value:function sendToFb(eventName,params,typeParam){var type=typeParam||'track';fbq(type,eventName,params);}/**
40
40
  * Extract the product Ids from an array with products
41
41
  *
42
42
  * @param {Array} products Array with products
43
43
  * @returns {Array} Array of product Ids
44
- */},{key:"getProductIds",value:function getProductIds(products){return products.map(function(product){return product.productNumber||product.uid||product.id;});}}]);return FbPixel;}(BasePlugin);window.SgFbPixelTracking=FbPixel;export default FbPixel;
44
+ */},{key:"getProductIds",value:function getProductIds(products){return products.map(function(product){return product.productNumber||product.uid||product.id;});}}]);}(BasePlugin);window.SgFbPixelTracking=FbPixel;export default FbPixel;
@@ -1,10 +1,10 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}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 _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}import BasePlugin from"../Base";import SgGAUniversalTracking from"./GaUniversal";import SgGAClassicTracking from"./GaClassic";import{SGLink}from"../../helpers/helper";var TRACK_PAGE_VIEW='pageView';var TRACK_EVENT='event';var TRACK_SET='set';var TRACK_REQUIRE='require';var TRACK_CONVERSION={ADDITEM:'addItem',CURRENCY:'currencyCode',END:'trackTrans',START:'addTrans',PAGE:'page'};var ACCOUNT_CLASSIC='classic';var ACCOUNT_UNIVERSAL='universal';var shopgateOnly={merchant:false,shopgate:true};var merchantOnly={merchant:true,shopgate:false};// Command mapping tuple, [classic, universal]
1
+ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}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 _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}import BasePlugin from"../Base";import SgGAUniversalTracking from"./GaUniversal";import SgGAClassicTracking from"./GaClassic";import{SGLink}from"../../helpers/helper";var TRACK_PAGE_VIEW='pageView';var TRACK_EVENT='event';var TRACK_SET='set';var TRACK_REQUIRE='require';var TRACK_CONVERSION={ADDITEM:'addItem',CURRENCY:'currencyCode',END:'trackTrans',START:'addTrans',PAGE:'page'};var ACCOUNT_CLASSIC='classic';var ACCOUNT_UNIVERSAL='universal';var shopgateOnly={merchant:false,shopgate:true};var merchantOnly={merchant:true,shopgate:false};// Command mapping tuple, [classic, universal]
2
2
  var commandMapping={};commandMapping[TRACK_PAGE_VIEW]=['trackPageview','pageview'];commandMapping[TRACK_EVENT]=['trackEvent','event'];commandMapping[TRACK_SET]=[undefined,'set'];commandMapping[TRACK_CONVERSION.ADDITEM]=['addItem','ecommerce:addItem'];commandMapping[TRACK_CONVERSION.CURRENCY]=['currencyCode'];commandMapping[TRACK_CONVERSION.END]=['trackTrans','ecommerce:send'];commandMapping[TRACK_CONVERSION.START]=['addTrans','ecommerce:addTransaction'];commandMapping[TRACK_REQUIRE]=[undefined,'require'];/**
3
3
  * Parent Tracking plugin for Google Analytics
4
- */var GaBase=/*#__PURE__*/function(_BasePlugin){_inherits(GaBase,_BasePlugin);/**
4
+ */var GaBase=/*#__PURE__*/function(_BasePlugin){/**
5
5
  * Constructor
6
- */function GaBase(){var _this;_classCallCheck(this,GaBase);_this=_possibleConstructorReturn(this,_getPrototypeOf(GaBase).call(this,'GAcore',{}));// Universal and classic merchant and shopgate accounts
7
- _this.accounts=[];_this.isRegistered=false;_this.universalPlugin=null;_this.classicPlugin=null;return _this;}/**
6
+ */function GaBase(){var _this2;_classCallCheck(this,GaBase);_this2=_callSuper(this,GaBase,['GAcore',{}]);// Universal and classic merchant and shopgate accounts
7
+ _this2.accounts=[];_this2.isRegistered=false;_this2.universalPlugin=null;_this2.classicPlugin=null;return _this2;}/**
8
8
  * Returns common data for a custom event
9
9
  * @param {string} name Event category
10
10
  * @param {Object} data Input
@@ -16,7 +16,7 @@ _this.accounts=[];_this.isRegistered=false;_this.universalPlugin=null;_this.clas
16
16
  * nonInteraction: (boolean)
17
17
  * }}
18
18
  * @private
19
- */_createClass(GaBase,[{key:"sendCommand",/**
19
+ */_inherits(GaBase,_BasePlugin);return _createClass(GaBase,[{key:"sendCommand",value:/**
20
20
  * Send command to both universal and classic sdk
21
21
  *
22
22
  * @param {string} command Name of the command
@@ -25,30 +25,30 @@ _this.accounts=[];_this.isRegistered=false;_this.universalPlugin=null;_this.clas
25
25
  * @param {Object} [scope] Scope (merchant or shopgate account)
26
26
  * @param {string} [account] Which account to use, classic or universal
27
27
  * @private
28
- */value:function sendCommand(command,payload,scope,account){if(typeof commandMapping[command]==='undefined'){return;}// Evaluate which accounts to send to.
28
+ */function sendCommand(command,payload,scope,account){if(typeof commandMapping[command]==='undefined'){return;}// Evaluate which accounts to send to.
29
29
  var isClassic=typeof account==='undefined'||account===ACCOUNT_CLASSIC;var isUniversal=typeof account==='undefined'||account===ACCOUNT_UNIVERSAL;if(isUniversal&&this.universalPlugin!==null){this.universalPlugin.send(commandMapping[command][1],payload,scope);}if(isClassic&&this.classicPlugin!==null){this.classicPlugin.send(commandMapping[command][0],payload,scope);}}/**
30
30
  * Helper to register for some events
31
31
  * @private
32
- */},{key:"registerEvents",value:function registerEvents(){var _this2=this;if(this.isRegistered){return;}this.isRegistered=true;// Handle pageview event for shopgate accounts
33
- this.register.pageview(function(data){_this2.sendCommand(TRACK_PAGE_VIEW,data.page.shopgateUrl,shopgateOnly);},shopgateOnly);// Handle pageview event for merchant account
34
- this.register.pageview(function(data){_this2.sendCommand(TRACK_PAGE_VIEW,data.page.merchantUrl,merchantOnly);},merchantOnly);// Handle add_to_cart event as a pageview
35
- this.register.addToCart(function(){_this2.sendCommand(TRACK_PAGE_VIEW,'add_to_cart');});// Smart app banner
36
- this.register.smartbanner(function(data){_this2.sendCommand(TRACK_EVENT,GaBase.getEventData('Smartbanner',data));});// Scroll to top button event
37
- this.register.scrollTop(function(data){_this2.sendCommand(TRACK_EVENT,GaBase.getEventData('ScrollTop',data),shopgateOnly);});// Qr scanner events
38
- this.register.qrScanner(function(data){_this2.sendCommand(TRACK_EVENT,GaBase.getEventData('QRScanner',data));});// Ad scanner events
39
- this.register.adScanner(function(data,originalData,scope){_this2.sendCommand(TRACK_EVENT,GaBase.getEventData('AdScanner',data),scope);});// Credit card scanner events
40
- this.register.ccScanner(function(data){_this2.sendCommand(TRACK_EVENT,GaBase.getEventData('CcScanner',data));});// Filter in live suggest events
41
- this.register.filterLiveSuggest(function(data){_this2.sendCommand(TRACK_EVENT,GaBase.getEventData('FilterLiveSuggest',data),shopgateOnly);});// Deeplink
42
- this.register.openDeepLink(function(data){_this2.sendCommand(TRACK_EVENT,GaBase.getEventData('DeepLinkOpen',data),shopgateOnly);});// Universal link
43
- this.register.openUniversalLink(function(data){_this2.sendCommand(TRACK_EVENT,GaBase.getEventData('UniversalLinkOpen',data),shopgateOnly);});// Deferred deep link
44
- this.register.openDeferredDeepLink(function(data){_this2.sendCommand(TRACK_EVENT,GaBase.getEventData('DeferredDeepLinkOpen',data),shopgateOnly);});// Smart app download link
45
- this.register.openSmartAppDownloadLink(function(data){_this2.sendCommand(TRACK_EVENT,GaBase.getEventData('SmartAppDownloadLink',data),shopgateOnly);});// Push notification
46
- this.register.openPushNotification(function(data){_this2.sendCommand(TRACK_EVENT,GaBase.getEventData('PushNotification',data),shopgateOnly);});// Push notification
47
- this.register.setCampaignWithUrl(function(data,raw){var shopgateUrl=new SGLink(data.url);shopgateUrl.setUtmParams(data,raw);_this2.sendCommand(TRACK_SET,['campaignName',shopgateUrl.getParam('utm_campaign')],undefined,ACCOUNT_UNIVERSAL);_this2.sendCommand(TRACK_SET,['campaignSource',shopgateUrl.getParam('utm_source')],undefined,ACCOUNT_UNIVERSAL);_this2.sendCommand(TRACK_SET,['campaignMedium',shopgateUrl.getParam('utm_medium')],undefined,ACCOUNT_UNIVERSAL);});// App review prompt
48
- this.register.appReviewPrompt(function(data){_this2.sendCommand(TRACK_EVENT,GaBase.getEventData('AppReviewPrompt',data),shopgateOnly);});// Purchase events
49
- this.register.purchase(function(data,rawData){_this2.sendCommand('require',['ecommerce','ecommerce.js'],null,ACCOUNT_UNIVERSAL);_this2.sendCommand(TRACK_CONVERSION.START,function(account){return{amountCompleteFloat:account.useNetPrices?data.revenueNet:data.revenueGross,amountTaxCompleteFloat:data.tax,amountShippingFloat:account.useNetPrices?data.shippingNet:data.shippingGross,city:rawData.order.shippingAddress.city,countryId:rawData.order.shippingAddress.country,currency:data.currency,orderNumber:data.id,shopName:data.affiliation,state:rawData.order.shippingAddress.stateId||''};});data.items.forEach(function(item){_this2.sendCommand(TRACK_CONVERSION.ADDITEM,function(account){return{orderNumber:rawData.order.number,productNumber:item.id,name:item.name,quantity:item.quantity,unitAmount:account.useNetPrices?item.priceNet:item.priceGross};});});_this2.sendCommand(TRACK_SET,[TRACK_CONVERSION.CURRENCY,data.currency],null,ACCOUNT_CLASSIC);_this2.sendCommand(TRACK_CONVERSION.END);});// Opt-out
50
- this.register.removeTracker(function(){_this2.sendCommand(TRACK_EVENT,GaBase.getEventData('analyticsOptOut',{eventAction:'optOut',eventLabel:'all_accounts'}));_this2.accounts.forEach(function(account){var disableStr="ga-disable-".concat(account.id);document.cookie="".concat(disableStr,"=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/");window[disableStr]=true;});});// Revert opt-out
51
- this.register.addTracker(function(){_this2.accounts.forEach(function(account){var disableStr="ga-disable-".concat(account.id);document.cookie="".concat(disableStr,"=false; expires=Thu, 01 Jan 1970 00:00:01 UTC; path=/");window[disableStr]=false;});_this2.sendCommand(TRACK_EVENT,GaBase.getEventData('revertOptOut',{eventAction:'optOut',eventLabel:'all_accounts'}));});}/**
32
+ */},{key:"registerEvents",value:function registerEvents(){var _this3=this;if(this.isRegistered){return;}this.isRegistered=true;// Handle pageview event for shopgate accounts
33
+ this.register.pageview(function(data){_this3.sendCommand(TRACK_PAGE_VIEW,data.page.shopgateUrl,shopgateOnly);},shopgateOnly);// Handle pageview event for merchant account
34
+ this.register.pageview(function(data){_this3.sendCommand(TRACK_PAGE_VIEW,data.page.merchantUrl,merchantOnly);},merchantOnly);// Handle add_to_cart event as a pageview
35
+ this.register.addToCart(function(){_this3.sendCommand(TRACK_PAGE_VIEW,'add_to_cart');});// Smart app banner
36
+ this.register.smartbanner(function(data){_this3.sendCommand(TRACK_EVENT,GaBase.getEventData('Smartbanner',data));});// Scroll to top button event
37
+ this.register.scrollTop(function(data){_this3.sendCommand(TRACK_EVENT,GaBase.getEventData('ScrollTop',data),shopgateOnly);});// Qr scanner events
38
+ this.register.qrScanner(function(data){_this3.sendCommand(TRACK_EVENT,GaBase.getEventData('QRScanner',data));});// Ad scanner events
39
+ this.register.adScanner(function(data,originalData,scope){_this3.sendCommand(TRACK_EVENT,GaBase.getEventData('AdScanner',data),scope);});// Credit card scanner events
40
+ this.register.ccScanner(function(data){_this3.sendCommand(TRACK_EVENT,GaBase.getEventData('CcScanner',data));});// Filter in live suggest events
41
+ this.register.filterLiveSuggest(function(data){_this3.sendCommand(TRACK_EVENT,GaBase.getEventData('FilterLiveSuggest',data),shopgateOnly);});// Deeplink
42
+ this.register.openDeepLink(function(data){_this3.sendCommand(TRACK_EVENT,GaBase.getEventData('DeepLinkOpen',data),shopgateOnly);});// Universal link
43
+ this.register.openUniversalLink(function(data){_this3.sendCommand(TRACK_EVENT,GaBase.getEventData('UniversalLinkOpen',data),shopgateOnly);});// Deferred deep link
44
+ this.register.openDeferredDeepLink(function(data){_this3.sendCommand(TRACK_EVENT,GaBase.getEventData('DeferredDeepLinkOpen',data),shopgateOnly);});// Smart app download link
45
+ this.register.openSmartAppDownloadLink(function(data){_this3.sendCommand(TRACK_EVENT,GaBase.getEventData('SmartAppDownloadLink',data),shopgateOnly);});// Push notification
46
+ this.register.openPushNotification(function(data){_this3.sendCommand(TRACK_EVENT,GaBase.getEventData('PushNotification',data),shopgateOnly);});// Push notification
47
+ this.register.setCampaignWithUrl(function(data,raw){var shopgateUrl=new SGLink(data.url);shopgateUrl.setUtmParams(data,raw);_this3.sendCommand(TRACK_SET,['campaignName',shopgateUrl.getParam('utm_campaign')],undefined,ACCOUNT_UNIVERSAL);_this3.sendCommand(TRACK_SET,['campaignSource',shopgateUrl.getParam('utm_source')],undefined,ACCOUNT_UNIVERSAL);_this3.sendCommand(TRACK_SET,['campaignMedium',shopgateUrl.getParam('utm_medium')],undefined,ACCOUNT_UNIVERSAL);});// App review prompt
48
+ this.register.appReviewPrompt(function(data){_this3.sendCommand(TRACK_EVENT,GaBase.getEventData('AppReviewPrompt',data),shopgateOnly);});// Purchase events
49
+ this.register.purchase(function(data,rawData){_this3.sendCommand('require',['ecommerce','ecommerce.js'],null,ACCOUNT_UNIVERSAL);_this3.sendCommand(TRACK_CONVERSION.START,function(account){return{amountCompleteFloat:account.useNetPrices?data.revenueNet:data.revenueGross,amountTaxCompleteFloat:data.tax,amountShippingFloat:account.useNetPrices?data.shippingNet:data.shippingGross,city:rawData.order.shippingAddress.city,countryId:rawData.order.shippingAddress.country,currency:data.currency,orderNumber:data.id,shopName:data.affiliation,state:rawData.order.shippingAddress.stateId||''};});data.items.forEach(function(item){_this3.sendCommand(TRACK_CONVERSION.ADDITEM,function(account){return{orderNumber:rawData.order.number,productNumber:item.id,name:item.name,quantity:item.quantity,unitAmount:account.useNetPrices?item.priceNet:item.priceGross};});});_this3.sendCommand(TRACK_SET,[TRACK_CONVERSION.CURRENCY,data.currency],null,ACCOUNT_CLASSIC);_this3.sendCommand(TRACK_CONVERSION.END);});// Opt-out
50
+ this.register.removeTracker(function(){_this3.sendCommand(TRACK_EVENT,GaBase.getEventData('analyticsOptOut',{eventAction:'optOut',eventLabel:'all_accounts'}));_this3.accounts.forEach(function(account){var disableStr="ga-disable-".concat(account.id);document.cookie="".concat(disableStr,"=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/");window[disableStr]=true;});});// Revert opt-out
51
+ this.register.addTracker(function(){_this3.accounts.forEach(function(account){var disableStr="ga-disable-".concat(account.id);document.cookie="".concat(disableStr,"=false; expires=Thu, 01 Jan 1970 00:00:01 UTC; path=/");window[disableStr]=false;});_this3.sendCommand(TRACK_EVENT,GaBase.getEventData('revertOptOut',{eventAction:'optOut',eventLabel:'all_accounts'}));});}/**
52
52
  * Creates an ga universals child tracker
53
53
  * @param {Object} tracker Tracker configuration data
54
54
  * @returns {GaUniversal} plugin instance
@@ -56,5 +56,5 @@ this.register.addTracker(function(){_this2.accounts.forEach(function(account){va
56
56
  * Creates a ga classic child tracker
57
57
  * @param {Object} tracker Tracker configuration data
58
58
  * @returns {GaClassic} plugin instance
59
- */},{key:"createClassic",value:function createClassic(tracker){var _this$accounts2;(_this$accounts2=this.accounts).push.apply(_this$accounts2,tracker.config.merchant);this.classicPlugin=new SgGAClassicTracking(tracker);this.registerEvents();return this.classicPlugin;}}],[{key:"getEventData",value:function getEventData(name,data){return{eventCategory:name,eventAction:data.eventAction,eventLabel:data.eventLabel,eventValue:data.eventValue,nonInteraction:data.nonInteraction};}}]);return GaBase;}(BasePlugin);// Export and create global instance
59
+ */},{key:"createClassic",value:function createClassic(tracker){var _this$accounts2;(_this$accounts2=this.accounts).push.apply(_this$accounts2,tracker.config.merchant);this.classicPlugin=new SgGAClassicTracking(tracker);this.registerEvents();return this.classicPlugin;}}],[{key:"getEventData",value:function getEventData(name,data){return{eventCategory:name,eventAction:data.eventAction,eventLabel:data.eventLabel,eventValue:data.eventValue,nonInteraction:data.nonInteraction};}}]);}(BasePlugin);// Export and create global instance
60
60
  window.SgGATrackingInstance=new GaBase();export default window.SgGATrackingInstance;
@@ -14,7 +14,7 @@ window._gaq=window._gaq||[];this.merchantAccounts=options.config.merchant;/**
14
14
  */this.filters={addTrans:function addTrans(data){return[data.orderNumber,data.shopName,data.amountCompleteFloat,data.amountTaxCompleteFloat,data.amountShippingFloat,data.city,'',// State
15
15
  data.countryId];},addItem:function addItem(data){return[data.orderNumber,data.productNumber,data.name,'',data.unitAmount,data.quantity];},trackEvent:function trackEvent(data){return[data.eventCategory,data.eventAction,data.eventLabel,data.eventValue,data.nonInteraction];}};this.initPlugin();}/**
16
16
  * Initiate and setup the SDK
17
- */_createClass(GaClassic,[{key:"initPlugin",value:function initPlugin(){// Load the SDK
17
+ */return _createClass(GaClassic,[{key:"initPlugin",value:function initPlugin(){// Load the SDK
18
18
  /* eslint-disable eslint-comments/no-unlimited-disable */ /* eslint-disable */if(typeof window._gaq==='undefined'||typeof window._gaq._getAsyncTracker==='undefined'||global&&global.it){(function(){var gaJs=document.createElement('script');gaJs.type='text/javascript';gaJs.async=true;gaJs.src='https://ssl.google-analytics.com/ga.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(gaJs,s);})();}/* eslint-enable */ // Setup merchant accounts
19
19
  this.merchantAccounts.forEach(function(account,index){var prefix="".concat(GaClassic.buildMerchantPrefix(index?account.id:''),".");_gaq.push(["".concat(prefix,"_setAccount"),account.id],["".concat(prefix,"_setAllowLinker"),true]);});// Set global options
20
20
  _gaq.push(['_gat._anonymizeIp',true],['_gat._forceSSL',true]);}/**
@@ -22,13 +22,13 @@ _gaq.push(['_gat._anonymizeIp',true],['_gat._forceSSL',true]);}/**
22
22
  *
23
23
  * @param {string} id Id of the account
24
24
  * @returns {string} Prefix for the account
25
- */},{key:"send",/**
25
+ */},{key:"send",value:/**
26
26
  * Function that sends the given command with the payload to the GA SDK
27
27
  * @param {string} command Name of the command
28
28
  * @param {Object|Array|string|Function} payload Data for the command,
29
29
  * or a function that returns data
30
30
  * @param {Object} [scope={}] Info if the event is for merchant and/or shopgate account
31
- */value:function send(command,payload){var _this=this;var scope=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var defaults={merchant:true,shopgate:true};var mergedScope=_extends({},defaults,{},scope);/**
31
+ */function send(command,payload){var _this=this;var scope=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var defaults={merchant:true,shopgate:true};var mergedScope=_extends({},defaults,{},scope);/**
32
32
  * Since we migrates all our classic account to universal,
33
33
  * Only the merchant can have classic accounts
34
- */if(mergedScope.merchant){this.merchantAccounts.forEach(function(account,index){var data=typeof payload==='function'?payload(account):payload;data=typeof _this.filters[command]!=='undefined'?_this.filters[command](data):data;var cmd="".concat(GaClassic.buildMerchantPrefix(index?account.id:''),"._").concat(command);if(Array.isArray(data)){_gaq.push([cmd].concat(data));}else{_gaq.push([cmd,data]);}});}}}],[{key:"buildMerchantPrefix",value:function buildMerchantPrefix(id){return"merchant_".concat(id);}}]);return GaClassic;}();export default GaClassic;
34
+ */if(mergedScope.merchant){this.merchantAccounts.forEach(function(account,index){var data=typeof payload==='function'?payload(account):payload;data=typeof _this.filters[command]!=='undefined'?_this.filters[command](data):data;var cmd="".concat(GaClassic.buildMerchantPrefix(index?account.id:''),"._").concat(command);if(Array.isArray(data)){_gaq.push([cmd].concat(data));}else{_gaq.push([cmd,data]);}});}}}],[{key:"buildMerchantPrefix",value:function buildMerchantPrefix(id){return"merchant_".concat(id);}}]);}();export default GaClassic;
@@ -19,7 +19,7 @@ var ACCESS_TYPE_APP='App';/**
19
19
  * @type {Object}
20
20
  */this.filters={'ecommerce:addTransaction':function ecommerceAddTransaction(data){return{revenue:data.amountCompleteFloat,tax:data.amountTaxCompleteFloat,shipping:data.amountShippingFloat,currency:data.currency,id:data.orderNumber,affiliation:data.shopName};},'ecommerce:addItem':function ecommerceAddItem(data){return{id:data.orderNumber,name:data.name,price:data.unitAmount,quantity:data.quantity,sku:data.productNumber};}};this.initPlugin();}/**
21
21
  * Initiate and setup the SDK
22
- */_createClass(GaUniversal,[{key:"initPlugin",value:function initPlugin(){var _this=this;// Load the SDK (if the code is executed form a unit test, always load the sdk)
22
+ */return _createClass(GaUniversal,[{key:"initPlugin",value:function initPlugin(){var _this=this;// Load the SDK (if the code is executed form a unit test, always load the sdk)
23
23
  if(typeof window.ga!=='function'||typeof global!=='undefined'&&typeof global.it==='function'){/* eslint-disable eslint-comments/no-unlimited-disable */ /* eslint-disable */(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments);},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m);})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');/* eslint-enable */}// Setup merchant accounts
24
24
  this.merchantAccounts.forEach(function(account){ga('create',{trackingId:account.id,cookieDomain:'auto',name:_this.buildMerchantPrefix(account.id),allowLinker:true});ga("".concat(_this.buildMerchantPrefix(account.id),".set"),'anonymizeIp',true);ga("".concat(_this.buildMerchantPrefix(account.id),".set"),'forceSSL',true);});// Setup shopgate account
25
25
  ga('create',{trackingId:this.shopgateAccount.id,cookieDomain:'auto',name:'shopgate',allowLinker:true});ga('shopgate.set','anonymizeIp',true);ga('shopgate.set','forceSSL',true);// Send custom variables to sdk
@@ -43,4 +43,4 @@ ga('shopgate.set',DIMENSION_SHOP_NUMBER,this.options.shopNumber||window.sgData.s
43
43
  * @param {Object} [scope={}] Info if the event is for merchant and/or shopgate account
44
44
  */},{key:"send",value:function send(command,payload){var _this2=this;var scope=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var defaults={merchant:true,shopgate:true};var useSendCmd=command!=='require'&&command!=='set'&&command.indexOf(':')===-1;var mergedScope=_extends({},defaults,{},scope);if(mergedScope.merchant){this.merchantAccounts.forEach(function(account){var data=typeof payload==='function'?payload(account):payload;data=typeof _this2.filters[command]!=='undefined'?_this2.filters[command](data):data;var merchantPrefix=_this2.buildMerchantPrefix(account.id);var cmd=[command];if(useSendCmd){cmd.unshift("".concat(merchantPrefix,".send"));}else{// We don't need the send command for example for ecommerce:addTransaction
45
45
  cmd[0]="".concat(merchantPrefix,".").concat(cmd[0]);}if(typeof data==='undefined'){ga.apply(void 0,cmd.slice());}else if(Array.isArray(data)){ga.apply(void 0,cmd.slice().concat(data));}else{ga.apply(void 0,cmd.slice().concat([data]));}});}if(mergedScope.shopgate){var data=typeof payload==='function'?payload(this.shopgateAccount):payload;data=typeof this.filters[command]!=='undefined'?this.filters[command](data):data;var cmd=[command];if(useSendCmd){cmd.unshift('shopgate.send');}else{// We don't need the send command for example for ecommerce:addTransaction
46
- cmd[0]="shopgate.".concat(cmd[0]);}if(typeof data==='undefined'){ga.apply(void 0,cmd.slice());}else if(Array.isArray(data)){ga.apply(void 0,cmd.slice().concat(data));}else{ga.apply(void 0,cmd.slice().concat([data]));}}}}]);return GaUniversal;}();export default GaUniversal;
46
+ cmd[0]="shopgate.".concat(cmd[0]);}if(typeof data==='undefined'){ga.apply(void 0,cmd.slice());}else if(Array.isArray(data)){ga.apply(void 0,cmd.slice().concat(data));}else{ga.apply(void 0,cmd.slice().concat([data]));}}}}]);}();export default GaUniversal;
@@ -1,11 +1,11 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}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 _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}import{sendDataRequest}from"../../helpers/helper";import BasePlugin from"../Base";/**
1
+ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}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 _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}import{sendDataRequest}from"../../helpers/helper";import BasePlugin from"../Base";/**
2
2
  * Tracking Plugin for our unified tracking system
3
- */var Unified=/*#__PURE__*/function(_BasePlugin){_inherits(Unified,_BasePlugin);/**
3
+ */var Unified=/*#__PURE__*/function(_BasePlugin){/**
4
4
  * @param {Object} [options] configuration
5
- */function Unified(){var _this;var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};_classCallCheck(this,Unified);var trackerName=options.trackerName||'unified';// Invoke the parent constructor
6
- _this=_possibleConstructorReturn(this,_getPrototypeOf(Unified).call(this,trackerName,options));_this.register.viewContent(function(data){return data;});_this.register.setCampaignWithUrl(function(data){return data;});_this.register.purchase(function(data){return data;});_this.register.addToCart(function(data){return data;});_this.register.initiatedCheckout(function(data){return data;});_this.register.completedRegistration(function(data){return data;});_this.register.addToWishlist(function(data){return data;});_this.register.search(function(data){return data;});_this.register.addedPaymentInfo(function(data){return data;});_this.trackingCore.register.removeTracker(function(){// Send request to server to remove the tracker
7
- sendDataRequest('remove_unified_trackers');},{trackerName:_this.trackerName,options:_this.options});_this.trackingCore.register.addTracker(function(){// Send request to server to add the tracker again
8
- sendDataRequest('add_unified_trackers');},{trackerName:_this.trackerName,options:_this.options});return _this;}/**
5
+ */function Unified(){var _this2;var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};_classCallCheck(this,Unified);var trackerName=options.trackerName||'unified';// Invoke the parent constructor
6
+ _this2=_callSuper(this,Unified,[trackerName,options]);_this2.register.viewContent(function(data){return data;});_this2.register.setCampaignWithUrl(function(data){return data;});_this2.register.purchase(function(data){return data;});_this2.register.addToCart(function(data){return data;});_this2.register.initiatedCheckout(function(data){return data;});_this2.register.completedRegistration(function(data){return data;});_this2.register.addToWishlist(function(data){return data;});_this2.register.search(function(data){return data;});_this2.register.addedPaymentInfo(function(data){return data;});_this2.trackingCore.register.removeTracker(function(){// Send request to server to remove the tracker
7
+ sendDataRequest('remove_unified_trackers');},{trackerName:_this2.trackerName,options:_this2.options});_this2.trackingCore.register.addTracker(function(){// Send request to server to add the tracker again
8
+ sendDataRequest('add_unified_trackers');},{trackerName:_this2.trackerName,options:_this2.options});return _this2;}/**
9
9
  * Helper function to register a plugin for a specific event. Overwrites the parent function with
10
10
  * special logic for the blacklist system.
11
11
  *
@@ -13,8 +13,8 @@ sendDataRequest('add_unified_trackers');},{trackerName:_this.trackerName,options
13
13
  * @param {Function} callback Callback from the plugin, to modify the data
14
14
  * @returns {RemoveListener} Function to remove the listener
15
15
  * @private
16
- */_createClass(Unified,[{key:"registerHelper",value:function registerHelper(eventName,callback){var _this2=this;// Register the tracking event of the plugin at the core
17
- return this.trackingCore.register[eventName](function(data,scope,blacklist,state){if(typeof _this2.appHandler[eventName]!=='function'){console.warn("this.appHandler[".concat(eventName,"] is not a function"));return;}// Convert the tracking data into the unified format
16
+ */_inherits(Unified,_BasePlugin);return _createClass(Unified,[{key:"registerHelper",value:function registerHelper(eventName,callback){var _this3=this;// Register the tracking event of the plugin at the core
17
+ return this.trackingCore.register[eventName](function(data,scope,blacklist,state){if(typeof _this3.appHandler[eventName]!=='function'){console.warn("this.appHandler[".concat(eventName,"] is not a function"));return;}// Convert the tracking data into the unified format
18
18
  var unifiedData=BasePlugin.formatData(eventName,data);// Invoke the event callback of the plugin to enable it to extend the data
19
19
  var finalData=callback(unifiedData,data,scope,state);// Send command to the app via the appHandler
20
- _this2.appHandler[eventName](finalData,{blacklist:true,trackers:blacklist});},{trackerName:this.trackerName,options:this.options});}}]);return Unified;}(BasePlugin);window.SgUnifiedTracking=Unified;export default Unified;
20
+ _this3.appHandler[eventName](finalData,{blacklist:true,trackers:blacklist});},{trackerName:this.trackerName,options:this.options});}}]);}(BasePlugin);window.SgUnifiedTracking=Unified;export default Unified;