@shopgate/pwa-tracking 7.12.7-beta.1 → 7.20.0-beta.10
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/helpers/index.js +2 -2
- package/package.json +5 -5
- package/selectors/category.js +1 -1
- package/selectors/page.js +1 -1
- package/selectors/product.js +1 -1
- package/selectors/search.js +1 -1
- package/selectors/user.js +2 -2
- package/streams/cart.js +13 -0
- package/streams/category.js +4 -3
- package/streams/page.js +3 -2
- package/streams/pages.js +1 -1
- package/streams/product.js +7 -4
- package/streams/scanner.js +1 -1
- package/streams/search.js +3 -2
- package/subscriptions/cart.js +1 -1
- package/subscriptions/checkout.js +1 -1
- package/subscriptions/deeplinkPush.js +4 -10
- package/subscriptions/pages.js +1 -1
- package/subscriptions/product.js +1 -1
- package/subscriptions/scanner.js +2 -2
- package/subscriptions/search.js +1 -1
- package/subscriptions/setup.js +7 -4
package/helpers/index.js
CHANGED
|
@@ -33,7 +33,7 @@ if(!passedOrder.totals&&passedOrder.amount){return{order:passedOrder};}var defau
|
|
|
33
33
|
* Creates data for the scanner utm url.
|
|
34
34
|
* @param {Object} params params
|
|
35
35
|
* @return {Object}
|
|
36
|
-
*/export var buildScannerUtmUrl=function buildScannerUtmUrl(_ref8){var scannerRoute=_ref8.scannerRoute,format=_ref8.format,payload=_ref8.payload,referer=_ref8.referer;var source='shopgate';var medium='scanner';var campaign="".concat(shopNumber,"Scanner");var term='';if(SCANNER_FORMATS_BARCODE.includes(format)){medium='barcode_scanner';campaign="".concat(shopNumber,"BarcodeScan");term=payload;}else if(SCANNER_FORMATS_QR_CODE.includes(format)){medium='qrcode_scanner';campaign="".concat(shopNumber,"QRScan");var
|
|
36
|
+
*/export var buildScannerUtmUrl=function buildScannerUtmUrl(_ref8){var scannerRoute=_ref8.scannerRoute,format=_ref8.format,payload=_ref8.payload,referer=_ref8.referer;var source='shopgate';var medium='scanner';var campaign="".concat(shopNumber,"Scanner");var term='';if(SCANNER_FORMATS_BARCODE.includes(format)){medium='barcode_scanner';campaign="".concat(shopNumber,"BarcodeScan");term=payload;}else if(SCANNER_FORMATS_QR_CODE.includes(format)){medium='qrcode_scanner';campaign="".concat(shopNumber,"QRScan");var _ref10=parse2dsQrCode(payload)||{},type=_ref10.type,data=_ref10.data;if(type===QR_CODE_TYPE_SEARCH){term=data.searchPhrase;}}var parsedPayload;var utmContent;try{parsedPayload=queryString.parseUrl(payload);}catch(e){// noting to do here
|
|
37
37
|
}if(parsedPayload&&parsedPayload.query){if(parsedPayload.query.utm_content){utmContent=parsedPayload.query.utm_content;}}var location=scannerRoute.location;var newPath=new URL(location,'http://scanner.com');/* eslint-disable camelcase */var utms={utm_source:source,utm_medium:medium,utm_campaign:campaign,utm_term:term,utm_content:utmContent||referer};/* eslint-enable camelcase */Object.keys(utms).forEach(function(utm){if(!newPath.searchParams.has(utm)&&utms[utm]){newPath.searchParams.set(utm,utms[utm]);}});return"".concat(newPath.pathname).concat(newPath.search);};/**
|
|
38
38
|
* Creates tracking data for a category.
|
|
39
39
|
* @param {Object} category The category data from the store.
|
|
@@ -46,7 +46,7 @@ if(!passedOrder.totals&&passedOrder.amount){return{order:passedOrder};}var defau
|
|
|
46
46
|
* Creates tracking data for the page view event.
|
|
47
47
|
* @param {Object} data The input data.
|
|
48
48
|
* @return {Object}
|
|
49
|
-
*/export var createPageviewData=function createPageviewData(
|
|
49
|
+
*/export var createPageviewData=function createPageviewData(_ref11){var _ref11$page=_ref11.page,page=_ref11$page===void 0?null:_ref11$page,_ref11$cart=_ref11.cart,cart=_ref11$cart===void 0?null:_ref11$cart,_ref11$favorites=_ref11.favorites,favorites=_ref11$favorites===void 0?null:_ref11$favorites,_ref11$search=_ref11.search,search=_ref11$search===void 0?null:_ref11$search,_ref11$category=_ref11.category,category=_ref11$category===void 0?null:_ref11$category,_ref11$product=_ref11.product,product=_ref11$product===void 0?null:_ref11$product,pageConfig=_ref11.pageConfig;var title='';if(pageConfig){title=pageConfig.title;}else if(category&&category.name){title=category.name;}else if(product&&product.name){title=product.name;}return{page:page?_extends({},page,{title:title}):null,cart:cart,favouriteList:{products:favorites},search:search,category:category,product:product};};/**
|
|
50
50
|
* Helper to pass the redux state to the tracking core
|
|
51
51
|
* @param {string} eventName The name of the event.
|
|
52
52
|
* @param {Object} data The tracking data of the event.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/pwa-tracking",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.20.0-beta.10",
|
|
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": "7.
|
|
19
|
-
"@shopgate/pwa-common-commerce": "7.
|
|
20
|
-
"@shopgate/pwa-core": "7.
|
|
21
|
-
"@shopgate/tracking-core": "7.
|
|
18
|
+
"@shopgate/pwa-common": "7.20.0-beta.10",
|
|
19
|
+
"@shopgate/pwa-common-commerce": "7.20.0-beta.10",
|
|
20
|
+
"@shopgate/pwa-core": "7.20.0-beta.10",
|
|
21
|
+
"@shopgate/tracking-core": "7.20.0-beta.10",
|
|
22
22
|
"reselect": "^3.0.1",
|
|
23
23
|
"rxjs": "~5.5.12"
|
|
24
24
|
}
|
package/selectors/category.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createSelector}from'reselect';import{
|
|
1
|
+
import{createSelector}from'reselect';import{hex2bin}from'@shopgate/engage/core/helpers';import{makeGetRouteParam,makeGetRoutePattern}from'@shopgate/engage/core/selectors';import{CATEGORY_PATTERN,ROOT_CATEGORY_PATTERN}from'@shopgate/engage/category/constants';import{getRootCategories,getCategory}from'@shopgate/engage/category/selectors';import{createCategoryData,createRootCategoryData}from"../helpers";/**
|
|
2
2
|
* Creates a selector that retrieves a formatted category for the current route.
|
|
3
3
|
* @returns {Function}
|
|
4
4
|
*/export var makeGetRouteCategory=function makeGetRouteCategory(){var getRoutePattern=makeGetRoutePattern();var getCategoryIdRouteParam=makeGetRouteParam('categoryId');return createSelector(function(state){return state;},getRoutePattern,getCategoryIdRouteParam,getRootCategories,function(state,pattern,categoryId,rootCategories){var decodedCategoryId=categoryId?hex2bin(categoryId):null;if(pattern===ROOT_CATEGORY_PATTERN){return createRootCategoryData(rootCategories);}if(pattern===CATEGORY_PATTERN&&decodedCategoryId){return createCategoryData(getCategory(state,{categoryId:decodedCategoryId}));}return null;});};
|
package/selectors/page.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createSelector}from'reselect';import{
|
|
1
|
+
import{createSelector}from'reselect';import{getCurrentPathname,makeGetRouteParam}from'@shopgate/engage/core/selectors';import{isDev}from'@shopgate/engage/core/helpers';import{getPageConfigById}from'@shopgate/engage/page/selectors';import{shopNumber}from'@shopgate/pwa-common/helpers/config';/**
|
|
2
2
|
* The tracking base URL.
|
|
3
3
|
* @type {string}
|
|
4
4
|
*/var baseUrl="https://rapid.shopgate.com".concat(isDev?'/php/shopgate':'',"/sg_app_resources");/**
|
package/selectors/product.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createSelector}from'reselect';import{
|
|
1
|
+
import{createSelector}from'reselect';import{makeGetRouteParam,makeGetRoutePattern}from'@shopgate/engage/core/selectors';import{hex2bin}from'@shopgate/engage/core/helpers';import{ITEM_PATTERN}from'@shopgate/engage/product/constants';import{getBaseProduct,getProduct}from'@shopgate/pwa-common-commerce/product/selectors/product';import{formatProductData}from"../helpers";/**
|
|
2
2
|
* Gets the current base product in a formatted way.
|
|
3
3
|
* @param {Object} state The current state.
|
|
4
4
|
* @returns {Object} The formatted selected variant.
|
package/selectors/search.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{createSelector}from'reselect';import{getSortOrder,getSearchPhrase}from'@shopgate/
|
|
1
|
+
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{createSelector}from'reselect';import{getSortOrder,getSearchPhrase}from'@shopgate/engage/core/selectors';import{generateResultHash}from'@shopgate/engage/core/helpers';import{getFulfillmentParams}from'@shopgate/pwa-common-commerce/product';/**
|
|
2
2
|
* Selects the container for search results.
|
|
3
3
|
* @param {Object} state The current state.
|
|
4
4
|
* @returns {Object} The search results.
|
package/selectors/user.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}import{createSelector}from'reselect';import{DEFAULT_LOGIN_STRATEGY,isUserLoggedIn,getUserData,makeGetLoginStrategy}from'@shopgate/engage/user';/**
|
|
1
|
+
var _excluded=["isFetching","loginType"];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 _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}import{createSelector}from'reselect';import{DEFAULT_LOGIN_STRATEGY,isUserLoggedIn,getUserData,makeGetLoginStrategy}from'@shopgate/engage/user';/**
|
|
2
2
|
* Creates a selector that retrieves user tracking data from the store.
|
|
3
3
|
* @param {string} name The name of the desired parameter.
|
|
4
4
|
* @returns {Function}
|
|
5
|
-
*/export function makeGetUser(){var getLoginStrategy=makeGetLoginStrategy();return createSelector(isUserLoggedIn,getUserData,getLoginStrategy,function(isLoggedIn,userData,loginStrategy){if(!isLoggedIn||!userData){return null;}var _ref=userData||{},isFetching=_ref.isFetching,loginType=_ref.loginType,trackedData=_objectWithoutProperties(_ref,
|
|
5
|
+
*/export function makeGetUser(){var getLoginStrategy=makeGetLoginStrategy();return createSelector(isUserLoggedIn,getUserData,getLoginStrategy,function(isLoggedIn,userData,loginStrategy){if(!isLoggedIn||!userData){return null;}var _ref=userData||{},isFetching=_ref.isFetching,loginType=_ref.loginType,trackedData=_objectWithoutProperties(_ref,_excluded);if(Object.keys(trackedData).length===0){return null;}var type=null;if(loginStrategy!==DEFAULT_LOGIN_STRATEGY){type=loginStrategy;}else if(['userGuest','userAccount'].includes(loginType)){type=loginType==='userGuest'?'guest':'standard';}return _extends({},trackedData,{type:type});});}
|
package/streams/cart.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
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'rxjs/add/operator/switchMap';import'rxjs/add/observable/of';import'rxjs/add/observable/defer';import{Observable}from'rxjs/Observable';import{productsAdded$ as originalProductsAdded$}from'@shopgate/engage/cart/streams';import{getProductById,fetchProductsById}from'@shopgate/engage/product';/**
|
|
2
|
+
* Emits when a product was added to the cart and product data is available
|
|
3
|
+
*/export var productsAdded$=originalProductsAdded$.switchMap(function(input){var getState=input.getState,action=input.action,dispatch=input.dispatch;var _action$products=action.products,products=_action$products===void 0?[]:_action$products;// Collect product ids from the add-to-cart action
|
|
4
|
+
var productIds=products.map(function(_ref){var productId=_ref.productId;return productId;}).filter(Boolean);// Check if we have product data for all productIds
|
|
5
|
+
var productDataAvailable=productIds.every(function(productId){return getProductById(getState(),{productId:productId});});if(productDataAvailable){// All product data for the tracking event is available - handover action data to subscribers
|
|
6
|
+
return Observable.of(input);}/**
|
|
7
|
+
* Incomplete product data can be caused by an add-to-cart push message. In that case the
|
|
8
|
+
* product was never fetched before due to visiting PDP. So we need to fetch missing product
|
|
9
|
+
* data first.
|
|
10
|
+
* Subscribers will receive the original action when product data comes available.
|
|
11
|
+
*/return Observable.defer(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var result;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:result={products:[]};_context.prev=1;_context.next=4;return dispatch(fetchProductsById(productIds));case 4:result=_context.sent;_context.next=9;break;case 7:_context.prev=7;_context.t0=_context["catch"](1);case 9:return _context.abrupt("return",result);case 10:case"end":return _context.stop();}},_callee,null,[[1,7]]);}))).first()// do not proceed when request didn't return any products (no suitable tracking data)
|
|
12
|
+
.filter(function(data){return Array.isArray(data.products)&&data.products.length>0;})// handover original action to subscribers
|
|
13
|
+
.switchMap(function(){return Observable.of(input);});});
|
package/streams/category.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import'rxjs/add/operator/switchMap';import'rxjs/add/observable/of';import{Observable}from'rxjs/Observable';import{
|
|
1
|
+
import'rxjs/add/operator/switchMap';import'rxjs/add/observable/of';import{Observable}from'rxjs/Observable';import{routeDidEnter$,pwaDidAppear$}from'@shopgate/engage/core/streams';import{hex2bin}from'@shopgate/engage/core/helpers';import{ROOT_CATEGORY_PATTERN,CATEGORY_PATTERN}from'@shopgate/engage/category/constants';import{getProductsResult}from'@shopgate/pwa-common-commerce/product/selectors/product';import{receivedRootCategories$}from'@shopgate/engage/category/streams';import{getRootCategories}from'@shopgate/engage/category/selectors';import{getIsAppWebViewVisible}from'@shopgate/engage/core/selectors';import{productsReceived$}from"./product";/**
|
|
2
2
|
* Emits when the root category was entered.
|
|
3
3
|
*/var rootCategoryDidEnter$=routeDidEnter$.filter(function(_ref){var action=_ref.action;return action.route.pattern===ROOT_CATEGORY_PATTERN;});/**
|
|
4
4
|
* Emits when a regular category was entered.
|
|
@@ -8,11 +8,12 @@ import'rxjs/add/operator/switchMap';import'rxjs/add/observable/of';import{Observ
|
|
|
8
8
|
* Emits when a root category's data is already available.
|
|
9
9
|
*/var rootCategoryPreloaded$=rootCategoryDidEnter$.filter(function(_ref3){var getState=_ref3.getState;var rootCategories=getRootCategories(getState());return rootCategories?!!rootCategories.length:false;});/**
|
|
10
10
|
* Emits when a category's data is available.
|
|
11
|
-
*/var categoryDataLoaded$=categoryDidEnter
|
|
11
|
+
*/var categoryDataLoaded$=categoryDidEnter$// Do not track while PWA webview is in the background
|
|
12
|
+
.filter(function(_ref4){var getState=_ref4.getState;return getIsAppWebViewVisible(getState());}).switchMap(function(data){var action=data.action,getState=data.getState;var categoryId=action.route.params.categoryId;// Check if products for the current route are already available within Redux.
|
|
12
13
|
var productsLoaded=getProductsResult(getState(),{categoryId:hex2bin(categoryId)}).totalProductCount!==null;if(!productsLoaded){// Wait for incoming products if they are not available yet.
|
|
13
14
|
return productsReceived$.first();}return Observable.of(data);});/**
|
|
14
15
|
* Emits when the category route comes active again after a legacy page was active.
|
|
15
|
-
*/var categoryRouteReappeared$=pwaDidAppear$.filter(function(
|
|
16
|
+
*/var categoryRouteReappeared$=pwaDidAppear$.filter(function(_ref5){var action=_ref5.action;return[CATEGORY_PATTERN,ROOT_CATEGORY_PATTERN].includes(action.route.pattern);});/**
|
|
16
17
|
* Emits when a category or root category is ready to be tracked,
|
|
17
18
|
* considering loaded or preloaded data.
|
|
18
19
|
*/export var categoryIsReady$=categoryDataLoaded$.merge(rootCategoryLoaded$,rootCategoryPreloaded$,categoryRouteReappeared$);
|
package/streams/page.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import'rxjs/add/operator/switchMap';import'rxjs/add/observable/of';import{Observable}from'rxjs/Observable';import{RECEIVE_PAGE_CONFIG}from'@shopgate/
|
|
1
|
+
import'rxjs/add/operator/switchMap';import'rxjs/add/observable/of';import{Observable}from'rxjs/Observable';import{RECEIVE_PAGE_CONFIG}from'@shopgate/engage/core/constants';import{main$,routeDidEnter$,pwaDidAppear$}from'@shopgate/engage/core/streams';import{getIsAppWebViewVisible}from'@shopgate/engage/core/selectors';import{PAGE_PATTERN}from'@shopgate/engage/page/constants';import{getPageConfigById}from'@shopgate/engage/page/selectors';/**
|
|
2
2
|
* Emits when a "page" was entered.
|
|
3
3
|
*/var pageDidEnter$=routeDidEnter$.filter(function(_ref){var action=_ref.action;return action.route.pattern===PAGE_PATTERN;});/**
|
|
4
4
|
* Emits when the page route comes active again after a legacy page was active.
|
|
5
5
|
*/var pageRouteReappeared$=pwaDidAppear$.filter(function(_ref2){var action=_ref2.action;return action.route.pattern===PAGE_PATTERN;});var pageConfigReceived$=main$.filter(function(_ref3){var action=_ref3.action;return action.type===RECEIVE_PAGE_CONFIG;});/**
|
|
6
6
|
* Emits when a "page" was opened, and its config is available.
|
|
7
|
-
*/export var pageIsReady$=pageDidEnter
|
|
7
|
+
*/export var pageIsReady$=pageDidEnter$// Do not track while PWA webview is in the background
|
|
8
|
+
.filter(function(_ref4){var getState=_ref4.getState;return getIsAppWebViewVisible(getState());}).switchMap(function(data){var action=data.action,getState=data.getState;var pageId=action.route.params.pageId;// Check if the page config for the current route is already available within Redux.
|
|
8
9
|
var pageConfig=getPageConfigById(getState(),{pageId:pageId});if(!pageConfig||pageConfig.isFetching){// Wait for incoming page data if it's not available yet.
|
|
9
10
|
return pageConfigReceived$.first().switchMap(function(){return Observable.of(data);});}return Observable.of(data);}).merge(pageRouteReappeared$);
|
package/streams/pages.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import{
|
|
1
|
+
function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import{appWillStart$,pwaDidAppear$,pwaDidDisappear$,routeDidEnter$}from'@shopgate/engage/core/streams';import{APP_WILL_START,PWA_DID_APPEAR}from'@shopgate/engage/core/constants';import{SEARCH_PATH,SEARCH_FILTER_PATTERN}from'@shopgate/engage/search/constants';import{ROOT_CATEGORY_PATTERN,CATEGORY_PATTERN,CATEGORY_FILTER_PATTERN}from'@shopgate/engage/category/constants';import{ITEM_PATTERN,ITEM_GALLERY_PATTERN,ITEM_REVIEWS_PATTERN,ITEM_WRITE_REVIEW_PATTERN}from'@shopgate/engage/product/constants';import{PAGE_PATTERN}from'@shopgate/engage/page/constants';import{pwaVisibility$}from"./app";import{checkoutDidEnter$}from"./checkout";/**
|
|
2
2
|
* A blacklist of paths that should be tracked within their individual subscriptions.
|
|
3
3
|
* @type {Array}
|
|
4
4
|
*/export var blacklistedPatterns=[ROOT_CATEGORY_PATTERN,CATEGORY_PATTERN,ITEM_PATTERN,SEARCH_PATH,// Patterns for routes which are not supported for tracking at the moment.
|
package/streams/product.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import'rxjs/add/operator/switchMap';import{routeWillEnter$}from'@shopgate/
|
|
1
|
+
import'rxjs/add/operator/switchMap';import{main$,routeWillEnter$,pwaDidAppear$}from'@shopgate/engage/core/streams';import{getIsAppWebViewVisible}from'@shopgate/engage/core/selectors';import{receivedVisibleProduct$}from'@shopgate/pwa-common-commerce/product/streams';import{RECEIVE_PRODUCTS,ITEM_PATTERN}from'@shopgate/pwa-common-commerce/product/constants';/**
|
|
2
|
+
* Emits when product results has been received.
|
|
3
|
+
*/export var productsReceived$=main$.filter(function(_ref){var action=_ref.action;return action.type===RECEIVE_PRODUCTS;});/**
|
|
2
4
|
* Emits when the category route comes active again after a legacy page was active.
|
|
3
|
-
*/export var productRouteReappeared$=pwaDidAppear$.filter(function(
|
|
5
|
+
*/export var productRouteReappeared$=pwaDidAppear$.filter(function(_ref2){var action=_ref2.action;return action.route.pattern===ITEM_PATTERN;});/**
|
|
4
6
|
* Emits when a product page was initially opened.
|
|
5
|
-
*/export var productWillEnter$=routeWillEnter$.filter(function(
|
|
7
|
+
*/export var productWillEnter$=routeWillEnter$.filter(function(_ref3){var action=_ref3.action;return action.route.pattern===ITEM_PATTERN;});/**
|
|
6
8
|
* Emits when a product page was initially opened and its data is present.
|
|
7
|
-
*/export var productIsReady$=productWillEnter$//
|
|
9
|
+
*/export var productIsReady$=productWillEnter$// Do not track while PWA webview is in the background
|
|
10
|
+
.filter(function(_ref4){var getState=_ref4.getState;return getIsAppWebViewVisible(getState());})// Take care that the stream only emits when underlying streams emit within the correct order.
|
|
8
11
|
.switchMap(function(){return receivedVisibleProduct$.first();}).merge(productRouteReappeared$);
|
package/streams/scanner.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{main$}from'@shopgate/
|
|
1
|
+
import{main$}from'@shopgate/engage/core/streams';import{scannerDidEnter$}from'@shopgate/engage/scanner/streams';import{SUCCESS_HANDLE_SCANNER,ERROR_HANDLE_SCANNER}from'@shopgate/engage/scanner/constants';import{SCANNER_SCOPE_DEFAULT,SCANNER_TYPE_BARCODE}from'@shopgate/engage/core/constants';/** @type {Observable} */export var scanActivated$=scannerDidEnter$.filter(function(_ref){var action=_ref.action;var _action$route$query=action.route.query,_action$route$query2=_action$route$query===void 0?{}:_action$route$query,_action$route$query2$=_action$route$query2.type,type=_action$route$query2$===void 0?SCANNER_TYPE_BARCODE:_action$route$query2$,_action$route$query2$2=_action$route$query2.scope,scope=_action$route$query2$2===void 0?SCANNER_SCOPE_DEFAULT:_action$route$query2$2;// The stream in supposed to emit only for the Shopgate default scanner.
|
|
2
2
|
return type===SCANNER_TYPE_BARCODE&&scope===SCANNER_SCOPE_DEFAULT;});/** @type {Observable} */export var scanSuccess$=main$.filter(function(_ref2){var action=_ref2.action;var type=action.type,scope=action.scope;return type===SUCCESS_HANDLE_SCANNER&&scope===SCANNER_SCOPE_DEFAULT;});/** @type {Observable} */export var scanFail$=main$.filter(function(_ref3){var action=_ref3.action;var type=action.type,scope=action.scope;return type===ERROR_HANDLE_SCANNER&&scope===SCANNER_SCOPE_DEFAULT;});
|
package/streams/search.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import'rxjs/add/operator/switchMap';import'rxjs/add/observable/of';import{Observable}from'rxjs/Observable';import{
|
|
1
|
+
import'rxjs/add/operator/switchMap';import'rxjs/add/operator/filter';import'rxjs/add/observable/of';import{Observable}from'rxjs/Observable';import{getProductsResult}from'@shopgate/pwa-common-commerce/product/selectors/product';import{main$,pwaDidAppear$}from'@shopgate/engage/core/streams';import{getIsAppWebViewVisible,getCurrentSearchQuery}from'@shopgate/engage/core/selectors';import{SEARCH_PATTERN,RECEIVE_SEARCH_RESULTS}from'@shopgate/engage/search/constants';import{searchDidEnter$}from'@shopgate/engage/search/streams';/**
|
|
2
2
|
* Emits when the search route comes active again after a legacy page was active.
|
|
3
3
|
*/var searchRouteReappeared$=pwaDidAppear$.filter(function(_ref){var action=_ref.action;return action.route.pattern===SEARCH_PATTERN;});/**
|
|
4
4
|
* Emits when search results are received.
|
|
5
5
|
*/var resultsReceived$=main$.filter(function(_ref2){var action=_ref2.action;return action.type===RECEIVE_SEARCH_RESULTS;});/**
|
|
6
6
|
* Emits when the search is ready to be tracked and all relevant data is available.
|
|
7
|
-
*/export var searchIsReady$=searchDidEnter
|
|
7
|
+
*/export var searchIsReady$=searchDidEnter$// Do not track while PWA webview is in the background
|
|
8
|
+
.filter(function(_ref3){var getState=_ref3.getState;return getIsAppWebViewVisible(getState());}).switchMap(function(data){var getState=data.getState;var query=getCurrentSearchQuery(getState());// Check if products for the current route are already available within Redux.
|
|
8
9
|
var productsLoaded=getProductsResult(getState(),{searchPhrase:query}).totalProductCount!==null;if(!productsLoaded){// Wait for incoming products if they are not available yet.
|
|
9
10
|
return resultsReceived$.first();}return Observable.of(data);}).merge(searchRouteReappeared$);
|
package/subscriptions/cart.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{productsAdded$}from
|
|
1
|
+
import{productsAdded$}from"../streams/cart";import{getAddToCartProducts}from"../selectors/cart";import getPage from"../selectors/page";import{track}from"../helpers/index";/**
|
|
2
2
|
* Pages tracking subscriptions.
|
|
3
3
|
* @param {Function} subscribe The subscribe function.
|
|
4
4
|
*/export default function cart(subscribe){/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import
|
|
1
|
+
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{event}from'@shopgate/engage/core/classes';import{appDidStart$}from'@shopgate/engage/core/streams';import{analyticsSetCustomValues}from'@shopgate/engage/core/commands';import{checkoutSuccess$}from'@shopgate/engage/checkout/streams';import getCart from"../selectors/cart";import{track,formatPurchaseData,formatNativeCheckoutPurchaseData}from"../helpers";import{checkoutDidEnter$}from"../streams/checkout";/**
|
|
2
2
|
* Checkout tracking subscriptions.
|
|
3
3
|
* @param {Function} subscribe The subscribe function.
|
|
4
4
|
*/export default function checkout(subscribe){subscribe(checkoutDidEnter$,function(_ref){var getState=_ref.getState;var state=getState();track('initiatedCheckout',{cart:getCart(state)},state);});/**
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import{
|
|
2
|
-
* Emits when a deeplink was opened.
|
|
3
|
-
*/var deeplinkOpened$=main$.filter(function(_ref){var action=_ref.action;return action.type===OPEN_DEEP_LINK;});/**
|
|
4
|
-
* Emits when a push message was opened.
|
|
5
|
-
*/var pushOpened$=main$.filter(function(_ref2){var action=_ref2.action;return action.type===OPEN_PUSH_NOTIFICATION;});/**
|
|
6
|
-
* Emits when a universal link was opened.
|
|
7
|
-
*/var universalLinkOpened$=main$.filter(function(_ref3){var action=_ref3.action;return action.type===OPEN_UNIVERSAL_LINK;});/**
|
|
1
|
+
import{pushNotificationOpened$,deeplinkOpened$,universalLinkOpened$}from'@shopgate/engage/core/streams';import{track}from"../helpers/index";/**
|
|
8
2
|
* Deeplink and push message tracking subscriptions.
|
|
9
3
|
* @param {Function} subscribe The subscribe function.
|
|
10
4
|
*/export default function deeplinkPush(subscribe){/**
|
|
11
5
|
* Gets triggered when a deeplink was opened.
|
|
12
|
-
*/subscribe(deeplinkOpened$,function(
|
|
6
|
+
*/subscribe(deeplinkOpened$,function(_ref){var getState=_ref.getState,action=_ref.action;var state=getState();var _action$payload=action.payload,_action$payload$link=_action$payload.link,link=_action$payload$link===void 0?'':_action$payload$link,_action$payload$sourc=_action$payload.sourceApp,sourceApp=_action$payload$sourc===void 0?'':_action$payload$sourc,wasOpenedFromSearchIndex=_action$payload.wasOpenedFromSearchIndex;var eventLabel=wasOpenedFromSearchIndex?'os_search':sourceApp;track('openDeepLink',{eventAction:link,eventLabel:eventLabel},state);track('setCampaignWithUrl',{url:link,type:'deeplink'},state);});/**
|
|
13
7
|
* Gets triggered when a push was opened.
|
|
14
|
-
*/subscribe(
|
|
8
|
+
*/subscribe(pushNotificationOpened$,function(_ref2){var getState=_ref2.getState,action=_ref2.action;var state=getState();var notificationId=action.notificationId?action.notificationId.toString():'n/a';track('openPushNotification',{eventAction:'opened',eventLabel:notificationId},state);track('setCampaignWithUrl',{url:action.link,notificationId:notificationId,type:'push_message'},state);});/**
|
|
15
9
|
* Gets triggered when a universal link was opened.
|
|
16
|
-
*/subscribe(universalLinkOpened$,function(
|
|
10
|
+
*/subscribe(universalLinkOpened$,function(_ref3){var getState=_ref3.getState,action=_ref3.action;var state=getState();var _action$payload2=action.payload,_action$payload2$link=_action$payload2.link,link=_action$payload2$link===void 0?'':_action$payload2$link,wasOpenedFromSearchIndex=_action$payload2.wasOpenedFromSearchIndex;var eventLabel=wasOpenedFromSearchIndex?'os_search':'n/a';track('openUniversalLink',{eventAction:link,eventLabel:eventLabel},state);track('setCampaignWithUrl',{url:link,type:'universal_link'},state);});}
|
package/subscriptions/pages.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{getCurrentRoute}from'@shopgate/
|
|
1
|
+
import{getCurrentRoute}from'@shopgate/engage/core/selectors';import{categoryIsReady$}from"../streams/category";import{searchIsReady$}from"../streams/search";import{productIsReady$}from"../streams/product";import{pagesAreReady$}from"../streams/pages";import{pageIsReady$}from"../streams/page";import{makeGetTrackingData}from"../selectors";import{track}from"../helpers";/**
|
|
2
2
|
* Calls the pageview core tracking function.
|
|
3
3
|
* @param {Object} input The input of the tracked stream.
|
|
4
4
|
*/var callPageViewTracker=function callPageViewTracker(_ref){var getState=_ref.getState;var state=getState();var getTrackingData=makeGetTrackingData();track('pageview',getTrackingData(state,getCurrentRoute(state)),state);};/**
|
package/subscriptions/product.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{getCurrentRoute}from'@shopgate/
|
|
1
|
+
import{getCurrentRoute}from'@shopgate/engage/core/selectors';import{variantDidChange$}from'@shopgate/pwa-common-commerce/product/streams';import{productIsReady$}from"../streams/product";import{getBaseProductFormatted,getProductFormatted}from"../selectors/product";import{makeGetTrackingData}from"../selectors";import{track}from"../helpers";/**
|
|
2
2
|
* Product tracking subscriptions.
|
|
3
3
|
* @param {Function} subscribe The subscribe function.
|
|
4
4
|
*/export default function product(subscribe){/**
|
package/subscriptions/scanner.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import core from'@shopgate/tracking-core/core/Core';import{routeDidLeave$}from'@shopgate/
|
|
1
|
+
function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import core from'@shopgate/tracking-core/core/Core';import{routeDidLeave$}from'@shopgate/engage/core/streams';import{scanActivated$,scanFail$,scanSuccess$}from"../streams/scanner";import{buildScannerUtmUrl,createScannerEventData,track}from"../helpers";/**
|
|
2
2
|
* Scanner tracking subscriptions.
|
|
3
3
|
* @param {Function} subscribe The subscribe function.
|
|
4
|
-
*/export default function scanner(subscribe){var events=core.getScannerEvents();subscribe(scanActivated$,function(_ref){var action=_ref.action,getState=_ref.getState;var format=action.format;track('qrScanner',createScannerEventData({event:events.SCAN_ACTIVATED,userInteraction:false,format:format}),getState());});subscribe(scanSuccess$,function(_ref2){var action=_ref2.action,getState=_ref2.getState;var format=action.format,payload=action.payload;track('qrScanner',createScannerEventData({event:events.SCAN_SUCCESS,format:format,payload:payload}),getState());});subscribe(scanFail$,function(_ref3){var action=_ref3.action,getState=_ref3.getState;var format=action.format,payload=action.payload;track('qrScanner',createScannerEventData({event:events.SCAN_FAIL,format:format,payload:payload}),getState());});var afterScan$=scanActivated$.withLatestFrom(routeDidLeave$).switchMap(function(){return scanSuccess$.first();},function(_ref4,successAction){var _ref5=_slicedToArray(_ref4,2),activatedAction=_ref5[0],refererAction=_ref5[1];return{activatedAction:activatedAction,refererAction:refererAction,successAction:successAction,getState:activatedAction.getState};});subscribe(afterScan$,function(_ref6){var activatedAction=_ref6.activatedAction,refererAction=_ref6.refererAction,successAction=_ref6.successAction,getState=_ref6.getState;var _activatedAction$acti=activatedAction.action
|
|
4
|
+
*/export default function scanner(subscribe){var events=core.getScannerEvents();subscribe(scanActivated$,function(_ref){var action=_ref.action,getState=_ref.getState;var format=action.format;track('qrScanner',createScannerEventData({event:events.SCAN_ACTIVATED,userInteraction:false,format:format}),getState());});subscribe(scanSuccess$,function(_ref2){var action=_ref2.action,getState=_ref2.getState;var format=action.format,payload=action.payload;track('qrScanner',createScannerEventData({event:events.SCAN_SUCCESS,format:format,payload:payload}),getState());});subscribe(scanFail$,function(_ref3){var action=_ref3.action,getState=_ref3.getState;var format=action.format,payload=action.payload;track('qrScanner',createScannerEventData({event:events.SCAN_FAIL,format:format,payload:payload}),getState());});var afterScan$=scanActivated$.withLatestFrom(routeDidLeave$).switchMap(function(){return scanSuccess$.first();},function(_ref4,successAction){var _ref5=_slicedToArray(_ref4,2),activatedAction=_ref5[0],refererAction=_ref5[1];return{activatedAction:activatedAction,refererAction:refererAction,successAction:successAction,getState:activatedAction.getState};});subscribe(afterScan$,function(_ref6){var activatedAction=_ref6.activatedAction,refererAction=_ref6.refererAction,successAction=_ref6.successAction,getState=_ref6.getState;var _activatedAction$acti=activatedAction.action,_activatedAction$acti2=_activatedAction$acti===void 0?{}:_activatedAction$acti,scannerRoute=_activatedAction$acti2.route;var _refererAction$action=refererAction.action.route,_refererAction$action2=_refererAction$action===void 0?{}:_refererAction$action,referer=_refererAction$action2.location;var _successAction$action=successAction.action,format=_successAction$action.format,payload=_successAction$action.payload;// eslint-disable-next-line extra-rules/no-single-line-objects
|
|
5
5
|
var urlWithUtm=buildScannerUtmUrl({scannerRoute:scannerRoute,format:format,payload:payload,referer:referer});track('setCampaignWithUrl',{url:urlWithUtm,type:'scanner'},getState());});}
|
package/subscriptions/search.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{getCurrentRoute}from'@shopgate/
|
|
1
|
+
import{getCurrentRoute}from'@shopgate/engage/core/selectors';import{searchIsReady$}from"../streams/search";import getTrackingData from"../selectors/search";import{track}from"../helpers/index";/**
|
|
2
2
|
* Search tracking subscriptions.
|
|
3
3
|
* @param {Function} subscribe The subscribe function.
|
|
4
4
|
*/export default function search(subscribe){subscribe(searchIsReady$,function(_ref){var getState=_ref.getState;var state=getState();track('search',{search:getTrackingData(state,getCurrentRoute(state))},state);});}
|
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});});}
|