@shopgate/pwa-tracking 6.23.0-beta.1 → 6.23.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/subscriptions/setup.js +7 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/pwa-tracking",
|
|
3
|
-
"version": "6.23.0-beta.
|
|
3
|
+
"version": "6.23.0-beta.3",
|
|
4
4
|
"description": "Tracking library for the Shopgate Connect PWA.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Shopgate <support@shopgate.com>",
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"connect"
|
|
16
16
|
],
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@shopgate/pwa-common": "6.23.0-beta.
|
|
19
|
-
"@shopgate/pwa-common-commerce": "6.23.0-beta.
|
|
20
|
-
"@shopgate/pwa-core": "6.23.0-beta.
|
|
21
|
-
"@shopgate/tracking-core": "6.23.0-beta.
|
|
18
|
+
"@shopgate/pwa-common": "6.23.0-beta.3",
|
|
19
|
+
"@shopgate/pwa-common-commerce": "6.23.0-beta.3",
|
|
20
|
+
"@shopgate/pwa-core": "6.23.0-beta.3",
|
|
21
|
+
"@shopgate/tracking-core": "6.23.0-beta.3",
|
|
22
22
|
"reselect": "^3.0.1",
|
|
23
23
|
"rxjs": "~5.5.12"
|
|
24
24
|
}
|
package/subscriptions/setup.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import get from'lodash/get';import{logGroup,getWebStorageEntry,useBrowserConnector,errorManager,SOURCE_TRACKING,CODE_TRACKING,defaultClientInformation}from'@shopgate/pwa-core';import{TYPE_PHONE,OS_ALL,OS_ANDROID}from'@shopgate/pwa-common/constants/Device';import appConfig,{shopNumber,componentsConfig}from'@shopgate/pwa-common/helpers/config';import core from'@shopgate/tracking-core/core/Core';import{
|
|
1
|
+
import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import get from'lodash/get';import{logGroup,getWebStorageEntry,useBrowserConnector,errorManager,SOURCE_TRACKING,CODE_TRACKING,defaultClientInformation}from'@shopgate/pwa-core';import{TYPE_PHONE,OS_ALL,OS_ANDROID}from'@shopgate/pwa-common/constants/Device';import appConfig,{shopNumber,componentsConfig}from'@shopgate/pwa-common/helpers/config';import core from'@shopgate/tracking-core/core/Core';import{COOKIE_CONSENT_UPDATED}from'@shopgate/tracking-core/helpers/events';import{cookieConsentInitialized$,cookieConsentUpdated$}from'@shopgate/engage/tracking/streams';import UnifiedPlugin from'@shopgate/tracking-core/plugins/trackers/Unified';import{track}from"../helpers/index";/**
|
|
2
2
|
* Setup tracking subscriptions.
|
|
3
3
|
* @param {Function} subscribe The subscribe function.
|
|
4
4
|
*/export default function setup(subscribe){/**
|
|
5
5
|
* Gets triggered when the app starts.
|
|
6
|
-
*/subscribe(
|
|
6
|
+
*/subscribe(cookieConsentInitialized$,/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref){var getState,action,statisticsCookiesAccepted,comfortCookiesAccepted,clientInformationResponse,clientInformation,GaBase,extensionsIndex,trackingExtensions;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:getState=_ref.getState,action=_ref.action;statisticsCookiesAccepted=action.statisticsCookiesAccepted,comfortCookiesAccepted=action.comfortCookiesAccepted;if(useBrowserConnector()){_context.next=8;break;}_context.next=5;return getWebStorageEntry({name:'clientInformation'});case 5:_context.t0=_context.sent;_context.next=9;break;case 8:_context.t0={value:defaultClientInformation};case 9:clientInformationResponse=_context.t0;clientInformation={type:get(clientInformationResponse,'value.device.type',TYPE_PHONE),os:get(clientInformationResponse,'value.device.os.platform',OS_ALL),state:getState(),services:get(clientInformationResponse,'value.device.supportedAnalyticsServices',[]),libVersion:get(clientInformationResponse,'value.libVersion'),appVersion:get(clientInformationResponse,'value.appVersion'),cookieConsent:{statisticsCookiesAccepted:statisticsCookiesAccepted,comfortCookiesAccepted:comfortCookiesAccepted}};// TODO: instantiate the UnifiedPlugin only if a native tracker is configured (FB, AppsFlyer)
|
|
7
7
|
// eslint-disable-next-line no-new
|
|
8
|
-
new UnifiedPlugin();if(appConfig.tracking.hasWebTrackingEngage){// eslint-disable-next-line global-require
|
|
8
|
+
new UnifiedPlugin();if(appConfig.tracking.hasWebTrackingEngage&&statisticsCookiesAccepted){// eslint-disable-next-line global-require
|
|
9
9
|
GaBase=require('@shopgate/tracking-core/plugins/trackers/GaBase')["default"];GaBase.createUniversal({shopNumber:shopNumber,codebaseVersion:get(clientInformationResponse,'value.codebaseVersion'),config:{merchant:[],shopgate:{id:clientInformation.os===OS_ANDROID?appConfig.webTrackingEngage.android:appConfig.webTrackingEngage.ios,useNetPrices:false}}});}try{// eslint-disable-next-line global-require, import/no-dynamic-require
|
|
10
10
|
extensionsIndex=require("".concat(process.env.THEME_PATH,"/extensions/tracking"))["default"];trackingExtensions=componentsConfig.tracking||{};Object.keys(trackingExtensions).forEach(function(key){var pluginInit=extensionsIndex[key];if(pluginInit){/**
|
|
11
11
|
* Call the init function of the plugin.
|
|
12
12
|
* This init function will create the actual instances
|
|
13
|
-
*/pluginInit(clientInformation);}});}catch(error){logGroup('Tracking %c: Could not setup plugins',{error:error},'#ED0422');error.code=CODE_TRACKING;error.source=SOURCE_TRACKING;error.context='trackingPlugins';errorManager.queue(error);}core.registerFinished();case
|
|
13
|
+
*/pluginInit(clientInformation);}});}catch(error){logGroup('Tracking %c: Could not setup plugins',{error:error},'#ED0422');error.code=CODE_TRACKING;error.source=SOURCE_TRACKING;error.context='trackingPlugins';errorManager.queue(error);}core.registerFinished();case 15:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref2.apply(this,arguments);};}());/**
|
|
14
|
+
* Gets triggered when the cookie consent selection changes. Registered trackers will be informed
|
|
15
|
+
* about the new decisions.
|
|
16
|
+
*/subscribe(cookieConsentUpdated$,function(_ref3){var action=_ref3.action;var statisticsCookiesAccepted=action.statisticsCookiesAccepted,comfortCookiesAccepted=action.comfortCookiesAccepted;track(COOKIE_CONSENT_UPDATED,{statisticsCookiesAccepted:statisticsCookiesAccepted,comfortCookiesAccepted:comfortCookiesAccepted});});}
|