@shopgate/engage 7.20.3 → 7.21.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.
- package/back-in-stock/components/BackInStockButton/index.js +1 -1
- package/core/action-creators/index.js +1 -1
- package/core/action-creators/optIns.js +37 -0
- package/core/actions/grantAppTrackingTransparencyPermission.js +3 -1
- package/core/actions/grantPermissions.js +7 -4
- package/core/actions/grantPushPermissions.js +2 -1
- package/core/constants/index.js +1 -1
- package/core/constants/optIns.js +1 -0
- package/core/streams/index.js +1 -1
- package/core/streams/optIns.js +13 -0
- package/package.json +7 -7
- package/push-opt-in/action-creators/pushOptIn.js +2 -1
- package/push-opt-in/actions/pushOptInModal.js +3 -3
- package/push-opt-in/reducers/optInModal.js +2 -2
- package/push-opt-in/reducers/optInTrigger.js +2 -2
- package/push-opt-in/selectors/optInModal.js +5 -2
- package/push-opt-in/selectors/optInTrigger.js +4 -2
- package/push-opt-in/subscriptions/index.js +1 -1
- package/push-opt-in/subscriptions/optInTracking.js +4 -0
- package/push-opt-in/subscriptions/optInTrigger.js +3 -3
- package/tracking/actions/cookieConsent.js +16 -4
- package/tracking/helpers/index.js +1 -0
- package/tracking/selectors/cookieConsent.js +6 -2
- package/tracking/streams/cookieConsent.js +2 -2
- package/tracking/subscriptions/analytics.js +5 -4
- package/tracking/subscriptions/cookieConsent.js +4 -4
|
@@ -10,5 +10,5 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function _defineProp
|
|
|
10
10
|
* @param {Function} props.addBackInStockSubscription Add product to back in stock list
|
|
11
11
|
* @param {Function} props.grantPushPermissions Request / Set push permission
|
|
12
12
|
* @return {JSX.Element}
|
|
13
|
-
*/var BackInStockButton=function BackInStockButton(_ref){var productId=_ref.productId,_ref$isLinkToBackInSt=_ref.isLinkToBackInStockEnabled,isLinkToBackInStockEnabled=_ref$isLinkToBackInSt===void 0?false:_ref$isLinkToBackInSt,subscription=_ref.subscription,_ref$stopPropagation=_ref.stopPropagation,stopPropagation=_ref$stopPropagation===void 0?false:_ref$stopPropagation,addBackInStockSubscription=_ref.addBackInStockSubscription,grantPushPermissions=_ref.grantPushPermissions,alignRight=_ref.alignRight,showAsButton=_ref.showAsButton;var handleClick=useCallback(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(event){var allowed;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:if(stopPropagation){event.stopPropagation();}_context.next=3;return grantPushPermissions({useRationaleModal:true,useSettingsModal:true,rationaleModal:{message:'back_in_stock.rationale.message',confirm:'back_in_stock.rationale.confirm',dismiss:'common.cancel'}});case 3:allowed=_context.sent;if(allowed){addBackInStockSubscription({productId:productId});}case 5:case"end":return _context.stop();}},_callee);}));return function(_x){return _ref2.apply(this,arguments);};}(),[addBackInStockSubscription,grantPushPermissions,productId,stopPropagation]);if((subscription===null||subscription===void 0?void 0:subscription.status)==='active'){return React.createElement(Link,{href:BACK_IN_STOCK_PATTERN,disabled:!isLinkToBackInStockEnabled,className:classNames(styles.backInStockMessageContainer,_defineProperty({},styles.rightAligned,alignRight)),tag:"span"},React.createElement(CheckedIcon,{color:colors.success,className:alignRight?styles.icon:classNames(styles.iconCentered,styles.icon)}),React.createElement("span",{className:styles.backInStockMessage},i18n.text('back_in_stock.we_will_remind_you')));}if(showAsButton){return React.createElement(Button,{type:"primary",tabIndex:0,onClick:handleClick,className:styles.button},React.createElement("span",{className:styles.buttonText},i18n.text('back_in_stock.get_notified')));}return(// eslint-disable-next-line jsx-a11y/anchor-is-valid,jsx-a11y/click-events-have-key-events
|
|
13
|
+
*/var BackInStockButton=function BackInStockButton(_ref){var productId=_ref.productId,_ref$isLinkToBackInSt=_ref.isLinkToBackInStockEnabled,isLinkToBackInStockEnabled=_ref$isLinkToBackInSt===void 0?false:_ref$isLinkToBackInSt,subscription=_ref.subscription,_ref$stopPropagation=_ref.stopPropagation,stopPropagation=_ref$stopPropagation===void 0?false:_ref$stopPropagation,addBackInStockSubscription=_ref.addBackInStockSubscription,grantPushPermissions=_ref.grantPushPermissions,alignRight=_ref.alignRight,showAsButton=_ref.showAsButton;var handleClick=useCallback(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(event){var allowed;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:if(stopPropagation){event.stopPropagation();}_context.next=3;return grantPushPermissions({useRationaleModal:true,useSettingsModal:true,rationaleModal:{message:'back_in_stock.rationale.message',confirm:'back_in_stock.rationale.confirm',dismiss:'common.cancel'},meta:{context:'backInStock',usesSoftPushOptIn:false,permission:'push'}});case 3:allowed=_context.sent;if(allowed){addBackInStockSubscription({productId:productId});}case 5:case"end":return _context.stop();}},_callee);}));return function(_x){return _ref2.apply(this,arguments);};}(),[addBackInStockSubscription,grantPushPermissions,productId,stopPropagation]);if((subscription===null||subscription===void 0?void 0:subscription.status)==='active'){return React.createElement(Link,{href:BACK_IN_STOCK_PATTERN,disabled:!isLinkToBackInStockEnabled,className:classNames(styles.backInStockMessageContainer,_defineProperty({},styles.rightAligned,alignRight)),tag:"span"},React.createElement(CheckedIcon,{color:colors.success,className:alignRight?styles.icon:classNames(styles.iconCentered,styles.icon)}),React.createElement("span",{className:styles.backInStockMessage},i18n.text('back_in_stock.we_will_remind_you')));}if(showAsButton){return React.createElement(Button,{type:"primary",tabIndex:0,onClick:handleClick,className:styles.button},React.createElement("span",{className:styles.buttonText},i18n.text('back_in_stock.get_notified')));}return(// eslint-disable-next-line jsx-a11y/anchor-is-valid,jsx-a11y/click-events-have-key-events
|
|
14
14
|
React.createElement("a",{role:"button",tabIndex:0,onClick:handleClick,className:classNames(styles.button,_defineProperty({},styles.rightAligned,alignRight))},React.createElement(NotificationIcon,{color:colors.primary,className:styles.icon}),React.createElement("span",{className:styles.buttonText},i18n.text('back_in_stock.get_notified'))));};BackInStockButton.defaultProps={stopPropagation:false,isLinkToBackInStockEnabled:false,showAsButton:false,alignRight:false,subscription:null,productId:null};export default connect(BackInStockButton);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{receiveShopSettings,errorShopSettings}from"./shopSettings";export{receiveMerchantSettings}from"./merchantSettings";export*from"./app";export*from"./appPermissions";
|
|
1
|
+
export{receiveShopSettings,errorShopSettings}from"./shopSettings";export{receiveMerchantSettings}from"./merchantSettings";export*from"./app";export*from"./appPermissions";export*from"./optIns";
|
|
@@ -0,0 +1,37 @@
|
|
|
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{SOFT_OPT_IN_SHOWN,SOFT_OPT_IN_SELECTED,HARD_OPT_IN_SHOWN,HARD_OPT_IN_SELECTED,PERMISSION_STATUS_DENIED,PERMISSION_STATUS_GRANTED,PERMISSION_STATUS_NOT_DETERMINED}from'@shopgate/engage/core/constants';/**
|
|
2
|
+
* @typedef {Object} OptInMeta
|
|
3
|
+
* @property {string} permission Permission type the event is dispatched for
|
|
4
|
+
*/ /**
|
|
5
|
+
* Sanitizes the meta object of opt in actions
|
|
6
|
+
* @param {OptInMeta} meta The original meta object
|
|
7
|
+
* @returns {Object} The sanitized meta object
|
|
8
|
+
*/var sanitizeMeta=function sanitizeMeta(){var meta=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return _extends({permission:'other'},meta);};/**
|
|
9
|
+
* Creates the SOFT_OPT_IN_SHOWN Redux action object that's supposed to be dispatched when a
|
|
10
|
+
* soft opt-in (e.g. push or tracking) was shown.
|
|
11
|
+
* @param {Object} params Action params
|
|
12
|
+
* @param {OptInMeta} params.meta Meta data for the action
|
|
13
|
+
* @returns {Object} The Redux action object
|
|
14
|
+
*/export var softOptInShown=function softOptInShown(){var _ref=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},meta=_ref.meta;return{type:SOFT_OPT_IN_SHOWN,meta:sanitizeMeta(meta)};};/**
|
|
15
|
+
* Creates the SOFT_OPT_IN_SELECTED Redux action object that's supposed to be dispatched when a
|
|
16
|
+
* a decision inside a soft opt-in (e.g. push or tracking) was taken.
|
|
17
|
+
* @param {Object} params Action params
|
|
18
|
+
* @param {"approved"|"denied"|"later"|"approvedAll"|"deniedAll"|"manage"} params.selection
|
|
19
|
+
* User selection
|
|
20
|
+
* @param {OptInMeta} params.meta Meta data for the action
|
|
21
|
+
* @returns {Object} The Redux action object
|
|
22
|
+
*/export var softOptInSelected=function softOptInSelected(_ref2){var selection=_ref2.selection,meta=_ref2.meta;return{type:SOFT_OPT_IN_SELECTED,selection:selection,meta:sanitizeMeta(meta)};};/**
|
|
23
|
+
* Creates the HARD_OPT_IN_SHOWN Redux action object that's supposed to be dispatched when a
|
|
24
|
+
* hard opt-in (native permission dialog) was shown.
|
|
25
|
+
* @param {Object} params Action params
|
|
26
|
+
* @param {string} params.permissionId Permission id the action was dispatched for
|
|
27
|
+
* @param {OptInMeta} params.meta Meta data for the action
|
|
28
|
+
* @returns {Object} The Redux action object
|
|
29
|
+
*/export var hardOptInShown=function hardOptInShown(_ref3){var permissionId=_ref3.permissionId,meta=_ref3.meta;return{type:HARD_OPT_IN_SHOWN,permissionId:permissionId,meta:sanitizeMeta(meta)};};/**
|
|
30
|
+
* Creates the HARD_OPT_IN_SELECTED Redux action object that's supposed to be dispatched when a
|
|
31
|
+
* a decision inside a hard opt-in (native permission dialog) was taken.
|
|
32
|
+
* @param {Object} params Action params
|
|
33
|
+
* @param {string} params.permissionId Permission id the action was dispatched for
|
|
34
|
+
* @param {string} params.status Permission status
|
|
35
|
+
* @param {OptInMeta} params.meta Meta data for the action
|
|
36
|
+
* @returns {Object} The Redux action object
|
|
37
|
+
*/export var hardOptInSelected=function hardOptInSelected(_ref4){var permissionId=_ref4.permissionId,status=_ref4.status,meta=_ref4.meta;var selection='other';switch(status){case PERMISSION_STATUS_GRANTED:selection='approved';break;case PERMISSION_STATUS_DENIED:selection='denied';break;case PERMISSION_STATUS_NOT_DETERMINED:selection='later';break;default:break;}return{type:HARD_OPT_IN_SELECTED,permissionId:permissionId,selection:selection,meta:sanitizeMeta(meta)};};
|
|
@@ -2,5 +2,7 @@ import{PERMISSION_ID_APP_TRACKING_TRANSPARENCY}from'@shopgate/engage/core/consta
|
|
|
2
2
|
* Determines the current state of the app tracking transparency permission.
|
|
3
3
|
* If not already happened, the user will be prompted to grant permissions.
|
|
4
4
|
* The action returns a promise which resolves with a boolean value, that indicates the state.
|
|
5
|
+
* @param {Object} options Action options.
|
|
6
|
+
* @param {Object} [options.meta={}] Additional meta data used for opt-in tracking actions
|
|
5
7
|
* @return { Function } A redux thunk.
|
|
6
|
-
*/var grantAppTrackingTransparencyPermission=function grantAppTrackingTransparencyPermission(){return function(dispatch){return dispatch(grantPermissions({permissionId:PERMISSION_ID_APP_TRACKING_TRANSPARENCY}));};};export default grantAppTrackingTransparencyPermission;
|
|
8
|
+
*/var grantAppTrackingTransparencyPermission=function grantAppTrackingTransparencyPermission(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return function(dispatch){var _options$meta=options.meta,meta=_options$meta===void 0?{}:_options$meta;return dispatch(grantPermissions({permissionId:PERMISSION_ID_APP_TRACKING_TRANSPARENCY,meta:meta}));};};export default grantAppTrackingTransparencyPermission;
|
|
@@ -1,4 +1,4 @@
|
|
|
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 event from'@shopgate/pwa-core/classes/Event';import{openAppSettings}from'@shopgate/engage/core/commands';import{showModal}from'@shopgate/engage/core/actions';import{PERMISSION_STATUS_DENIED,PERMISSION_STATUS_GRANTED,PERMISSION_STATUS_NOT_DETERMINED,PERMISSION_STATUS_NOT_SUPPORTED,APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND,availablePermissionsIds}from'@shopgate/engage/core/constants';import{logger,hasSGJavaScriptBridge,hasWebBridge}from'@shopgate/engage/core/helpers';import requestAppPermission from"./requestAppPermission";import requestAppPermissionStatus from"./requestAppPermissionStatus";import{createMockedPermissions}from"../helpers/appPermissions";/**
|
|
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 event from'@shopgate/pwa-core/classes/Event';import{openAppSettings}from'@shopgate/engage/core/commands';import{showModal}from'@shopgate/engage/core/actions';import{PERMISSION_STATUS_DENIED,PERMISSION_STATUS_GRANTED,PERMISSION_STATUS_NOT_DETERMINED,PERMISSION_STATUS_NOT_SUPPORTED,APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND,availablePermissionsIds}from'@shopgate/engage/core/constants';import{logger,hasSGJavaScriptBridge,hasWebBridge}from'@shopgate/engage/core/helpers';import{softOptInShown,softOptInSelected,hardOptInShown,hardOptInSelected}from"../action-creators";import requestAppPermission from"./requestAppPermission";import requestAppPermissionStatus from"./requestAppPermissionStatus";import{createMockedPermissions}from"../helpers/appPermissions";/**
|
|
2
2
|
* Determines the current state of a specific permission for an app feature. If not already
|
|
3
3
|
* happened, the user will be prompted to grant permissions.
|
|
4
4
|
* The action returns a promise which resolves with a boolean value, that indicates the state.
|
|
@@ -23,16 +23,19 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGenera
|
|
|
23
23
|
* requested if not already granted,
|
|
24
24
|
* @param {boolean} [options.resolveWithData=false] If set to TRUE the Promise will resolve with
|
|
25
25
|
* data if available (e.g. geolocation).
|
|
26
|
+
* @param {Object} [options.meta={}] Additional meta data used for opt-in tracking actions
|
|
26
27
|
* @return { Function } A redux thunk.
|
|
27
|
-
*/var grantPermissions=function grantPermissions(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return function(dispatch){return new Promise(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resolve){var permissionId,_options$useSettingsM,useSettingsModal,_options$useRationale,useRationaleModal,_options$rationaleMod,rationaleModalOptions,_options$modal,modalOptions,_options$requestPermi,requestPermissions,_options$resolveWithD,resolveWithData,dispatchMock,fallbackStatus,status,data,_ref2,requestAllowed,_ref3,openSettings,handler;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:permissionId=options.permissionId,_options$useSettingsM=options.useSettingsModal,useSettingsModal=_options$useSettingsM===void 0?false:_options$useSettingsM,_options$useRationale=options.useRationaleModal,useRationaleModal=_options$useRationale===void 0?false:_options$useRationale,_options$rationaleMod=options.rationaleModal,rationaleModalOptions=_options$rationaleMod===void 0?{}:_options$rationaleMod,_options$modal=options.modal,modalOptions=_options$modal===void 0?{}:_options$modal,_options$requestPermi=options.requestPermissions,requestPermissions=_options$requestPermi===void 0?true:_options$requestPermi,_options$resolveWithD=options.resolveWithData,resolveWithData=_options$resolveWithD===void 0?false:_options$resolveWithD;if(!hasSGJavaScriptBridge()||hasWebBridge()){/**
|
|
28
|
+
*/var grantPermissions=function grantPermissions(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return function(dispatch){return new Promise(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resolve){var permissionId,_options$useSettingsM,useSettingsModal,_options$useRationale,useRationaleModal,_options$rationaleMod,rationaleModalOptions,_options$modal,modalOptions,_options$requestPermi,requestPermissions,_options$resolveWithD,resolveWithData,_options$meta,meta,dispatchMock,fallbackStatus,status,data,_ref2,requestAllowed,_ref3,openSettings,handler;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:permissionId=options.permissionId,_options$useSettingsM=options.useSettingsModal,useSettingsModal=_options$useSettingsM===void 0?false:_options$useSettingsM,_options$useRationale=options.useRationaleModal,useRationaleModal=_options$useRationale===void 0?false:_options$useRationale,_options$rationaleMod=options.rationaleModal,rationaleModalOptions=_options$rationaleMod===void 0?{}:_options$rationaleMod,_options$modal=options.modal,modalOptions=_options$modal===void 0?{}:_options$modal,_options$requestPermi=options.requestPermissions,requestPermissions=_options$requestPermi===void 0?true:_options$requestPermi,_options$resolveWithD=options.resolveWithData,resolveWithData=_options$resolveWithD===void 0?false:_options$resolveWithD,_options$meta=options.meta,meta=_options$meta===void 0?{}:_options$meta;if(!hasSGJavaScriptBridge()||hasWebBridge()){/**
|
|
28
29
|
* The fallbackStatus will be used at browsers that don't support the permissions API. By
|
|
29
30
|
* default it will always resolve with GRANTED, so that further steps still might trigger a
|
|
30
31
|
* permissions dialog. When permissions are not supposed to be requested, it will resolve with
|
|
31
32
|
* the NOT_DETERMINED status, to keep logic between browsers / apps in sync as much as possible.
|
|
32
|
-
*/fallbackStatus=requestPermissions?PERMISSION_STATUS_GRANTED:PERMISSION_STATUS_NOT_DETERMINED;dispatchMock=createMockedPermissions(fallbackStatus);}if(availablePermissionsIds.includes(permissionId)){_context2.next=6;break;}logger.error('grandPermissions: %s is no valid permission id',permissionId);resolve(false);return _context2.abrupt("return");case 6:_context2.next=8;return dispatch(requestAppPermissionStatus({permissionId:permissionId,dispatchMock:dispatchMock}));case 8:_ref2=_context2.sent;status=_ref2.status;if(!(status===PERMISSION_STATUS_NOT_SUPPORTED)){_context2.next=13;break;}resolve(false);return _context2.abrupt("return");case 13:if(!(status===PERMISSION_STATUS_NOT_DETERMINED)){_context2.next=
|
|
33
|
+
*/fallbackStatus=requestPermissions?PERMISSION_STATUS_GRANTED:PERMISSION_STATUS_NOT_DETERMINED;dispatchMock=createMockedPermissions(fallbackStatus);}if(availablePermissionsIds.includes(permissionId)){_context2.next=6;break;}logger.error('grandPermissions: %s is no valid permission id',permissionId);resolve(false);return _context2.abrupt("return");case 6:_context2.next=8;return dispatch(requestAppPermissionStatus({permissionId:permissionId,dispatchMock:dispatchMock}));case 8:_ref2=_context2.sent;status=_ref2.status;if(!(status===PERMISSION_STATUS_NOT_SUPPORTED)){_context2.next=13;break;}resolve(false);return _context2.abrupt("return");case 13:if(!(status===PERMISSION_STATUS_NOT_DETERMINED)){_context2.next=36;break;}if(requestPermissions){_context2.next=17;break;}resolve(false);return _context2.abrupt("return");case 17:if(!useRationaleModal){_context2.next=26;break;}dispatch(softOptInShown({meta:meta}));_context2.next=21;return dispatch(showModal({message:rationaleModalOptions.message||'',confirm:rationaleModalOptions.confirm||'',dismiss:rationaleModalOptions.dismiss||'',params:rationaleModalOptions.params}));case 21:requestAllowed=_context2.sent;dispatch(softOptInSelected({selection:requestAllowed?'approved':'later',meta:meta}));if(!(requestAllowed===false)){_context2.next=26;break;}resolve(false);return _context2.abrupt("return");case 26:dispatch(hardOptInShown({permissionId:permissionId,meta:meta}));// Trigger the native permissions dialog.
|
|
34
|
+
_context2.next=29;return dispatch(requestAppPermission({permissionId:permissionId,dispatchMock:dispatchMock}));case 29:_ref3=_context2.sent;status=_ref3.status;data=_ref3.data;dispatch(hardOptInSelected({permissionId:permissionId,status:status,meta:meta}));// The user denied the permissions within the native dialog.
|
|
35
|
+
if(![PERMISSION_STATUS_DENIED,PERMISSION_STATUS_NOT_DETERMINED].includes(status)){_context2.next=36;break;}resolve(false);return _context2.abrupt("return");case 36:if(!(status===PERMISSION_STATUS_GRANTED)){_context2.next=39;break;}resolve(resolveWithData&&data?data:true);return _context2.abrupt("return");case 39:if(!(status===PERMISSION_STATUS_DENIED)){_context2.next=52;break;}if(useSettingsModal){_context2.next=43;break;}resolve(false);return _context2.abrupt("return");case 43:_context2.next=45;return dispatch(showModal({title:modalOptions.title||null,message:modalOptions.message,confirm:modalOptions.confirm,dismiss:modalOptions.dismiss,params:modalOptions.params}));case 45:openSettings=_context2.sent;if(openSettings){_context2.next=49;break;}resolve(false);return _context2.abrupt("return");case 49:/**
|
|
33
36
|
* Handler for the app event.
|
|
34
37
|
*/handler=/*#__PURE__*/function(){var _ref4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var _ref5;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:event.removeCallback(APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND,handler);_context.next=3;return dispatch(requestAppPermissionStatus({permissionId:permissionId}));case 3:_ref5=_context.sent;status=_ref5.status;resolve(status===PERMISSION_STATUS_GRANTED);case 6:case"end":return _context.stop();}},_callee);}));return function handler(){return _ref4.apply(this,arguments);};}();/**
|
|
35
38
|
* Register an event handler, so that we can perform the permissions check again,
|
|
36
39
|
* when the user comes back from the settings.
|
|
37
40
|
*/event.addCallback(APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND,handler);// Open the settings (protected by a timeout, so that the modal closes before the app is left).
|
|
38
|
-
setTimeout(function(){openAppSettings();},0);case
|
|
41
|
+
setTimeout(function(){openAppSettings();},0);case 52:case"end":return _context2.stop();}},_callee2);}));return function(_x){return _ref.apply(this,arguments);};}());};};export default grantPermissions;
|
|
@@ -18,5 +18,6 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
|
|
|
18
18
|
* @param {string} options.modal.confirm Label for the confirm button.
|
|
19
19
|
* @param {string} options.modal.dismiss Label for the dismiss button.
|
|
20
20
|
* @param {Object} options.modal.params Additional parameters for i18n strings.
|
|
21
|
+
* @param {Object} [options.meta={}] Additional meta data used for opt-in tracking actions
|
|
21
22
|
* @return { Function } A redux thunk.
|
|
22
|
-
*/var grantPushPermissions=function grantPushPermissions(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return function(dispatch){var _options$useSettingsM=options.useSettingsModal,useSettingsModal=_options$useSettingsM===void 0?true:_options$useSettingsM,_options$useRationale=options.useRationaleModal,useRationaleModal=_options$useRationale===void 0?false:_options$useRationale,_options$modal=options.modal,modal=_options$modal===void 0?{}:_options$modal,_options$rationaleMod=options.rationaleModal,rationaleModal=_options$rationaleMod===void 0?{}:_options$rationaleMod;return dispatch(grantPermissions({permissionId:PERMISSION_ID_PUSH,useSettingsModal:useSettingsModal,useRationaleModal:useRationaleModal,modal:_extends({title:null,message:'permissions.access_denied.push_message',confirm:'permissions.access_denied.settings_button'},modal),rationaleModal:rationaleModal}));};};export default grantPushPermissions;
|
|
23
|
+
*/var grantPushPermissions=function grantPushPermissions(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return function(dispatch){var _options$useSettingsM=options.useSettingsModal,useSettingsModal=_options$useSettingsM===void 0?true:_options$useSettingsM,_options$useRationale=options.useRationaleModal,useRationaleModal=_options$useRationale===void 0?false:_options$useRationale,_options$modal=options.modal,modal=_options$modal===void 0?{}:_options$modal,_options$rationaleMod=options.rationaleModal,rationaleModal=_options$rationaleMod===void 0?{}:_options$rationaleMod,_options$meta=options.meta,meta=_options$meta===void 0?{}:_options$meta;return dispatch(grantPermissions({permissionId:PERMISSION_ID_PUSH,useSettingsModal:useSettingsModal,useRationaleModal:useRationaleModal,modal:_extends({title:null,message:'permissions.access_denied.push_message',confirm:'permissions.access_denied.settings_button'},modal),rationaleModal:rationaleModal,meta:meta}));};};export default grantPushPermissions;
|
package/core/constants/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{INDEX_PATH,INDEX_PATH_DEEPLINK,LOGIN_PATH}from'@shopgate/pwa-common/constants/RoutePaths';export{RECEIVE_SHOP_SETTINGS,ERROR_SHOP_SETTINGS,CACHE_LEASE_SHOP_SETTINGS,SHOP_SETTING_GOOGLE_SITE_VERIFICATION_CODE,SHOP_SETTING_CART_SUPPLEMENTAL_CONTENT,SHOP_SETTING_ORDER_SUPPLEMENTAL_CONTENT,SHOP_SETTING_SHOW_SHOP_LOGO_IN_APP,SHOP_SETTING_SHOW_SHOP_LOGO_IN_WEB,SHOP_SETTING_PRODUCTS_SORT_ORDER,SHOP_SETTING_COOKIE_CONSENT_MODE,SHOP_SETTING_DISPLAY_PRICE_PER_MEASURE_UNIT,SHOP_SETTING_IMAGES,SHOP_SETTING_IMAGES_PRODUCT_PLACEHOLDER,SHOP_SETTING_IMAGES_CATEGORY_PLACEHOLDER,SHOP_SETTING_IMAGES_FAVICON,SHOP_SETTING_NUMBER_OF_ADDRESS_LINES,SHOP_SETTING_REGISTRATION_MODE_SIMPLE,SHOP_SETTING_REGISTRATION_MODE_EXTENDED,SHOP_SETTING_WISHLIST_ITEM_QUANTITY_ENABLED,SHOP_SETTING_WISHLIST_ITEM_NOTES_ENABLED,SHOP_SETTING_LOAD_WISHLIST_ON_APP_START_ENABLED,SHOP_SETTING_SHOW_WISHLIST_ITEMS_COUNT_BADGE}from"./shopSettings";export{RECEIVE_MERCHANT_SETTINGS,MERCHANT_SETTINGS_LOCATION_BASED_SHOPPING_ENABLED,MERCHANT_SETTINGS_SUBSTITUTION_PREFERENCES_ENABLED,MERCHANT_SETTINGS_CUSTOMER_ATTRIBUTES,MERCHANT_SETTINGS_FULFILLMENT_SCHEDULED_ENABLED,MERCHANT_SETTINGS_RESTRICT_MULTI_LOCATION_ORDERS,MERCHANT_SETTINGS_DEFAULT_CURRENCY,MERCHANT_SETTINGS_ENABLE_WEB_INDEXING,MERCHANT_SETTINGS_PRODUCT_SHOW_ALTERNATIVE_LOCATION,MERCHANT_SETTINGS_PRODUCTLIST_SHOW_INVENTORY}from"./merchantSettings";export{SHOPGATE_CORE_GET_SHOP_SETTINGS,EUNAUTHORIZED,EAUTHENTICATION}from"./pipelines";export*from"./actionTypes";export*from"./appFeatures";export*from"./deviceTypes";export*from"./geolocationRequest";// Core Constants
|
|
1
|
+
import{INDEX_PATH,INDEX_PATH_DEEPLINK,LOGIN_PATH}from'@shopgate/pwa-common/constants/RoutePaths';export{RECEIVE_SHOP_SETTINGS,ERROR_SHOP_SETTINGS,CACHE_LEASE_SHOP_SETTINGS,SHOP_SETTING_GOOGLE_SITE_VERIFICATION_CODE,SHOP_SETTING_CART_SUPPLEMENTAL_CONTENT,SHOP_SETTING_ORDER_SUPPLEMENTAL_CONTENT,SHOP_SETTING_SHOW_SHOP_LOGO_IN_APP,SHOP_SETTING_SHOW_SHOP_LOGO_IN_WEB,SHOP_SETTING_PRODUCTS_SORT_ORDER,SHOP_SETTING_COOKIE_CONSENT_MODE,SHOP_SETTING_DISPLAY_PRICE_PER_MEASURE_UNIT,SHOP_SETTING_IMAGES,SHOP_SETTING_IMAGES_PRODUCT_PLACEHOLDER,SHOP_SETTING_IMAGES_CATEGORY_PLACEHOLDER,SHOP_SETTING_IMAGES_FAVICON,SHOP_SETTING_NUMBER_OF_ADDRESS_LINES,SHOP_SETTING_REGISTRATION_MODE_SIMPLE,SHOP_SETTING_REGISTRATION_MODE_EXTENDED,SHOP_SETTING_WISHLIST_ITEM_QUANTITY_ENABLED,SHOP_SETTING_WISHLIST_ITEM_NOTES_ENABLED,SHOP_SETTING_LOAD_WISHLIST_ON_APP_START_ENABLED,SHOP_SETTING_SHOW_WISHLIST_ITEMS_COUNT_BADGE}from"./shopSettings";export{RECEIVE_MERCHANT_SETTINGS,MERCHANT_SETTINGS_LOCATION_BASED_SHOPPING_ENABLED,MERCHANT_SETTINGS_SUBSTITUTION_PREFERENCES_ENABLED,MERCHANT_SETTINGS_CUSTOMER_ATTRIBUTES,MERCHANT_SETTINGS_FULFILLMENT_SCHEDULED_ENABLED,MERCHANT_SETTINGS_RESTRICT_MULTI_LOCATION_ORDERS,MERCHANT_SETTINGS_DEFAULT_CURRENCY,MERCHANT_SETTINGS_ENABLE_WEB_INDEXING,MERCHANT_SETTINGS_PRODUCT_SHOW_ALTERNATIVE_LOCATION,MERCHANT_SETTINGS_PRODUCTLIST_SHOW_INVENTORY}from"./merchantSettings";export{SHOPGATE_CORE_GET_SHOP_SETTINGS,EUNAUTHORIZED,EAUTHENTICATION}from"./pipelines";export*from"./actionTypes";export*from"./appFeatures";export*from"./deviceTypes";export*from"./geolocationRequest";export*from"./optIns";// Core Constants
|
|
2
2
|
export*from'@shopgate/pwa-core/constants/ErrorManager';export*from'@shopgate/pwa-core/constants/AppEvents';export*from'@shopgate/pwa-core/constants/AppPermissions';export*from'@shopgate/pwa-core/constants/ErrorHandleTypes';export*from'@shopgate/pwa-core/constants/Pipeline';export*from'@shopgate/pwa-core/constants/ProcessTypes';export*from'@shopgate/pwa-core/constants/Scanner';export*from'@shopgate/pwa-core/constants/Trilean';// Common Constants
|
|
3
3
|
export*from'@shopgate/pwa-common/constants/ActionTypes';export*from'@shopgate/pwa-common/constants/Configuration';export*from'@shopgate/pwa-common/constants/Device';export*from'@shopgate/pwa-common/constants/DisplayOptions';export*from'@shopgate/pwa-common/constants/Pipelines';export*from'@shopgate/pwa-common/constants/Portals';// CLIENT CONSTANTS
|
|
4
4
|
export*from'@shopgate/pwa-common/constants/client';// MENU CONSTANTS
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var SOFT_OPT_IN_SHOWN='SOFT_OPT_IN_SHOWN';export var SOFT_OPT_IN_SELECTED='SOFT_OPT_IN_SELECTED';export var HARD_OPT_IN_SHOWN='HARD_OPT_IN_SHOWN';export var HARD_OPT_IN_SELECTED='HARD_OPT_IN_SELECTED';
|
package/core/streams/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export*from"./app";export*from"./appPermissions";export*from'@shopgate/pwa-common/streams/main';export*from'@shopgate/pwa-common/streams/error';export*from'@shopgate/pwa-common/streams/view';// --------------- APP --------------- //
|
|
1
|
+
export*from"./app";export*from"./appPermissions";export*from"./optIns";export*from'@shopgate/pwa-common/streams/main';export*from'@shopgate/pwa-common/streams/error';export*from'@shopgate/pwa-common/streams/view';// --------------- APP --------------- //
|
|
2
2
|
export*from'@shopgate/pwa-common/streams/app';// --------------- CLIENT --------------- //
|
|
3
3
|
export*from'@shopgate/pwa-common/streams/client';// --------------- ROUTER --------------- //
|
|
4
4
|
export*from'@shopgate/pwa-common/streams/router';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{main$}from'@shopgate/pwa-common/streams/main';import{SOFT_OPT_IN_SHOWN,SOFT_OPT_IN_SELECTED,HARD_OPT_IN_SHOWN,HARD_OPT_IN_SELECTED}from"../constants";/**
|
|
2
|
+
* Gets triggered when a SOFT_OPT_IN_SHOWN action was dispatched
|
|
3
|
+
* @type {Observable}
|
|
4
|
+
*/export var softOptInShown$=main$.filter(function(_ref){var action=_ref.action;return action.type===SOFT_OPT_IN_SHOWN;});/**
|
|
5
|
+
* Gets triggered when a SOFT_OPT_IN_SELECTED action was dispatched
|
|
6
|
+
* @type {Observable}
|
|
7
|
+
*/export var softOptInSelected$=main$.filter(function(_ref2){var action=_ref2.action;return action.type===SOFT_OPT_IN_SELECTED;});/**
|
|
8
|
+
* Gets triggered when a HARD_OPT_IN_SHOWN action was dispatched
|
|
9
|
+
* @type {Observable}
|
|
10
|
+
*/export var hardOptInShown$=main$.filter(function(_ref3){var action=_ref3.action;return action.type===HARD_OPT_IN_SHOWN;});/**
|
|
11
|
+
* Gets triggered when a HARD_OPT_IN_SELECTED action was dispatched
|
|
12
|
+
* @type {Observable}
|
|
13
|
+
*/export var hardOptInSelected$=main$.filter(function(_ref4){var action=_ref4.action;return action.type===HARD_OPT_IN_SELECTED;});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/engage",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.21.0-beta.2",
|
|
4
4
|
"description": "Shopgate's ENGAGE library.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Shopgate <support@shopgate.com>",
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@shopgate/native-modules": "1.0.0-beta.18",
|
|
19
|
-
"@shopgate/pwa-common": "7.
|
|
20
|
-
"@shopgate/pwa-common-commerce": "7.
|
|
21
|
-
"@shopgate/pwa-core": "7.
|
|
22
|
-
"@shopgate/pwa-ui-ios": "7.
|
|
23
|
-
"@shopgate/pwa-ui-material": "7.
|
|
24
|
-
"@shopgate/pwa-ui-shared": "7.
|
|
19
|
+
"@shopgate/pwa-common": "7.21.0-beta.2",
|
|
20
|
+
"@shopgate/pwa-common-commerce": "7.21.0-beta.2",
|
|
21
|
+
"@shopgate/pwa-core": "7.21.0-beta.2",
|
|
22
|
+
"@shopgate/pwa-ui-ios": "7.21.0-beta.2",
|
|
23
|
+
"@shopgate/pwa-ui-material": "7.21.0-beta.2",
|
|
24
|
+
"@shopgate/pwa-ui-shared": "7.21.0-beta.2",
|
|
25
25
|
"@stripe/react-stripe-js": "^1.1.2",
|
|
26
26
|
"@stripe/stripe-js": "^1.3.1",
|
|
27
27
|
"@virtuous/conductor": "~2.5.0",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import{HIDE_PUSH_OPT_IN_MODAL,SHOW_PUSH_OPT_IN_MODAL}from"../constants";/**
|
|
2
2
|
* action to be dispatched when the push opt-in should be shown
|
|
3
|
+
* @param {"appStarts"|"ordersPlaced"} triggerType Trigger type that caused showing the modal
|
|
3
4
|
* @returns {Function}
|
|
4
|
-
*/export var showPushOptInModal=function showPushOptInModal(){return{type:SHOW_PUSH_OPT_IN_MODAL};};/**
|
|
5
|
+
*/export var showPushOptInModal=function showPushOptInModal(triggerType){return{type:SHOW_PUSH_OPT_IN_MODAL,triggerType:triggerType};};/**
|
|
5
6
|
* action to be dispatched when the push opt-in should be hidden
|
|
6
7
|
* @returns {Function}
|
|
7
8
|
*/export var hidePushOptInModal=function hidePushOptInModal(){return{type:HIDE_PUSH_OPT_IN_MODAL};};
|
|
@@ -1,8 +1,8 @@
|
|
|
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{grantPushPermissions}from"../../core";import{hidePushOptInModal,optInPostponed}from"../action-creators";/**
|
|
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{softOptInSelected}from'@shopgate/engage/core/action-creators';import{grantPushPermissions}from"../../core";import{hidePushOptInModal,optInPostponed}from"../action-creators";import{getPushOptInTrackingMeta}from"../selectors";/**
|
|
2
2
|
* action to be dispatched when the user allowed the push opt-in in the modal
|
|
3
3
|
* and native modal should be triggered for setting the permission
|
|
4
4
|
* @returns {Function}
|
|
5
|
-
*/export var allowPushOptIn=function allowPushOptIn(){return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.next=
|
|
5
|
+
*/export var allowPushOptIn=function allowPushOptIn(){return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch,getState){var meta;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:meta=getPushOptInTrackingMeta(getState());dispatch(softOptInSelected({selection:'approved',meta:meta}));_context.next=4;return dispatch(grantPushPermissions({useSettingsModal:true,meta:meta}));case 4:dispatch(hidePushOptInModal());case 5:case"end":return _context.stop();}},_callee);}));return function(_x,_x2){return _ref.apply(this,arguments);};}());};/**
|
|
6
6
|
* action to be dispatched when the user denied the push opt-in in the modal
|
|
7
7
|
* @returns {Function}
|
|
8
|
-
*/export var denyPushOptIn=function denyPushOptIn(){return(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(dispatch){return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:_context2.next=
|
|
8
|
+
*/export var denyPushOptIn=function denyPushOptIn(){return(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(dispatch,getState){var meta;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:meta=getPushOptInTrackingMeta(getState());dispatch(softOptInSelected({selection:'later',meta:meta}));_context2.next=4;return dispatch(optInPostponed());case 4:dispatch(hidePushOptInModal());case 5:case"end":return _context2.stop();}},_callee2);}));return function(_x3,_x4){return _ref2.apply(this,arguments);};}());};
|
|
@@ -1,6 +1,6 @@
|
|
|
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{HIDE_PUSH_OPT_IN_MODAL,SHOW_PUSH_OPT_IN_MODAL}from"../constants";var defaultState={isPushOptInModalVisible:false};/**
|
|
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{HIDE_PUSH_OPT_IN_MODAL,SHOW_PUSH_OPT_IN_MODAL}from"../constants";var defaultState={triggerType:null,isPushOptInModalVisible:false};/**
|
|
2
2
|
* Stores all the states related to the push Opt-In Modal functionality.
|
|
3
3
|
* @param {Object} [state] The current state.
|
|
4
4
|
* @param {Object} action The action object.
|
|
5
5
|
* @return {Object} The new state.
|
|
6
|
-
*/var pushOptInModalReducer=function pushOptInModalReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:defaultState;var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case SHOW_PUSH_OPT_IN_MODAL:{return _extends({},state,{isPushOptInModalVisible:true});}case HIDE_PUSH_OPT_IN_MODAL:{return _extends({},state,{isPushOptInModalVisible:false});}default:return state;}};export default pushOptInModalReducer;
|
|
6
|
+
*/var pushOptInModalReducer=function pushOptInModalReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:defaultState;var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case SHOW_PUSH_OPT_IN_MODAL:{return _extends({},state,{triggerType:action.triggerType,isPushOptInModalVisible:true});}case HIDE_PUSH_OPT_IN_MODAL:{return _extends({},state,{triggerType:null,isPushOptInModalVisible:false});}default:return state;}};export default pushOptInModalReducer;
|
|
@@ -1,6 +1,6 @@
|
|
|
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{PUSH_OPT_IN_INCREASE_APP_START_COUNT,PUSH_OPT_IN_RESET_APP_START_STATE,PUSH_OPT_IN_RESET_APP_START_COUNT,PUSH_OPT_IN_INCREASE_ORDERS_PLACED_COUNT,PUSH_OPT_IN_RESET_ORDERS_PLACED_COUNT,PUSH_OPT_IN_RESET_ORDERS_PLACED_STATE,PUSH_OPT_IN_SET_LAST_POPUP_TIMESTAMP,PUSH_OPT_IN_INCREASE_REJECTION_COUNT}from"../constants";var defaultState={appStartCount:0,appStartResetCount:0,ordersPlacedCount:0,ordersPlacedResetCount:0,lastPopupAt:null,rejectionCount:0};/**
|
|
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{PUSH_OPT_IN_INCREASE_APP_START_COUNT,PUSH_OPT_IN_RESET_APP_START_STATE,PUSH_OPT_IN_RESET_APP_START_COUNT,PUSH_OPT_IN_INCREASE_ORDERS_PLACED_COUNT,PUSH_OPT_IN_RESET_ORDERS_PLACED_COUNT,PUSH_OPT_IN_RESET_ORDERS_PLACED_STATE,PUSH_OPT_IN_SET_LAST_POPUP_TIMESTAMP,PUSH_OPT_IN_INCREASE_REJECTION_COUNT}from"../constants";var defaultState={appStartCount:0,appStartCountAbs:0,appStartResetCount:0,ordersPlacedCount:0,ordersPlacedCountAbs:0,ordersPlacedResetCount:0,lastPopupAt:null,rejectionCount:0};/**
|
|
2
2
|
* Stores all the states related to the pushOptInTrigger functionality.
|
|
3
3
|
* @param {Object} [state] The current state.
|
|
4
4
|
* @param {Object} action The action object.
|
|
5
5
|
* @return {Object} The new state.
|
|
6
|
-
*/var pushOptInReducer=function pushOptInReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:defaultState;var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case PUSH_OPT_IN_INCREASE_APP_START_COUNT:{return _extends({},state,{appStartCount:state.appStartCount+1});}case PUSH_OPT_IN_RESET_APP_START_COUNT:{return _extends({},state,{appStartCount:0,appStartResetCount:state.appStartResetCount+1});}case PUSH_OPT_IN_RESET_APP_START_STATE:{return _extends({},state,{appStartCount:0,appStartResetCount:0});}case PUSH_OPT_IN_INCREASE_ORDERS_PLACED_COUNT:{return _extends({},state,{ordersPlacedCount:state.ordersPlacedCount+1});}case PUSH_OPT_IN_RESET_ORDERS_PLACED_COUNT:{return _extends({},state,{ordersPlacedCount:0,ordersPlacedResetCount:state.ordersPlacedResetCount+1});}case PUSH_OPT_IN_RESET_ORDERS_PLACED_STATE:{return _extends({},state,{ordersPlacedCount:0,ordersPlacedResetCount:0});}case PUSH_OPT_IN_SET_LAST_POPUP_TIMESTAMP:{return _extends({},state,{lastPopupAt:Date.now()});}case PUSH_OPT_IN_INCREASE_REJECTION_COUNT:{return _extends({},state,{rejectionCount:state.rejectionCount+1});}default:return state;}};export default pushOptInReducer;
|
|
6
|
+
*/var pushOptInReducer=function pushOptInReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:defaultState;var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case PUSH_OPT_IN_INCREASE_APP_START_COUNT:{return _extends({},state,{appStartCount:state.appStartCount+1,appStartCountAbs:state.appStartCountAbs+1});}case PUSH_OPT_IN_RESET_APP_START_COUNT:{return _extends({},state,{appStartCount:0,appStartResetCount:state.appStartResetCount+1});}case PUSH_OPT_IN_RESET_APP_START_STATE:{return _extends({},state,{appStartCount:0,appStartResetCount:0});}case PUSH_OPT_IN_INCREASE_ORDERS_PLACED_COUNT:{return _extends({},state,{ordersPlacedCount:state.ordersPlacedCount+1,ordersPlacedCountAbs:state.ordersPlacedCountAbs+1});}case PUSH_OPT_IN_RESET_ORDERS_PLACED_COUNT:{return _extends({},state,{ordersPlacedCount:0,ordersPlacedResetCount:state.ordersPlacedResetCount+1});}case PUSH_OPT_IN_RESET_ORDERS_PLACED_STATE:{return _extends({},state,{ordersPlacedCount:0,ordersPlacedResetCount:0});}case PUSH_OPT_IN_SET_LAST_POPUP_TIMESTAMP:{return _extends({},state,{lastPopupAt:new Date(Date.now()).toISOString()});}case PUSH_OPT_IN_INCREASE_REJECTION_COUNT:{return _extends({},state,{rejectionCount:state.rejectionCount+1});}default:return state;}};export default pushOptInReducer;
|
|
@@ -3,6 +3,9 @@ import{createSelector}from'reselect';/**
|
|
|
3
3
|
* @param {Object} state The current state of the push opt-in modal.
|
|
4
4
|
* @returns {Object} whether push opt-in modal is shown.
|
|
5
5
|
*/export var getPushOptInModalState=function getPushOptInModalState(state){var _state$pushOptIn;return(state===null||state===void 0?void 0:(_state$pushOptIn=state.pushOptIn)===null||_state$pushOptIn===void 0?void 0:_state$pushOptIn.optInModal)||{};};/**
|
|
6
|
-
*
|
|
6
|
+
* Determines visibility of the Push-Opt-In Modal
|
|
7
7
|
* @returns {boolean} whether push opt-in modal is shown.
|
|
8
|
-
*/export var getIsPushOptInModalVisible=createSelector(getPushOptInModalState,function(modalState){return modalState.isPushOptInModalVisible||false;})
|
|
8
|
+
*/export var getIsPushOptInModalVisible=createSelector(getPushOptInModalState,function(modalState){return modalState.isPushOptInModalVisible||false;});/**
|
|
9
|
+
* Determines the trigger type of the Push-Opt-In Modal
|
|
10
|
+
* @returns {string} whether push opt-in modal is shown.
|
|
11
|
+
*/export var getPushOptInModalTriggerType=createSelector(getPushOptInModalState,function(modalState){return modalState.triggerType;});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import{createSelector}from'reselect';import{appSupportsPushOptIn}from'@shopgate/engage/core/helpers';import{appConfig}from'@shopgate/engage';import{getPushOptInModalTriggerType}from"./optInModal";/**
|
|
2
2
|
* Selects the push opt in information.
|
|
3
3
|
* @param {Object} state The current state.
|
|
4
4
|
* @returns {Object} The push opt in information.
|
|
5
|
-
*/export var getPushOptInTriggerState=function getPushOptInTriggerState(state){var _state$pushOptIn;return(state===null||state===void 0?void 0:(_state$pushOptIn=state.pushOptIn)===null||_state$pushOptIn===void 0?void 0:_state$pushOptIn.optInTrigger)||{};}
|
|
5
|
+
*/export var getPushOptInTriggerState=function getPushOptInTriggerState(state){var _state$pushOptIn;return(state===null||state===void 0?void 0:(_state$pushOptIn=state.pushOptIn)===null||_state$pushOptIn===void 0?void 0:_state$pushOptIn.optInTrigger)||{};};/**
|
|
6
|
+
* Creates a meta data object for push opt in tracking events
|
|
7
|
+
*/export var getPushOptInTrackingMeta=createSelector(getPushOptInModalTriggerType,getPushOptInTriggerState,function(triggerType,triggerState){var _appConfig$pushOptIn=appConfig.pushOptIn,_appConfig$pushOptIn2=_appConfig$pushOptIn===void 0?{}:_appConfig$pushOptIn,_appConfig$pushOptIn3=_appConfig$pushOptIn2.appStarts,_appConfig$pushOptIn4=_appConfig$pushOptIn3===void 0?{}:_appConfig$pushOptIn3,_appConfig$pushOptIn5=_appConfig$pushOptIn4.value,appStartsVal=_appConfig$pushOptIn5===void 0?0:_appConfig$pushOptIn5,_appConfig$pushOptIn6=_appConfig$pushOptIn2.ordersPlaced,_appConfig$pushOptIn7=_appConfig$pushOptIn6===void 0?{}:_appConfig$pushOptIn6,_appConfig$pushOptIn8=_appConfig$pushOptIn7.value,ordersPlacedVal=_appConfig$pushOptIn8===void 0?0:_appConfig$pushOptIn8;var usesSoftPushOptIn=appSupportsPushOptIn()&&(appStartsVal>0||ordersPlacedVal>0);if(triggerType==='ordersPlaced'){return{permission:'push',context:'checkoutSuccess',contextCounter:triggerState.ordersPlacedCountAbs,usesSoftPushOptIn:usesSoftPushOptIn};}return{permission:'push',context:'appStart',contextCounter:triggerState.appStartCountAbs,usesSoftPushOptIn:usesSoftPushOptIn};});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import optInTrigger from"./optInTrigger";export default(function(subscribe){optInTrigger(subscribe);});
|
|
1
|
+
import optInTrigger from"./optInTrigger";import optInTracking from"./optInTracking";export default(function(subscribe){optInTrigger(subscribe);optInTracking(subscribe);});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var _excluded=["permission"],_excluded2=["permission"],_excluded3=["permission"],_excluded4=["permission"];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{softOptInShown$,softOptInSelected$,hardOptInShown$,hardOptInSelected$}from'@shopgate/engage/core/streams';import{track}from'@shopgate/engage/tracking/helpers';var softPushOptInShown$=softOptInShown$.filter(function(_ref){var _action$meta;var action=_ref.action;return(action===null||action===void 0?void 0:(_action$meta=action.meta)===null||_action$meta===void 0?void 0:_action$meta.permission)==='push';});var softPushOptInSelected$=softOptInSelected$.filter(function(_ref2){var _action$meta2;var action=_ref2.action;return(action===null||action===void 0?void 0:(_action$meta2=action.meta)===null||_action$meta2===void 0?void 0:_action$meta2.permission)==='push';});var hardPushOptInShown$=hardOptInShown$.filter(function(_ref3){var _action$meta3;var action=_ref3.action;return(action===null||action===void 0?void 0:(_action$meta3=action.meta)===null||_action$meta3===void 0?void 0:_action$meta3.permission)==='push';});var hardPushOptInSelected$=hardOptInSelected$.filter(function(_ref4){var _action$meta4;var action=_ref4.action;return(action===null||action===void 0?void 0:(_action$meta4=action.meta)===null||_action$meta4===void 0?void 0:_action$meta4.permission)==='push';});/**
|
|
2
|
+
* Push opt in tracking subscriptions
|
|
3
|
+
* @param {Function} subscribe The subscribe function
|
|
4
|
+
*/export default function pushOptInTracking(subscribe){subscribe(softPushOptInShown$,function(_ref5){var action=_ref5.action,getState=_ref5.getState;var _action$meta5=action.meta,permission=_action$meta5.permission,meta=_objectWithoutProperties(_action$meta5,_excluded);track('customEvent',{eventCategory:'softPushOptIn',eventAction:'shown',eventLabel:null,additionalEventParams:_extends({eventName:'softPushOptInShown'},meta)},getState());});subscribe(softPushOptInSelected$,function(_ref6){var action=_ref6.action,getState=_ref6.getState;var selection=action.selection,_action$meta6=action.meta,permission=_action$meta6.permission,meta=_objectWithoutProperties(_action$meta6,_excluded2);track('customEvent',{eventCategory:'softPushOptIn',eventAction:'decision',eventLabel:selection,additionalEventParams:_extends({eventName:'softPushOptInSelected',selection:selection},meta)},getState());});subscribe(hardPushOptInShown$,function(_ref7){var action=_ref7.action,getState=_ref7.getState;var _action$meta7=action.meta,permission=_action$meta7.permission,meta=_objectWithoutProperties(_action$meta7,_excluded3);track('customEvent',{eventCategory:'hardPushOptIn',eventAction:'shown',eventLabel:null,additionalEventParams:_extends({eventName:'hardPushOptInShown'},meta)},getState());});subscribe(hardPushOptInSelected$,function(_ref8){var action=_ref8.action,getState=_ref8.getState;var selection=action.selection,_action$meta8=action.meta,permission=_action$meta8.permission,meta=_objectWithoutProperties(_action$meta8,_excluded4);track('customEvent',{eventCategory:'hardPushOptIn',eventAction:'decision',eventLabel:selection,additionalEventParams:_extends({eventName:'hardPushOptInSelected',selection:selection},meta)},getState());});}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _regeneratorRuntime from"@babel/runtime/regenerator";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 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{appConfig}from'@shopgate/engage';import{main$}from'@shopgate/engage/core/streams';import{event}from'@shopgate/engage/core/classes';import{appSupportsPushOptIn,logger}from'@shopgate/engage/core/helpers';import{PERMISSION_ID_PUSH,PERMISSION_STATUS_NOT_DETERMINED}from'@shopgate/engage/core/constants';import{requestAppPermissionStatus}from'@shopgate/engage/core/actions';import{cookieConsentInitialized$}from'@shopgate/engage/tracking/streams';import{increaseAppStartCount,resetAppStartCount,increaseOrdersPlacedCount,resetOrdersPlacedCount,setLastPopupTimestamp,increaseRejectionCount,showPushOptInModal}from"../action-creators";import{PUSH_OPT_IN_OPT_IN_POSTPONED}from"../constants";import{getPushOptInTriggerState}from"../selectors";var DAY_IN_MS=1000*60*60*24;var increaseRejectionCount$=main$.filter(function(_ref){var action=_ref.action;return action.type===PUSH_OPT_IN_OPT_IN_POSTPONED;});/**
|
|
1
|
+
import _regeneratorRuntime from"@babel/runtime/regenerator";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 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{appConfig}from'@shopgate/engage';import{main$}from'@shopgate/engage/core/streams';import{event}from'@shopgate/engage/core/classes';import{appSupportsPushOptIn,logger}from'@shopgate/engage/core/helpers';import{PERMISSION_ID_PUSH,PERMISSION_STATUS_NOT_DETERMINED}from'@shopgate/engage/core/constants';import{softOptInShown}from'@shopgate/engage/core/action-creators';import{requestAppPermissionStatus}from'@shopgate/engage/core/actions';import{cookieConsentInitialized$}from'@shopgate/engage/tracking/streams';import{increaseAppStartCount,resetAppStartCount,increaseOrdersPlacedCount,resetOrdersPlacedCount,setLastPopupTimestamp,increaseRejectionCount,showPushOptInModal}from"../action-creators";import{PUSH_OPT_IN_OPT_IN_POSTPONED}from"../constants";import{getPushOptInTriggerState,getPushOptInTrackingMeta}from"../selectors";var DAY_IN_MS=1000*60*60*24;var increaseRejectionCount$=main$.filter(function(_ref){var action=_ref.action;return action.type===PUSH_OPT_IN_OPT_IN_POSTPONED;});/**
|
|
2
2
|
* Push opt in subscriptions
|
|
3
3
|
* @param {Function} subscribe The subscribe function
|
|
4
4
|
*/export default function pushOptIn(subscribe){/**
|
|
@@ -6,7 +6,7 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function _typeof(obj
|
|
|
6
6
|
* @param {string} configKey The "pushOptIn" key to be used
|
|
7
7
|
* @param {Function} increaseCountAction Action to increase the count in Redux for the configKey
|
|
8
8
|
* @returns {void}
|
|
9
|
-
*/var showOptInAfterChecks=/*#__PURE__*/function(){var _ref3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref2,configKey,increaseCountAction){var dispatch,getState,_appConfig$pushOptIn,_appConfig$pushOptIn2,appStarts,ordersPlaced,rejectionMaxCount,minDaysBetweenOptIns,_ref4,pushStatus,state,configValue,resetAction,resetCountState,configCountState,mustShowModal,hasRepeats,minDaysElapsed;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:dispatch=_ref2.dispatch,getState=_ref2.getState;if(appSupportsPushOptIn()){_context.next=3;break;}return _context.abrupt("return");case 3:_appConfig$pushOptIn=appConfig.pushOptIn,_appConfig$pushOptIn2=_appConfig$pushOptIn===void 0?{}:_appConfig$pushOptIn,appStarts=_appConfig$pushOptIn2.appStarts,ordersPlaced=_appConfig$pushOptIn2.ordersPlaced,rejectionMaxCount=_appConfig$pushOptIn2.rejectionMaxCount,minDaysBetweenOptIns=_appConfig$pushOptIn2.minDaysBetweenOptIns;// Deactivate feature when config is invalid
|
|
10
|
-
if(!(typeof minDaysBetweenOptIns!=='number'||typeof rejectionMaxCount!=='number'||_typeof(ordersPlaced)!=='object'||_typeof(appStarts)!=='object')){_context.next=7;break;}logger.error('PushOptInTrigger - Config invalid',appConfig===null||appConfig===void 0?void 0:appConfig.pushOptIn);return _context.abrupt("return");case 7:_context.next=9;return dispatch(requestAppPermissionStatus({permissionId:PERMISSION_ID_PUSH}));case 9:_ref4=_context.sent;pushStatus=_ref4.status;if(!(pushStatus!==PERMISSION_STATUS_NOT_DETERMINED)){_context.next=13;break;}return _context.abrupt("return");case 13:dispatch(increaseCountAction());state=getPushOptInTriggerState(getState());configValue=appStarts;resetAction=resetAppStartCount;resetCountState=state.appStartResetCount;configCountState=state.appStartCount;if(configKey==='ordersPlaced'){configValue=ordersPlaced;resetAction=resetOrdersPlacedCount;resetCountState=state.ordersPlacedResetCount;configCountState=state.ordersPlacedCount;}if(!(state.rejectionCount>=rejectionMaxCount)){_context.next=22;break;}return _context.abrupt("return");case 22:mustShowModal=Number(configValue.value)>0&&configCountState>=configValue.value;hasRepeats=configValue.repeats===null||resetCountState<=configValue.repeats;minDaysElapsed=Date.now()-state.lastPopupAt>=minDaysBetweenOptIns*DAY_IN_MS;if(mustShowModal&&hasRepeats&&minDaysElapsed){dispatch(setLastPopupTimestamp());dispatch(resetAction());dispatch(showPushOptInModal());}case 26:case"end":return _context.stop();}},_callee);}));return function showOptInAfterChecks(_x,_x2,_x3){return _ref3.apply(this,arguments);};}();// event subscriber to handle app start based push opt in
|
|
9
|
+
*/var showOptInAfterChecks=/*#__PURE__*/function(){var _ref3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref2,configKey,increaseCountAction){var dispatch,getState,_appConfig$pushOptIn,_appConfig$pushOptIn2,appStarts,ordersPlaced,rejectionMaxCount,minDaysBetweenOptIns,_ref4,pushStatus,state,configValue,resetAction,resetCountState,configCountState,mustShowModal,hasRepeats,minDaysElapsed,meta;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:dispatch=_ref2.dispatch,getState=_ref2.getState;if(appSupportsPushOptIn()){_context.next=3;break;}return _context.abrupt("return");case 3:_appConfig$pushOptIn=appConfig.pushOptIn,_appConfig$pushOptIn2=_appConfig$pushOptIn===void 0?{}:_appConfig$pushOptIn,appStarts=_appConfig$pushOptIn2.appStarts,ordersPlaced=_appConfig$pushOptIn2.ordersPlaced,rejectionMaxCount=_appConfig$pushOptIn2.rejectionMaxCount,minDaysBetweenOptIns=_appConfig$pushOptIn2.minDaysBetweenOptIns;// Deactivate feature when config is invalid
|
|
10
|
+
if(!(typeof minDaysBetweenOptIns!=='number'||typeof rejectionMaxCount!=='number'||_typeof(ordersPlaced)!=='object'||_typeof(appStarts)!=='object')){_context.next=7;break;}logger.error('PushOptInTrigger - Config invalid',appConfig===null||appConfig===void 0?void 0:appConfig.pushOptIn);return _context.abrupt("return");case 7:_context.next=9;return dispatch(requestAppPermissionStatus({permissionId:PERMISSION_ID_PUSH}));case 9:_ref4=_context.sent;pushStatus=_ref4.status;if(!(pushStatus!==PERMISSION_STATUS_NOT_DETERMINED)){_context.next=13;break;}return _context.abrupt("return");case 13:dispatch(increaseCountAction());state=getPushOptInTriggerState(getState());configValue=appStarts;resetAction=resetAppStartCount;resetCountState=state.appStartResetCount;configCountState=state.appStartCount;if(configKey==='ordersPlaced'){configValue=ordersPlaced;resetAction=resetOrdersPlacedCount;resetCountState=state.ordersPlacedResetCount;configCountState=state.ordersPlacedCount;}if(!(state.rejectionCount>=rejectionMaxCount)){_context.next=22;break;}return _context.abrupt("return");case 22:mustShowModal=Number(configValue.value)>0&&configCountState>=configValue.value;hasRepeats=configValue.repeats===null||resetCountState<=configValue.repeats;minDaysElapsed=Date.now()-new Date(state.lastPopupAt)>=minDaysBetweenOptIns*DAY_IN_MS;if(mustShowModal&&hasRepeats&&minDaysElapsed){meta=getPushOptInTrackingMeta(getState());dispatch(softOptInShown({meta:meta}));dispatch(setLastPopupTimestamp());dispatch(resetAction());dispatch(showPushOptInModal(configKey));}case 26:case"end":return _context.stop();}},_callee);}));return function showOptInAfterChecks(_x,_x2,_x3){return _ref3.apply(this,arguments);};}();// event subscriber to handle app start based push opt in
|
|
11
11
|
subscribe(cookieConsentInitialized$,/*#__PURE__*/function(){var _ref6=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref5){var dispatch,getState;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:dispatch=_ref5.dispatch,getState=_ref5.getState;_context2.next=3;return showOptInAfterChecks({dispatch:dispatch,getState:getState},'appStarts',increaseAppStartCount);case 3:case"end":return _context2.stop();}},_callee2);}));return function(_x4){return _ref6.apply(this,arguments);};}());// event subscriber to handle order based push opt in
|
|
12
12
|
subscribe(cookieConsentInitialized$,function(_ref7){var dispatch=_ref7.dispatch,getState=_ref7.getState;event.addCallback('checkoutSuccess',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(){return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:_context3.next=2;return showOptInAfterChecks({dispatch:dispatch,getState:getState},'ordersPlaced',increaseOrdersPlacedCount);case 2:case"end":return _context3.stop();}},_callee3);})));});subscribe(increaseRejectionCount$,function(_ref9){var dispatch=_ref9.dispatch;dispatch(increaseRejectionCount());});}
|
|
@@ -1,8 +1,20 @@
|
|
|
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{historyPush,grantAppTrackingTransparencyPermission}from'@shopgate/engage/core/actions';import{updateCookieConsent,hideCookieConsentModal}from"../action-creators";import{PRIVACY_SETTINGS_PATTERN}from"../constants";/**
|
|
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{historyPush,grantAppTrackingTransparencyPermission}from'@shopgate/engage/core/actions';import{softOptInSelected}from'@shopgate/engage/core/action-creators';import{updateCookieConsent,hideCookieConsentModal}from"../action-creators";import{PRIVACY_SETTINGS_PATTERN}from"../constants";import{getCookieConsentTrackingMeta,getIsCookieConsentModalVisible,getIsCookieConsentHandled}from"../selectors/cookieConsent";/**
|
|
2
|
+
* Broadcasts updates of the cookie consent states and dispatches related tracking events.
|
|
3
|
+
* @param {Object} update Updated cookie consent states
|
|
4
|
+
* @param {boolean} update.comfortCookiesAccepted Whether comfort cookies
|
|
5
|
+
* are accepted.
|
|
6
|
+
* @param {boolean} update.statisticsCookiesAccepted Whether statistics cookies
|
|
7
|
+
* are accepted.
|
|
8
|
+
* @returns {Function}
|
|
9
|
+
*/var updateCookieConsentLocal=function updateCookieConsentLocal(update){return function(dispatch,getState){var comfortCookiesAccepted=update.comfortCookiesAccepted,statisticsCookiesAccepted=update.statisticsCookiesAccepted;var state=getState();// Whether the update was triggered by a button from within the modal
|
|
10
|
+
var updateFromModal=getIsCookieConsentModalVisible(state);// Whether the cookie consent was already handled when the update came in
|
|
11
|
+
var cookieConsentHandled=getIsCookieConsentHandled(state);if(!cookieConsentHandled){// Prepare tracking events when cookie consent wasn't handled yet
|
|
12
|
+
var meta=getCookieConsentTrackingMeta(state,{allowComfort:comfortCookiesAccepted,allowStatistics:statisticsCookiesAccepted});var selection='manage';if(updateFromModal){selection=comfortCookiesAccepted&&statisticsCookiesAccepted?'approvedAll':'deniedAll';}dispatch(softOptInSelected({selection:selection,meta:meta}));}// Broadcast the actual state update
|
|
13
|
+
dispatch(updateCookieConsent(update));};};/**
|
|
2
14
|
* action to be dispatched when the user accepted all cookies in the custom modal
|
|
3
15
|
* and native modal should be triggered for setting the permission
|
|
4
16
|
* @returns {Function}
|
|
5
|
-
*/export var acceptAllCookies=function acceptAllCookies(){return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.next=
|
|
17
|
+
*/export var acceptAllCookies=function acceptAllCookies(){return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch,getState){var meta;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:meta=getCookieConsentTrackingMeta(getState());_context.next=3;return dispatch(grantAppTrackingTransparencyPermission({meta:meta}));case 3:dispatch(updateCookieConsentLocal({comfortCookiesAccepted:true,statisticsCookiesAccepted:true}));dispatch(hideCookieConsentModal());case 5:case"end":return _context.stop();}},_callee);}));return function(_x,_x2){return _ref.apply(this,arguments);};}());};/**
|
|
6
18
|
* action to be dispatched when the user accepted the selected cookies in the custom modal
|
|
7
19
|
* and native modal should be triggered for setting the permission
|
|
8
20
|
* @param {Object} params Action params
|
|
@@ -11,11 +23,11 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGenera
|
|
|
11
23
|
* @param {boolean|null} params.statisticsCookiesAccepted whether this cookie type was accepted
|
|
12
24
|
* by user
|
|
13
25
|
* @returns {Function}
|
|
14
|
-
*/export var acceptSelectedCookies=function acceptSelectedCookies(_ref2){var comfortCookiesAccepted=_ref2.comfortCookiesAccepted,statisticsCookiesAccepted=_ref2.statisticsCookiesAccepted;return(/*#__PURE__*/function(){var _ref3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(dispatch){return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:if(!(comfortCookiesAccepted||statisticsCookiesAccepted)){_context2.next=
|
|
26
|
+
*/export var acceptSelectedCookies=function acceptSelectedCookies(_ref2){var comfortCookiesAccepted=_ref2.comfortCookiesAccepted,statisticsCookiesAccepted=_ref2.statisticsCookiesAccepted;return(/*#__PURE__*/function(){var _ref3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(dispatch,getState){var meta;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:if(!(comfortCookiesAccepted||statisticsCookiesAccepted)){_context2.next=4;break;}meta=getCookieConsentTrackingMeta(getState());_context2.next=4;return dispatch(grantAppTrackingTransparencyPermission({meta:meta}));case 4:dispatch(updateCookieConsentLocal({comfortCookiesAccepted:comfortCookiesAccepted,statisticsCookiesAccepted:statisticsCookiesAccepted}));dispatch(hideCookieConsentModal());case 6:case"end":return _context2.stop();}},_callee2);}));return function(_x3,_x4){return _ref3.apply(this,arguments);};}());};/**
|
|
15
27
|
* action to be dispatched when the user selected only the required cookies in the custom modal
|
|
16
28
|
* and native modal should be triggered for setting the permission
|
|
17
29
|
* @returns {Function}
|
|
18
|
-
*/export var acceptRequiredCookies=function acceptRequiredCookies(){return function(dispatch){dispatch(
|
|
30
|
+
*/export var acceptRequiredCookies=function acceptRequiredCookies(){return function(dispatch){dispatch(updateCookieConsentLocal({comfortCookiesAccepted:false,statisticsCookiesAccepted:false}));dispatch(hideCookieConsentModal());};};/**
|
|
19
31
|
* action to be dispatched when the user opted to configure cookie settings in the custom modal
|
|
20
32
|
* @returns {Function}
|
|
21
33
|
*/export var openPrivacySettings=function openPrivacySettings(){return function(dispatch){dispatch(historyPush({pathname:PRIVACY_SETTINGS_PATTERN}));};};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{track}from'@shopgate/pwa-tracking/helpers';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createSelector}from'reselect';import{appConfig}from'@shopgate/engage';import{appSupportsCookieConsent}from'@shopgate/engage/core/helpers';var _appConfig$cookieCons=appConfig.cookieConsent,_appConfig$cookieCons2=_appConfig$cookieCons===void 0?{}:_appConfig$cookieCons,isCookieConsentActivated=_appConfig$cookieCons2.isCookieConsentActivated,showComfortCookiesToggle=_appConfig$cookieCons2.showComfortCookiesToggle;/**
|
|
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{appConfig}from'@shopgate/engage';import{appSupportsCookieConsent}from'@shopgate/engage/core/helpers';var _appConfig$cookieCons=appConfig.cookieConsent,_appConfig$cookieCons2=_appConfig$cookieCons===void 0?{}:_appConfig$cookieCons,isCookieConsentActivated=_appConfig$cookieCons2.isCookieConsentActivated,showComfortCookiesToggle=_appConfig$cookieCons2.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.
|
|
@@ -32,4 +32,8 @@ import{createSelector}from'reselect';import{appConfig}from'@shopgate/engage';imp
|
|
|
32
32
|
*/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;});/**
|
|
33
33
|
* Selects the visibility property of the cookie consent modal.
|
|
34
34
|
* @returns {boolean} whether cookie consent modal is shown.
|
|
35
|
-
*/export var getIsCookieConsentModalVisible=createSelector(getCookieConsentModalState,getAreComfortCookiesAcceptedInternal,getAreStatisticsCookiesAcceptedInternal,function(modalState,comfortCookiesState,statisticsCookiesState){return modalState.isCookieConsentModalVisible&&comfortCookiesState===null&&statisticsCookiesState===null;})
|
|
35
|
+
*/export var getIsCookieConsentModalVisible=createSelector(getCookieConsentModalState,getAreComfortCookiesAcceptedInternal,getAreStatisticsCookiesAcceptedInternal,function(modalState,comfortCookiesState,statisticsCookiesState){return modalState.isCookieConsentModalVisible&&comfortCookiesState===null&&statisticsCookiesState===null;});/**
|
|
36
|
+
* Determines if the cookie consent feature is activated
|
|
37
|
+
*/export var getIsCookieConsentActivated=createSelector(function(){return isCookieConsentActivated&&appSupportsCookieConsent();});/**
|
|
38
|
+
* Creates a meta data object for tracking opt in tracking events
|
|
39
|
+
*/export var getCookieConsentTrackingMeta=createSelector(getIsCookieConsentActivated,function(_){var props=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return props;},function(isActivated,states){return _extends({permission:'tracking',usesSoftTrackingOptIn:isActivated},states);});
|
|
@@ -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);}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{main$,routeWillEnter$}from'@shopgate/engage/core/streams';import'rxjs/add/observable/of';import{Observable}from'rxjs/Observable';import{makeGetPrivacyPolicyLink}from'@shopgate/engage/page/selectors';import{COOKIE_CONSENT_HANDLED,UPDATE_COOKIE_CONSENT,PRIVACY_SETTINGS_PATTERN}from"../constants";import{getIsCookieConsentHandled}from"../selectors/cookieConsent";/**
|
|
1
|
+
var _excluded=["type"];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;}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{main$,routeWillEnter$}from'@shopgate/engage/core/streams';import'rxjs/add/observable/of';import{Observable}from'rxjs/Observable';import{makeGetPrivacyPolicyLink}from'@shopgate/engage/page/selectors';import{COOKIE_CONSENT_HANDLED,UPDATE_COOKIE_CONSENT,PRIVACY_SETTINGS_PATTERN}from"../constants";import{getIsCookieConsentHandled}from"../selectors/cookieConsent";/**
|
|
2
2
|
* Gets triggered when the cookie consent has been updated by the user or handled already.
|
|
3
3
|
* This stream is only for internal usage and will be triggered independent of changed payload.
|
|
4
4
|
* @type {Observable}
|
|
@@ -19,7 +19,7 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
|
|
|
19
19
|
*/export var privacySettingsConfirmedWithoutChangeInternal$=cookieConsentSetInternal$.pairwise().filter(function(_ref3){var _ref4=_slicedToArray(_ref3,2),actionPrev=_ref4[0].action,actionCurrent=_ref4[1].action;return actionPrev.comfortCookiesAccepted===actionCurrent.comfortCookiesAccepted&&actionPrev.statisticsCookiesAccepted===actionCurrent.statisticsCookiesAccepted;}).switchMap(function(_ref5){var _ref6=_slicedToArray(_ref5,2),latest=_ref6[1];return Observable.of(latest);});/**
|
|
20
20
|
* Gets triggered when cookie consent settings changed after initialization
|
|
21
21
|
* @type {Observable}
|
|
22
|
-
*/export var cookieConsentUpdated$=cookieConsentSetInternal$.pairwise().filter(function(_ref7){var _ref8=_slicedToArray(_ref7,2),actionPrev=_ref8[0].action,actionCurrent=_ref8[1].action;return actionPrev.comfortCookiesAccepted!==actionCurrent.comfortCookiesAccepted||actionPrev.statisticsCookiesAccepted!==actionCurrent.statisticsCookiesAccepted;}).switchMap(function(_ref9){var _ref10=_slicedToArray(_ref9,2),latest=_ref10[1];return Observable.of(latest);});/**
|
|
22
|
+
*/export var cookieConsentUpdated$=cookieConsentSetInternal$.pairwise().filter(function(_ref7){var _ref8=_slicedToArray(_ref7,2),actionPrev=_ref8[0].action,actionCurrent=_ref8[1].action;return actionPrev.comfortCookiesAccepted!==actionCurrent.comfortCookiesAccepted||actionPrev.statisticsCookiesAccepted!==actionCurrent.statisticsCookiesAccepted;}).switchMap(function(_ref9){var _ref10=_slicedToArray(_ref9,2),previous=_ref10[0],latest=_ref10[1];var _previous$action=previous.action,type=_previous$action.type,prevPayload=_objectWithoutProperties(_previous$action,_excluded);return Observable.of(_extends({},latest,{action:_extends({},latest.action,{previous:prevPayload})}));});/**
|
|
23
23
|
* Gets triggered when the cookie consent has been updated by the user or handled already.
|
|
24
24
|
* @type {Observable}
|
|
25
25
|
*/export var cookieConsentSet$=cookieConsentInitialized$.merge(cookieConsentUpdated$);/**
|
|
@@ -1,11 +1,12 @@
|
|
|
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{reloadApp}from'@shopgate/engage/core/action-creators';import{appSupportsCookieConsent,hasSGJavaScriptBridge}from'@shopgate/engage/core/helpers';import{analyticsSetConsent}from'@shopgate/engage/core/commands';import{cookieConsentInitialized$,cookieConsentUpdated$}from"../streams"
|
|
1
|
+
import _regeneratorRuntime from"@babel/runtime/regenerator";var _excluded=["permission"],_excluded2=["permission"],_excluded3=["permission"];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;}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{softOptInShown$,softOptInSelected$,hardOptInShown$,hardOptInSelected$,routeWillEnter$}from'@shopgate/engage/core/streams';import{getCurrentQuery}from'@shopgate/engage/core/selectors';import{track}from'@shopgate/engage/tracking/helpers';import{reloadApp}from'@shopgate/engage/core/action-creators';import{appSupportsCookieConsent,hasSGJavaScriptBridge}from'@shopgate/engage/core/helpers';import{analyticsSetConsent}from'@shopgate/engage/core/commands';import{cookieConsentInitialized$,cookieConsentUpdated$}from"../streams";import{getIsCookieConsentHandled}from"../selectors/cookieConsent";import{PRIVACY_SETTINGS_PATTERN}from"../constants";var softTrackingOptInShown$=softOptInShown$.filter(function(_ref){var _action$meta;var action=_ref.action;return(action===null||action===void 0?void 0:(_action$meta=action.meta)===null||_action$meta===void 0?void 0:_action$meta.permission)==='tracking';});var softTrackingOptInSelected$=softOptInSelected$.filter(function(_ref2){var _action$meta2;var action=_ref2.action;return(action===null||action===void 0?void 0:(_action$meta2=action.meta)===null||_action$meta2===void 0?void 0:_action$meta2.permission)==='tracking';});var hardTrackingOptInShown$=hardOptInShown$.filter(function(_ref3){var _action$meta3;var action=_ref3.action;return(action===null||action===void 0?void 0:(_action$meta3=action.meta)===null||_action$meta3===void 0?void 0:_action$meta3.permission)==='tracking';});var hardTrackingOptInSelected$=hardOptInSelected$.filter(function(_ref4){var _action$meta4;var action=_ref4.action;return(action===null||action===void 0?void 0:(_action$meta4=action.meta)===null||_action$meta4===void 0?void 0:_action$meta4.permission)==='tracking';});var privacySettingsWillEnter$=routeWillEnter$.filter(function(_ref5){var action=_ref5.action;return action.route.pattern===PRIVACY_SETTINGS_PATTERN;})// Only emit when cookie consent is already handled
|
|
2
|
+
.filter(function(_ref6){var getState=_ref6.getState;return getIsCookieConsentHandled(getState());});/**
|
|
2
3
|
* Analytics subscriptions
|
|
3
4
|
* @param {Function} subscribe The subscribe function
|
|
4
5
|
*/export default function analytics(subscribe){/**
|
|
5
6
|
* Sends cookie consent decisions to the app
|
|
6
7
|
* @param {Object} params Function params
|
|
7
8
|
* @param {Object} params.action Cookie consent update action
|
|
8
|
-
*/var sendConsentToApp=/*#__PURE__*/function(){var
|
|
9
|
-
_context.next=6;return analyticsSetConsent({statistics:statisticsCookiesAccepted,comfort:comfortCookiesAccepted});case 6:case"end":return _context.stop();}},_callee);}));return function sendConsentToApp(_x){return
|
|
9
|
+
*/var sendConsentToApp=/*#__PURE__*/function(){var _ref8=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref7){var action,statisticsCookiesAccepted,comfortCookiesAccepted;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:action=_ref7.action;if(!(!appSupportsCookieConsent()||!hasSGJavaScriptBridge())){_context.next=3;break;}return _context.abrupt("return");case 3:statisticsCookiesAccepted=action.statisticsCookiesAccepted,comfortCookiesAccepted=action.comfortCookiesAccepted;// Send consent decisions to the app
|
|
10
|
+
_context.next=6;return analyticsSetConsent({statistics:statisticsCookiesAccepted,comfort:comfortCookiesAccepted});case 6:case"end":return _context.stop();}},_callee);}));return function sendConsentToApp(_x){return _ref8.apply(this,arguments);};}();subscribe(cookieConsentInitialized$,/*#__PURE__*/function(){var _ref10=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref9){var action;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:action=_ref9.action;_context2.next=3;return sendConsentToApp({action:action});case 3:case"end":return _context2.stop();}},_callee2);}));return function(_x2){return _ref10.apply(this,arguments);};}());subscribe(cookieConsentUpdated$,/*#__PURE__*/function(){var _ref12=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref11){var dispatch,action;return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:dispatch=_ref11.dispatch,action=_ref11.action;_context3.next=3;return sendConsentToApp({action:action});case 3:// The PWA is reloaded whenever cookie consent settings changed to guarantee that all trackers
|
|
10
11
|
// are turned off
|
|
11
|
-
dispatch(reloadApp());case 4:case"end":return _context3.stop();}},_callee3);}));return function(_x3){return
|
|
12
|
+
dispatch(reloadApp());case 4:case"end":return _context3.stop();}},_callee3);}));return function(_x3){return _ref12.apply(this,arguments);};}());subscribe(softTrackingOptInShown$,function(_ref13){var getState=_ref13.getState;track('customEvent',{eventCategory:'softTrackingOptIn',eventAction:'shown',eventLabel:null,additionalEventParams:{eventName:'softTrackingOptInShown'}},getState());});subscribe(softTrackingOptInSelected$,function(_ref14){var action=_ref14.action,getState=_ref14.getState;var selection=action.selection,_action$meta5=action.meta,permission=_action$meta5.permission,meta=_objectWithoutProperties(_action$meta5,_excluded);track('customEvent',{eventCategory:'softTrackingOptIn',eventAction:'decision',eventLabel:selection,additionalEventParams:_extends({eventName:'softTrackingOptInSelected',selection:selection},meta)},getState());});subscribe(hardTrackingOptInShown$,function(_ref15){var action=_ref15.action,getState=_ref15.getState;var _action$meta6=action.meta,permission=_action$meta6.permission,meta=_objectWithoutProperties(_action$meta6,_excluded2);track('customEvent',{eventCategory:'hardTrackingOptIn',eventAction:'shown',eventLabel:null,additionalEventParams:_extends({eventName:'hardTrackingOptInShown'},meta)},getState());});subscribe(hardTrackingOptInSelected$,function(_ref16){var action=_ref16.action,getState=_ref16.getState;var selection=action.selection,_action$meta7=action.meta,permission=_action$meta7.permission,meta=_objectWithoutProperties(_action$meta7,_excluded3);track('customEvent',{eventCategory:'hardTrackingOptIn',eventAction:'decision',eventLabel:selection,additionalEventParams:_extends({eventName:'hardTrackingOptInSelected',selection:selection},meta)},getState());});subscribe(cookieConsentUpdated$,function(_ref17){var action=_ref17.action,getState=_ref17.getState;var _getCurrentQuery=getCurrentQuery(getState()),_getCurrentQuery$sour=_getCurrentQuery.source,source=_getCurrentQuery$sour===void 0?'other':_getCurrentQuery$sour;var allowComfortNew=action.comfortCookiesAccepted,allowStatisticsNew=action.statisticsCookiesAccepted,_action$previous=action.previous,_action$previous2=_action$previous===void 0?{}:_action$previous,allowComfortOld=_action$previous2.comfortCookiesAccepted,allowStatisticsOld=_action$previous2.statisticsCookiesAccepted;track('customEvent',{eventCategory:'softTrackingSettings',eventAction:'changed',eventLabel:null,additionalEventParams:{eventName:'softTrackingSettingsChanged',context:source,allowComfortOld:allowComfortOld,allowComfortNew:allowComfortNew,allowStatisticsOld:allowStatisticsOld,allowStatisticsNew:allowStatisticsNew}},getState());});subscribe(privacySettingsWillEnter$,function(_ref18){var getState=_ref18.getState;var _getCurrentQuery2=getCurrentQuery(getState()),_getCurrentQuery2$sou=_getCurrentQuery2.source,source=_getCurrentQuery2$sou===void 0?'other':_getCurrentQuery2$sou;track('customEvent',{eventCategory:'softTrackingSettings',eventAction:'shown',eventLabel:null,additionalEventParams:{eventName:'softTrackingSettingsShown',context:source}},getState());});}
|
|
@@ -1,13 +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{appDidStart$}from'@shopgate/engage/core/streams';import{appSupportsCookieConsent}from'@shopgate/engage/core/helpers';import{grantAppTrackingTransparencyPermission,historyReset,historyPop}from'@shopgate/engage/core/actions';import{handleCookieConsent,showCookieConsentModal,hideCookieConsentModal}from"../action-creators";import{getIsCookieConsentHandled,getAreComfortCookiesAccepted,getAreStatisticsCookiesAccepted}from"../selectors/cookieConsent";import{cookieConsentInitializedByUserInternal$,privacySettingsConfirmedWithoutChangeInternal$,cookieConsentModalShouldToggleInternal$}from"../streams/cookieConsent";/**
|
|
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{appDidStart$}from'@shopgate/engage/core/streams';import{appSupportsCookieConsent}from'@shopgate/engage/core/helpers';import{grantAppTrackingTransparencyPermission,historyReset,historyPop}from'@shopgate/engage/core/actions';import{softOptInShown}from'@shopgate/engage/core/action-creators';import{handleCookieConsent,showCookieConsentModal,hideCookieConsentModal}from"../action-creators";import{getIsCookieConsentHandled,getAreComfortCookiesAccepted,getAreStatisticsCookiesAccepted,getCookieConsentTrackingMeta}from"../selectors/cookieConsent";import{cookieConsentInitializedByUserInternal$,privacySettingsConfirmedWithoutChangeInternal$,cookieConsentModalShouldToggleInternal$}from"../streams/cookieConsent";/**
|
|
2
2
|
* determine whether to show the cookie consent modal at app start
|
|
3
3
|
* @param {Function} subscribe The subscribe function
|
|
4
|
-
*/export default function cookieConsent(subscribe){subscribe(appDidStart$,/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref){var dispatch,getState,state,isCookieConsentHandled,comfortCookiesAccepted,statisticsCookiesAccepted;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:dispatch=_ref.dispatch,getState=_ref.getState;state=getState();isCookieConsentHandled=getIsCookieConsentHandled(state);/**
|
|
4
|
+
*/export default function cookieConsent(subscribe){subscribe(appDidStart$,/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref){var dispatch,getState,state,isCookieConsentHandled,trackingMeta,comfortCookiesAccepted,statisticsCookiesAccepted;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:dispatch=_ref.dispatch,getState=_ref.getState;state=getState();isCookieConsentHandled=getIsCookieConsentHandled(state);trackingMeta=getCookieConsentTrackingMeta(state);/**
|
|
5
5
|
* if merchant has not activated the cookie feature OR if merchant has activated cookie feature
|
|
6
6
|
* and user has chosen cookies already trigger stream to run code that depends on the cookie
|
|
7
7
|
* consent.
|
|
8
|
-
*/if(!isCookieConsentHandled){_context.next=
|
|
8
|
+
*/if(!isCookieConsentHandled){_context.next=13;break;}comfortCookiesAccepted=getAreComfortCookiesAccepted(state);statisticsCookiesAccepted=getAreStatisticsCookiesAccepted(state);dispatch(handleCookieConsent({comfortCookiesAccepted:comfortCookiesAccepted,statisticsCookiesAccepted:statisticsCookiesAccepted}));if(!(appSupportsCookieConsent()&&(comfortCookiesAccepted||statisticsCookiesAccepted))){_context.next=11;break;}_context.next=11;return dispatch(grantAppTrackingTransparencyPermission({meta:trackingMeta}));case 11:_context.next=15;break;case 13:// if merchant has activated cookie feature but user has not chosen cookies yet:
|
|
9
9
|
// show cookie consent modal to make user choose them
|
|
10
|
-
dispatch(showCookieConsentModal());case
|
|
10
|
+
dispatch(softOptInShown({meta:trackingMeta}));dispatch(showCookieConsentModal());case 15:case"end":return _context.stop();}},_callee);}));return function(_x){return _ref2.apply(this,arguments);};}());subscribe(cookieConsentInitializedByUserInternal$,function(_ref3){var dispatch=_ref3.dispatch;// Reset history after consent initialization to guarantee an empty history
|
|
11
11
|
dispatch(historyReset());});subscribe(privacySettingsConfirmedWithoutChangeInternal$,function(_ref4){var dispatch=_ref4.dispatch;// Remove privacy settings route from route stack when any button was clicked but no settings
|
|
12
12
|
// where changed. When something was changed, app will reset via the "analytics" streams.
|
|
13
13
|
dispatch(historyPop());});subscribe(cookieConsentModalShouldToggleInternal$,function(_ref5){var dispatch=_ref5.dispatch,showConsentModal=_ref5.showConsentModal;dispatch(showConsentModal?showCookieConsentModal():hideCookieConsentModal());});}
|