@shopgate/engage 6.23.4-beta.2 → 6.23.4-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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/engage",
3
- "version": "6.23.4-beta.2",
3
+ "version": "6.23.4-beta.3",
4
4
  "description": "Shopgate's ENGAGE library.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Shopgate <support@shopgate.com>",
@@ -15,12 +15,12 @@
15
15
  "connect"
16
16
  ],
17
17
  "dependencies": {
18
- "@shopgate/pwa-common": "6.23.4-beta.2",
19
- "@shopgate/pwa-common-commerce": "6.23.4-beta.2",
20
- "@shopgate/pwa-core": "6.23.4-beta.2",
21
- "@shopgate/pwa-ui-ios": "6.23.4-beta.2",
22
- "@shopgate/pwa-ui-material": "6.23.4-beta.2",
23
- "@shopgate/pwa-ui-shared": "6.23.4-beta.2",
18
+ "@shopgate/pwa-common": "6.23.4-beta.3",
19
+ "@shopgate/pwa-common-commerce": "6.23.4-beta.3",
20
+ "@shopgate/pwa-core": "6.23.4-beta.3",
21
+ "@shopgate/pwa-ui-ios": "6.23.4-beta.3",
22
+ "@shopgate/pwa-ui-material": "6.23.4-beta.3",
23
+ "@shopgate/pwa-ui-shared": "6.23.4-beta.3",
24
24
  "@virtuous/conductor": "~2.4.0",
25
25
  "babel-plugin-transform-es3-member-expression-literals": "^6.8.0",
26
26
  "babel-plugin-transform-es3-property-literals": "^6.8.0",
@@ -1,4 +1,4 @@
1
- import{createSelector}from'reselect';import{appConfig}from'@shopgate/engage';/**
1
+ import{createSelector}from'reselect';import{appConfig}from'@shopgate/engage';import{appSupportsCookieConsent}from'@shopgate/engage/core/helpers';var _appConfig$cookieCons=appConfig.cookieConsent;_appConfig$cookieCons=_appConfig$cookieCons===void 0?{}:_appConfig$cookieCons;var isCookieConsentActivated=_appConfig$cookieCons.isCookieConsentActivated,showComfortCookiesToggle=_appConfig$cookieCons.showComfortCookiesToggle;/**
2
2
  * Selects the cookie consent modal state.
3
3
  * @param {Object} state The current state of the cookie consent modal.
4
4
  * @returns {Object} whether cookie consent modal is shown.
@@ -7,6 +7,10 @@ import{createSelector}from'reselect';import{appConfig}from'@shopgate/engage';/**
7
7
  * @param {Object} state The current state of the cookie settings.
8
8
  * @returns {Object} whether cookies have been accepted by the user.
9
9
  */export var getCookieSettingsState=function getCookieSettingsState(state){var _state$tracking2;return(state===null||state===void 0?void 0:(_state$tracking2=state.tracking)===null||_state$tracking2===void 0?void 0:_state$tracking2.cookieSettings)||{};};/**
10
+ * Determines whether the cookie consent process is finished (selection happened before, feature is
11
+ * inactive, app doesn't support the feature).
12
+ * @returns {boolean} whether cookie consent settings have been chosen by the user.
13
+ */export var getIsCookieConsentHandled=createSelector(getCookieSettingsState,function(settingsState){if(!isCookieConsentActivated||!appSupportsCookieConsent()){return true;}return(settingsState===null||settingsState===void 0?void 0:settingsState.comfortCookiesAccepted)!==null||(settingsState===null||settingsState===void 0?void 0:settingsState.statisticsCookiesAccepted)!==null;});/**
10
14
  * Selects the property of the comfort cookie settings.
11
15
  * @private This selector is intended to be used internally. When a cookie consent status needs
12
16
  * to be checked for a feature, please use `getAreComfortCookiesAccepted` instead.
@@ -16,18 +20,15 @@ import{createSelector}from'reselect';import{appConfig}from'@shopgate/engage';/**
16
20
  * @private This selector is intended to be used internally. When a cookie consent status needs
17
21
  * to be checked for a feature, please use `getAreStatisticsCookiesAccepted` instead.
18
22
  * @returns {boolean|null} whether statistics cookies have been selected by the user.
19
- */export var getAreStatisticsCookiesAcceptedInternal=createSelector(getCookieSettingsState,function(settingsState){return settingsState.statisticsCookiesAccepted;});var _appConfig$cookieCons=appConfig.cookieConsent;_appConfig$cookieCons=_appConfig$cookieCons===void 0?{}:_appConfig$cookieCons;var showComfortCookiesToggle=_appConfig$cookieCons.showComfortCookiesToggle,isCookieConsentActivated=_appConfig$cookieCons.isCookieConsentActivated;/**
23
+ */export var getAreStatisticsCookiesAcceptedInternal=createSelector(getCookieSettingsState,function(settingsState){return settingsState.statisticsCookiesAccepted;});/**
20
24
  * Determines if comfort cookies where accepted in the cookie consent process. When cookie
21
25
  * consent is inactive, the selector will also return true.
22
26
  * @returns {boolean} whether comfort cookies are set and should activate tracking.
23
- */export var getAreComfortCookiesAccepted=createSelector(getCookieSettingsState,function(settingsState){if(!isCookieConsentActivated||!showComfortCookiesToggle)return true;if(settingsState.comfortCookiesAccepted===null)return true;return settingsState.comfortCookiesAccepted;});/**
27
+ */export var getAreComfortCookiesAccepted=createSelector(getCookieSettingsState,getIsCookieConsentHandled,function(settingsState,consentHandled){if(!consentHandled)return false;if(!isCookieConsentActivated||!showComfortCookiesToggle)return true;if(settingsState.comfortCookiesAccepted===null)return true;return settingsState.comfortCookiesAccepted;});/**
24
28
  * Determines if statistics cookies where accepted in the cookie consent process. When cookie
25
29
  * consent is inactive, the selector will also return true.
26
30
  * @returns {boolean} whether statistics cookies are set and should activate tracking.
27
- */export var getAreStatisticsCookiesAccepted=createSelector(getCookieSettingsState,function(settingsState){if(!isCookieConsentActivated)return true;if(settingsState.statisticsCookiesAccepted===null)return true;return settingsState.statisticsCookiesAccepted;});/**
31
+ */export var getAreStatisticsCookiesAccepted=createSelector(getCookieSettingsState,getIsCookieConsentHandled,function(settingsState,consentHandled){if(!consentHandled)return false;if(!isCookieConsentActivated)return true;if(settingsState.statisticsCookiesAccepted===null)return true;return settingsState.statisticsCookiesAccepted;});/**
28
32
  * Selects the visibility property of the cookie consent modal.
29
33
  * @returns {boolean} whether cookie consent modal is shown.
30
- */export var getIsCookieConsentModalVisible=createSelector(getCookieConsentModalState,getAreComfortCookiesAcceptedInternal,getAreStatisticsCookiesAcceptedInternal,function(modalState,comfortCookiesState,statisticsCookiesState){return modalState.isCookieConsentModalVisible&&comfortCookiesState===null&&statisticsCookiesState===null;});/**
31
- * Selects the cookie consent settings property.
32
- * @returns {boolean} whether cookie consent settings have been chosen by the user.
33
- */export var getIsCookieConsentHandled=createSelector(getCookieSettingsState,function(settingsState){return(settingsState===null||settingsState===void 0?void 0:settingsState.comfortCookiesAccepted)!==null||(settingsState===null||settingsState===void 0?void 0:settingsState.statisticsCookiesAccepted)!==null;});
34
+ */export var getIsCookieConsentModalVisible=createSelector(getCookieConsentModalState,getAreComfortCookiesAcceptedInternal,getAreStatisticsCookiesAcceptedInternal,function(modalState,comfortCookiesState,statisticsCookiesState){return modalState.isCookieConsentModalVisible&&comfortCookiesState===null&&statisticsCookiesState===null;});
@@ -1,17 +1,17 @@
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{main$,appDidStart$}from'@shopgate/engage/core/streams';import{ROUTE_WILL_LEAVE}from'@shopgate/engage/core/constants';import{PRIVACY_SETTINGS_PATTERN}from'@shopgate/engage/tracking/constants';import{appSupportsCookieConsent}from'@shopgate/engage/core/helpers';import{grantAppTrackingTransparencyPermission,historyReset,historyPop}from'@shopgate/engage/core/actions';import{handleCookieConsent,showCookieConsentModal}from"../action-creators";import{getIsCookieConsentHandled,getAreComfortCookiesAccepted,getAreStatisticsCookiesAccepted}from"../selectors/cookieConsent";import{cookieConsentInitializedByUserInternal$,privacySettingsConfirmedWithoutChangeInternal$}from"../streams/cookieConsent";import{appConfig}from"../../index";/**
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{main$,appDidStart$}from'@shopgate/engage/core/streams';import{ROUTE_WILL_LEAVE}from'@shopgate/engage/core/constants';import{PRIVACY_SETTINGS_PATTERN}from'@shopgate/engage/tracking/constants';import{appSupportsCookieConsent}from'@shopgate/engage/core/helpers';import{grantAppTrackingTransparencyPermission,historyReset,historyPop}from'@shopgate/engage/core/actions';import{handleCookieConsent,showCookieConsentModal}from"../action-creators";import{getIsCookieConsentHandled,getAreComfortCookiesAccepted,getAreStatisticsCookiesAccepted}from"../selectors/cookieConsent";import{cookieConsentInitializedByUserInternal$,privacySettingsConfirmedWithoutChangeInternal$}from"../streams/cookieConsent";/**
2
2
  * stream which gets triggered when the user navigates back from privacy settings page
3
3
  * and cookie consent modal needs to be shown again.
4
4
  * @type {Observable}
5
5
  */export var navigateBackToCookieModal$=main$.filter(function(_ref){var action=_ref.action;return action.type===ROUTE_WILL_LEAVE;}).filter(function(_ref2){var action=_ref2.action;return action.route.pathname===PRIVACY_SETTINGS_PATTERN;});/**
6
6
  * determine whether to show the cookie consent modal at app start
7
7
  * @param {Function} subscribe The subscribe function
8
- */export default function cookieConsent(subscribe){subscribe(appDidStart$,/*#__PURE__*/function(){var _ref4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref3){var dispatch,getState,state,_appConfig$cookieCons,isCookieConsentActivated,isCookieConsentHandled,comfortCookiesAccepted,statisticsCookiesAccepted;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:dispatch=_ref3.dispatch,getState=_ref3.getState;state=getState();_appConfig$cookieCons=appConfig.cookieConsent;_appConfig$cookieCons=_appConfig$cookieCons===void 0?{}:_appConfig$cookieCons;isCookieConsentActivated=_appConfig$cookieCons.isCookieConsentActivated;isCookieConsentHandled=getIsCookieConsentHandled(state);/**
8
+ */export default function cookieConsent(subscribe){subscribe(appDidStart$,/*#__PURE__*/function(){var _ref4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref3){var dispatch,getState,state,isCookieConsentHandled,comfortCookiesAccepted,statisticsCookiesAccepted;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:dispatch=_ref3.dispatch,getState=_ref3.getState;state=getState();isCookieConsentHandled=getIsCookieConsentHandled(state);/**
9
9
  * if merchant has not activated the cookie feature OR if merchant has activated cookie feature
10
10
  * and user has chosen cookies already trigger stream to run code that depends on the cookie
11
11
  * consent.
12
- */if(!(!isCookieConsentActivated||isCookieConsentActivated&&isCookieConsentHandled||!appSupportsCookieConsent())){_context.next=14;break;}comfortCookiesAccepted=getAreComfortCookiesAccepted(state);statisticsCookiesAccepted=getAreStatisticsCookiesAccepted(state);dispatch(handleCookieConsent({comfortCookiesAccepted:comfortCookiesAccepted,statisticsCookiesAccepted:statisticsCookiesAccepted}));if(!(appSupportsCookieConsent()&&(comfortCookiesAccepted||statisticsCookiesAccepted))){_context.next=13;break;}_context.next=13;return dispatch(grantAppTrackingTransparencyPermission());case 13:return _context.abrupt("return");case 14:// if merchant has activated cookie feature but user has not chosen cookies yet:
12
+ */if(!isCookieConsentHandled){_context.next=12;break;}comfortCookiesAccepted=getAreComfortCookiesAccepted(state);statisticsCookiesAccepted=getAreStatisticsCookiesAccepted(state);dispatch(handleCookieConsent({comfortCookiesAccepted:comfortCookiesAccepted,statisticsCookiesAccepted:statisticsCookiesAccepted}));if(!(appSupportsCookieConsent()&&(comfortCookiesAccepted||statisticsCookiesAccepted))){_context.next=10;break;}_context.next=10;return dispatch(grantAppTrackingTransparencyPermission());case 10:_context.next=13;break;case 12:// if merchant has activated cookie feature but user has not chosen cookies yet:
13
13
  // show cookie consent modal to make user choose them
14
- if(isCookieConsentActivated&&!isCookieConsentHandled){dispatch(showCookieConsentModal());}case 15:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref4.apply(this,arguments);};}());subscribe(navigateBackToCookieModal$,function(_ref5){var dispatch=_ref5.dispatch,getState=_ref5.getState;var isCookieConsentActivated=appConfig.cookieConsent.isCookieConsentActivated;var isCookieConsentHandled=getIsCookieConsentHandled(getState());if(isCookieConsentActivated&&!isCookieConsentHandled){dispatch(showCookieConsentModal());}});subscribe(cookieConsentInitializedByUserInternal$,function(_ref6){var dispatch=_ref6.dispatch;// Reset history after consent initialization to guarantee an empty history
14
+ dispatch(showCookieConsentModal());case 13:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref4.apply(this,arguments);};}());subscribe(navigateBackToCookieModal$,function(_ref5){var dispatch=_ref5.dispatch,getState=_ref5.getState;var isCookieConsentHandled=getIsCookieConsentHandled(getState());if(!isCookieConsentHandled){dispatch(showCookieConsentModal());}});subscribe(cookieConsentInitializedByUserInternal$,function(_ref6){var dispatch=_ref6.dispatch;// Reset history after consent initialization to guarantee an empty history
15
15
  dispatch(historyReset());});subscribe(privacySettingsConfirmedWithoutChangeInternal$,function(_ref7){var dispatch=_ref7.dispatch;// Remove privacy settings route from route stack when any button was clicked but no settings
16
16
  // where changed. When something was changed, app will reset via the "analytics" streams.
17
17
  dispatch(historyPop());});}