@shopgate/engage 6.23.0-beta.1 → 6.23.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/components/Switch/index.js +5 -0
- package/components/Switch/style.js +1 -0
- package/components/index.js +1 -1
- package/core/action-creators/app.js +5 -0
- package/core/action-creators/index.js +1 -1
- package/core/actions/grantAppTrackingTransparencyPermission.js +6 -0
- package/core/actions/index.js +7 -1
- package/core/classes/index.js +1 -0
- package/core/collections/index.js +1 -1
- package/core/commands/analyticsSetConsent.js +11 -0
- package/core/commands/index.js +1 -0
- package/core/constants/actionTypes.js +1 -1
- package/core/constants/appFeatures.js +1 -1
- package/core/helpers/appFeatures.js +8 -2
- package/core/helpers/baseUrl.js +14 -0
- package/core/helpers/index.js +7 -1
- package/core/index.js +8 -43
- package/core/initialization/index.js +5 -3
- package/core/selectors/index.js +6 -1
- package/core/streams/app.js +8 -0
- package/core/streams/index.js +4 -1
- package/core/subscriptions/app.js +7 -0
- package/package.json +9 -8
- package/page/constants/index.js +1 -0
- package/page/index.js +2 -2
- package/push-opt-in/components/PushOptInModal/index.js +1 -1
- package/push-opt-in/components/PushOptInModal/style.js +1 -1
- package/push-opt-in/subscriptions/optInTrigger.js +3 -3
- package/tracking/action-creators/cookieConsent.js +24 -0
- package/tracking/action-creators/index.js +1 -0
- package/tracking/actions/cookieConsent.js +21 -0
- package/tracking/actions/index.js +1 -0
- package/tracking/components/CookieConsentModal/connector.js +8 -0
- package/tracking/components/CookieConsentModal/cookieConsent.svg +62 -0
- package/tracking/components/CookieConsentModal/index.js +10 -0
- package/tracking/components/CookieConsentModal/style.js +1 -0
- package/tracking/components/PrivacySettings/connector.js +8 -0
- package/tracking/components/PrivacySettings/index.js +4 -0
- package/tracking/components/PrivacySettings/style.js +1 -0
- package/tracking/components/index.js +1 -0
- package/tracking/constants/index.js +1 -0
- package/tracking/reducers/cookieConsentModal.js +6 -0
- package/tracking/reducers/cookieSettings.js +6 -0
- package/tracking/reducers/index.js +1 -0
- package/tracking/selectors/cookieConsent.js +29 -0
- package/tracking/selectors/index.js +1 -0
- package/tracking/streams/cookieConsent.js +29 -0
- package/tracking/streams/index.js +1 -0
- package/tracking/subscriptions/analytics.js +11 -0
- package/tracking/subscriptions/cookieConsent.js +14 -0
- package/tracking/subscriptions/index.js +1 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React,{useMemo}from'react';import PropTypes from'prop-types';import classNames from'classnames';import styles from"./style";/**
|
|
2
|
+
* The Switch component.
|
|
3
|
+
* @param {Object} props The component props.
|
|
4
|
+
* @returns {JSX.Element}
|
|
5
|
+
*/var Switch=function Switch(_ref){var disabled=_ref.disabled,checked=_ref.checked,onChange=_ref.onChange,id=_ref.id;var switchId=useMemo(function(){return id||Math.random();},[id]);return/*#__PURE__*/React.createElement("div",{className:styles.container},/*#__PURE__*/React.createElement("input",{onChange:onChange,className:styles.input,disabled:disabled,checked:checked,type:"checkbox",id:switchId}),/*#__PURE__*/React.createElement("label",{className:disabled?classNames(styles.disabled,styles.switchButton):styles.switchButton,htmlFor:switchId}));};Switch.defaultProps={disabled:false,checked:false,onChange:null,id:null};export default Switch;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _css;function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var container=css({display:'flex',textAlign:'left',justifyContent:'space-between'});var switchButton=css({display:'inline-block',width:'40px',height:'20px',backgroundColor:'#ccc',borderRadius:'10px',position:'relative',cursor:'pointer',':before':{content:'""',position:'absolute',top:'2px',left:'2px',width:'16px',height:'16px',backgroundColor:'white',borderRadius:'50%',transition:'transform 0.3s'}});var input=css((_css={display:'none'},_defineProperty(_css,":checked + .".concat(switchButton),{backgroundColor:themeConfig.colors.accent}),_defineProperty(_css,":disabled + .".concat(switchButton),{backgroundColor:themeConfig.colors.shade7}),_defineProperty(_css,":checked + .".concat(switchButton,"::before"),{transform:'translateX(20px)'}),_css));var disabled=css({backgroundColor:themeConfig.colors.shade7,cursor:'not-allowed'});export default{input:input,switchButton:switchButton,container:container,disabled:disabled};
|
package/components/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Holds the react components.
|
|
3
3
|
* @module index
|
|
4
4
|
*/export{default as App}from'@shopgate/pwa-common/App';// COMMON
|
|
5
|
-
export{default as Backdrop}from'@shopgate/pwa-common/components/Backdrop';export{default as BaseButton}from'@shopgate/pwa-common/components/Button';export{default as BaseCheckbox}from'@shopgate/pwa-common/components/Checkbox';export{default as Consume}from'@shopgate/pwa-common/components/Consume';export{default as CountdownTimer}from'@shopgate/pwa-common/components/CountdownTimer';export{default as Drawer}from'@shopgate/pwa-common/components/Drawer';export{default as Dropdown}from'@shopgate/pwa-common/components/Dropdown';export{default as Ellipsis}from'@shopgate/pwa-common/components/Ellipsis';export{default as ErrorBoundary}from'@shopgate/pwa-common/components/ErrorBoundary';export{default as Grid}from'@shopgate/pwa-common/components/Grid';export{default as HtmlSanitizer}from'@shopgate/pwa-common/components/HtmlSanitizer';export{default as I18n}from'@shopgate/pwa-common/components/I18n';export{default as Icon}from'@shopgate/pwa-common/components/Icon';export{default as Image}from'@shopgate/pwa-common/components/Image';export{default as InfiniteContainer}from'@shopgate/pwa-common/components/InfiniteContainer';export{default as Input}from'@shopgate/pwa-common/components/Input';export{default as KeyboardConsumer}from'@shopgate/pwa-common/components/KeyboardConsumer';export{default as Link}from'@shopgate/pwa-common/components/Link';export{default as List}from'@shopgate/pwa-common/components/List';export{default as Loading}from'@shopgate/pwa-common/components/Loading';export{default as Modal}from'@shopgate/pwa-common/components/Modal';export{default as ModalContainer,MODAL_EVENTS}from'@shopgate/pwa-common/components/ModalContainer';export{default as Picker}from"./Picker";export{default as Portal}from'@shopgate/pwa-common/components/Portal';export{default as RangeSlider}from"./RangeSlider";export{default as Route}from'@shopgate/pwa-common/components/Route';export{default as ScannerContainer}from'@shopgate/pwa-common/components/ScannerContainer';export{default as BaseSelect}from'@shopgate/pwa-common/components/Select';export{default as SelectBox}from'@shopgate/pwa-common/components/SelectBox';export{default as Slider}from'@shopgate/pwa-common/components/Slider';export{default as SurroundPortals}from'@shopgate/pwa-common/components/SurroundPortals';export{default as Swiper}from'@shopgate/pwa-common/components/Swiper';export{default as Toaster}from'@shopgate/pwa-common/components/Toaster';export{default as Transition}from'@shopgate/pwa-common/components/Transition';export{default as Widgets}from'@shopgate/pwa-common/components/Widgets';// iOS
|
|
5
|
+
export{default as Backdrop}from'@shopgate/pwa-common/components/Backdrop';export{default as BaseButton}from'@shopgate/pwa-common/components/Button';export{default as BaseCheckbox}from'@shopgate/pwa-common/components/Checkbox';export{default as Consume}from'@shopgate/pwa-common/components/Consume';export{default as CountdownTimer}from'@shopgate/pwa-common/components/CountdownTimer';export{default as Drawer}from'@shopgate/pwa-common/components/Drawer';export{default as Dropdown}from'@shopgate/pwa-common/components/Dropdown';export{default as Ellipsis}from'@shopgate/pwa-common/components/Ellipsis';export{default as ErrorBoundary}from'@shopgate/pwa-common/components/ErrorBoundary';export{default as Grid}from'@shopgate/pwa-common/components/Grid';export{default as HtmlSanitizer}from'@shopgate/pwa-common/components/HtmlSanitizer';export{default as I18n}from'@shopgate/pwa-common/components/I18n';export{default as Icon}from'@shopgate/pwa-common/components/Icon';export{default as Image}from'@shopgate/pwa-common/components/Image';export{default as InfiniteContainer}from'@shopgate/pwa-common/components/InfiniteContainer';export{default as Input}from'@shopgate/pwa-common/components/Input';export{default as KeyboardConsumer}from'@shopgate/pwa-common/components/KeyboardConsumer';export{default as Link}from'@shopgate/pwa-common/components/Link';export{default as List}from'@shopgate/pwa-common/components/List';export{default as Loading}from'@shopgate/pwa-common/components/Loading';export{default as Modal}from'@shopgate/pwa-common/components/Modal';export{default as ModalContainer,MODAL_EVENTS}from'@shopgate/pwa-common/components/ModalContainer';export{default as Picker}from"./Picker";export{default as Portal}from'@shopgate/pwa-common/components/Portal';export{default as RangeSlider}from"./RangeSlider";export{default as Route}from'@shopgate/pwa-common/components/Route';export{default as ScannerContainer}from'@shopgate/pwa-common/components/ScannerContainer';export{default as BaseSelect}from'@shopgate/pwa-common/components/Select';export{default as SelectBox}from'@shopgate/pwa-common/components/SelectBox';export{default as Slider}from'@shopgate/pwa-common/components/Slider';export{default as SurroundPortals}from'@shopgate/pwa-common/components/SurroundPortals';export{default as Swiper}from'@shopgate/pwa-common/components/Swiper';export{default as Toaster}from'@shopgate/pwa-common/components/Toaster';export{default as Transition}from'@shopgate/pwa-common/components/Transition';export{default as Widgets}from'@shopgate/pwa-common/components/Widgets';export{default as Switch}from'@shopgate/engage/components/Switch';// iOS
|
|
6
6
|
export{default as AppBarIOS}from'@shopgate/pwa-ui-ios/AppBar';export{default as BaseDialogIOS}from'@shopgate/pwa-ui-ios/BaseDialog';// ANDROID
|
|
7
7
|
export{default as Accordion}from'@shopgate/pwa-ui-material/Accordion';export{default as AppBarAndroid}from'@shopgate/pwa-ui-material/AppBar';export{default as BaseDialogAndroid}from'@shopgate/pwa-ui-material/BaseDialog';export{default as FloatingActionButton}from'@shopgate/pwa-ui-material/FloatingActionButton';export{default as NavDrawer}from'@shopgate/pwa-ui-material/NavDrawer';export{default as SnackBar}from'@shopgate/pwa-ui-material/SnackBar';// SHARED
|
|
8
8
|
export{default as AccordionContainer}from'@shopgate/pwa-ui-shared/AccordionContainer';export{default as ActionButton}from'@shopgate/pwa-ui-shared/ActionButton';export{default as AddToCartButton}from'@shopgate/pwa-ui-shared/AddToCartButton';export{default as Availability}from'@shopgate/pwa-ui-shared/Availability';export{default as Button}from'@shopgate/pwa-ui-shared/Button';export{default as ButtonLink}from'@shopgate/pwa-ui-shared/ButtonLink';export{default as Card}from'@shopgate/pwa-ui-shared/Card';export{default as CardList}from'@shopgate/pwa-ui-shared/CardList';export{default as CartTotalLine}from'@shopgate/pwa-ui-shared/CartTotalLine';export{default as Chip}from'@shopgate/pwa-ui-shared/Chip';export{default as ClientInformation}from'@shopgate/pwa-ui-shared/ClientInformation';export{default as ContextMenu}from'@shopgate/pwa-ui-shared/ContextMenu';export{default as Dialog}from'@shopgate/pwa-ui-shared/Dialog';export{default as DiscountBadge}from'@shopgate/pwa-ui-shared/DiscountBadge';export{default as FavoritesButton}from'@shopgate/pwa-ui-shared/FavoritesButton';export{default as Checkbox}from'@shopgate/pwa-ui-shared/Form/Checkbox';export{default as Password}from'@shopgate/pwa-ui-shared/Form/Password';export{default as RadioGroup}from'@shopgate/pwa-ui-shared/Form/RadioGroup';export{default as Select}from'@shopgate/pwa-ui-shared/Form/Select';export{default as TextField}from'@shopgate/pwa-ui-shared/Form/TextField';export{default as FormElement}from'@shopgate/pwa-ui-shared/FormElement';export{default as Glow}from'@shopgate/pwa-ui-shared/Glow';export{default as IndicatorCircle}from'@shopgate/pwa-ui-shared/IndicatorCircle';export{default as LoadingIndicator}from'@shopgate/pwa-ui-shared/LoadingIndicator';export{default as Manufacturer}from'@shopgate/pwa-ui-shared/Manufacturer';export{default as MessageBar}from"./MessageBar";export{default as NoResults}from'@shopgate/pwa-ui-shared/NoResults';export{default as Placeholder}from'@shopgate/pwa-ui-shared/Placeholder';export{default as PlaceholderLabel}from'@shopgate/pwa-ui-shared/PlaceholderLabel';export{default as PlaceholderParagraph}from'@shopgate/pwa-ui-shared/PlaceholderParagraph';export{default as Price}from'@shopgate/pwa-ui-shared/Price';export{default as PriceInfo}from'@shopgate/pwa-ui-shared/PriceInfo';export{default as PriceStriked}from'@shopgate/pwa-ui-shared/PriceStriked';export{default as ProductProperties}from'@shopgate/pwa-ui-shared/ProductProperties';export{default as ProgressBar}from'@shopgate/pwa-ui-shared/ProgressBar';export{default as RadioButton}from'@shopgate/pwa-ui-shared/RadioButton';export{default as RatingNumber}from'@shopgate/pwa-ui-shared/RatingNumber';export{default as RatingStars}from'@shopgate/pwa-ui-shared/RatingStars';export{default as Ripple}from'@shopgate/pwa-ui-shared/Ripple';export{default as RippleButton}from'@shopgate/pwa-ui-shared/RippleButton';export{default as ScannerOverlay}from'@shopgate/pwa-ui-shared/ScannerOverlay';export{default as Sheet,SHEET_EVENTS}from'@shopgate/pwa-ui-shared/Sheet';export{default as TaxDisclaimer}from'@shopgate/pwa-ui-shared/TaxDisclaimer';export{default as ToggleIcon}from'@shopgate/pwa-ui-shared/ToggleIcon';// ICONS IOS
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{RELOAD_APP}from"../constants";/**
|
|
2
|
+
* Creates the RELOAD_APP Redux action object that's supposed to be dispatched
|
|
3
|
+
* when the app is supposed to be reloaded.
|
|
4
|
+
* @returns {Object} The Redux action object
|
|
5
|
+
*/export var reloadApp=function reloadApp(){return{type:RELOAD_APP};};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./appPermissions";
|
|
1
|
+
export*from"./app";export*from"./appPermissions";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{PERMISSION_ID_APP_TRACKING_TRANSPARENCY}from'@shopgate/engage/core/constants';import grantPermissions from"./grantPermissions";/**
|
|
2
|
+
* Determines the current state of the app tracking transparency permission.
|
|
3
|
+
* If not already happened, the user will be prompted to grant permissions.
|
|
4
|
+
* The action returns a promise which resolves with a boolean value, that indicates the state.
|
|
5
|
+
* @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;
|
package/core/actions/index.js
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
export{default as getGeolocation}from"./getGeolocation";export{default as grantCameraPermissions}from"./grantCameraPermissions";export{default as grantGeolocationPermissions}from"./grantGeolocationPermissions";export{default as grantPushPermissions}from"./grantPushPermissions";export{default as requestAppPermission}from"./requestAppPermission";export{default as requestAppPermissionStatus}from"./requestAppPermissionStatus";export{default as updateStatusBarBackground}from"./updateStatusBarBackground";
|
|
1
|
+
export{default as getGeolocation}from"./getGeolocation";export{default as grantCameraPermissions}from"./grantCameraPermissions";export{default as grantGeolocationPermissions}from"./grantGeolocationPermissions";export{default as grantPushPermissions}from"./grantPushPermissions";export{default as grantAppTrackingTransparencyPermission}from"./grantAppTrackingTransparencyPermission";export{default as requestAppPermission}from"./requestAppPermission";export{default as requestAppPermissionStatus}from"./requestAppPermissionStatus";export{default as updateStatusBarBackground}from"./updateStatusBarBackground";export{default as grantPermissions}from"./grantPermissions";// --------------- APP --------------- //
|
|
2
|
+
export{default as handleDeepLink}from'@shopgate/pwa-common/actions/app/handleDeepLink';export{default as handleUniversalLink}from'@shopgate/pwa-common/actions/app/handleUniversalLink';export{default as handleLink}from'@shopgate/pwa-common/actions/app/handleLink';export{default as handlePushNotification}from'@shopgate/pwa-common/actions/app/handlePushNotification';export{default as registerLinkEvents}from'@shopgate/pwa-common/actions/app/registerLinkEvents';// --------------- CLIENT --------------- //
|
|
3
|
+
export{default as fetchClientInformation}from'@shopgate/pwa-common/actions/client/fetchClientInformation';// --------------- ROUTER --------------- //
|
|
4
|
+
export{historyPop}from'@shopgate/pwa-common/actions/router/historyPop';export{historyPush}from'@shopgate/pwa-common/actions/router/historyPush';export{historyRedirect}from'@shopgate/pwa-common/actions/router/historyRedirect';export{historyReplace}from'@shopgate/pwa-common/actions/router/historyReplace';export{historyReset}from'@shopgate/pwa-common/actions/router/historyReset';// --------------- URL --------------- //
|
|
5
|
+
export{resetApp}from'@shopgate/pwa-common/action-creators/app';export*from'@shopgate/pwa-common/action-creators/url';// --------------- MENU --------------- //
|
|
6
|
+
export{default as fetchMenu}from'@shopgate/pwa-common/actions/menu/fetchMenu';// --------------- MODAL --------------- //
|
|
7
|
+
export{default as closeModal}from'@shopgate/pwa-common/actions/modal/closeModal';export{default as promiseMap}from'@shopgate/pwa-common/actions/modal/promiseMap';export{default as showModal}from'@shopgate/pwa-common/actions/modal/showModal';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{default as GeolocationRequest}from"./GeolocationRequest";export{default as AppCommand}from'@shopgate/pwa-core/classes/AppCommand';export{default as AppCommandRequest}from'@shopgate/pwa-core/classes/AppCommandRequest';export{default as GetAppPermissionsRequest}from'@shopgate/pwa-core/classes/AppPermissionsRequest/GetAppPermissionsRequest';export{default as RequestAppPermissionsRequest}from'@shopgate/pwa-core/classes/AppPermissionsRequest/RequestAppPermissionsRequest';export{default as BrightnessRequest}from'@shopgate/pwa-core/classes/BrightnessRequest';export{default as Conditioner}from'@shopgate/pwa-core/classes/Conditioner';export{default as DataRequest}from'@shopgate/pwa-core/classes/DataRequest';export{default as DevServerBridge}from'@shopgate/pwa-core/classes/DevServerBridge';export{default as errorManager,emitter}from'@shopgate/pwa-core/classes/ErrorManager';export{default as event}from'@shopgate/pwa-core/classes/Event';export{default as HttpRequest}from'@shopgate/pwa-core/classes/HttpRequest';export{default as PipelineRequest}from'@shopgate/pwa-core/classes/PipelineRequest';export{default as ScannerManager}from'@shopgate/pwa-core/classes/ScannerManager';export{default as WebStorageRequest}from'@shopgate/pwa-core/classes/WebStorageRequest';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{default as appInitialization}from"./AppInitialization";export*from'@shopgate/pwa-common/collections';
|
|
1
|
+
export{default as appInitialization}from"./AppInitialization";export*from'@shopgate/pwa-common/collections';export{default as authRoutes}from'@shopgate/pwa-common/collections/AuthRoutes';export{default as redirects}from'@shopgate/pwa-common/collections/Redirects';export{default as configuration}from'@shopgate/pwa-common/collections/Configuration';export{default as embeddedMedia}from'@shopgate/pwa-common/collections/EmbeddedMedia';export{default as persistedReducers}from'@shopgate/pwa-common/collections/PersistedReducers';export{default as Vimeo}from'@shopgate/pwa-common/collections/media-providers/Vimeo';export{default as YouTube}from'@shopgate/pwa-common/collections/media-providers/YouTube';
|
|
@@ -0,0 +1,11 @@
|
|
|
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{AppCommandRequest}from'@shopgate/engage/core/classes';/**
|
|
2
|
+
* @typedef {Object} AnalyticsSetConsentResponse
|
|
3
|
+
* @property {string} status Update status
|
|
4
|
+
* @property {string} error Update error message
|
|
5
|
+
*/ /**
|
|
6
|
+
* Sends cookie consent settings to the app
|
|
7
|
+
* @param {Object} params Command params
|
|
8
|
+
* @param {boolean} [params.statistics=false] Setting for statistics consent
|
|
9
|
+
* @param {boolean} [params.comfort=false] Setting for comfort consent
|
|
10
|
+
* @returns {Promise<AnalyticsSetConsentResponse>}
|
|
11
|
+
*/var analyticsSetConsent=function analyticsSetConsent(){var params=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return new AppCommandRequest('analyticsSetConsent').setCommandParams(_extends({statistics:false,comfort:false},params)).dispatch();};export default analyticsSetConsent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{default as analyticsSetConsent}from"./analyticsSetConsent";export{default as analyticsSetCustomValues}from'@shopgate/pwa-core/commands/analyticsSetCustomValues';export*from'@shopgate/pwa-core/commands/appPermissions';export*from'@shopgate/pwa-core/commands/brightness';export{default as broadcastEvent}from'@shopgate/pwa-core/commands/broadcastEvent';export{default as cleanTab,cleanTabCmd}from'@shopgate/pwa-core/commands/cleanTab';export{default as closeInAppBrowser}from'@shopgate/pwa-core/commands/closeInAppBrowser';export{default as flushTab}from'@shopgate/pwa-core/commands/flushTab';export{default as hideMenuBar}from'@shopgate/pwa-core/commands/hideMenuBar';export{default as hideNavigationBar}from'@shopgate/pwa-core/commands/hideNavigationBar';export{default as hideSplashScreen}from'@shopgate/pwa-core/commands/hideSplashScreen';export{default as onload}from'@shopgate/pwa-core/commands/onload';export{default as openAppSettings}from'@shopgate/pwa-core/commands/openAppSettings';export{default as openPage}from'@shopgate/pwa-core/commands/openPage';export{default as openPageExtern}from'@shopgate/pwa-core/commands/openPageExtern';export{default as performCommandsAfterDelay,performCommandsAfterDelayCmd}from'@shopgate/pwa-core/commands/performCommandsAfterDelay';export*from'@shopgate/pwa-core/commands/plotProjects';export{default as popTabToRoot,popTabToRootCmd}from'@shopgate/pwa-core/commands/popTabToRoot';export{default as registerEvents}from'@shopgate/pwa-core/commands/registerEvents';export*from'@shopgate/pwa-core/commands/scanner';export{default as setCookie}from'@shopgate/pwa-core/commands/setCookie';export{default as setDebugLoggingEnabled}from'@shopgate/pwa-core/commands/setDebugLoggingEnabled';export{default as setScrollingEnabled}from'@shopgate/pwa-core/commands/setScrollingEnabled';export{default as showNavigationBar}from'@shopgate/pwa-core/commands/showNavigationBar';export{default as showTab}from'@shopgate/pwa-core/commands/showTab';export*from'@shopgate/pwa-core/commands/unifiedTracking';export{default as getWebStorageEntry}from'@shopgate/pwa-core/commands/getWebStorageEntry';export{default as setWebStorageEntry}from'@shopgate/pwa-core/commands/setWebStorageEntry';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export var APP_PERMISSION_STATUS_RECEIVED='APP_PERMISSION_STATUS_RECEIVED';
|
|
1
|
+
export var APP_PERMISSION_STATUS_RECEIVED='APP_PERMISSION_STATUS_RECEIVED';export var RELOAD_APP='RELOAD_APP';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export var APP_FEATURE_PUSH_OPT_IN='optIn';
|
|
1
|
+
export var APP_FEATURE_PUSH_OPT_IN='optIn';export var APP_FEATURE_COOKIE_CONSENT='cookieConsent';
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import{APP_FEATURE_PUSH_OPT_IN}from'@shopgate/engage/core/constants';import{hasSGJavaScriptBridge}from'@shopgate/pwa-core/helpers';/**
|
|
1
|
+
import{APP_FEATURE_PUSH_OPT_IN,APP_FEATURE_COOKIE_CONSENT}from'@shopgate/engage/core/constants';import{hasSGJavaScriptBridge}from'@shopgate/pwa-core/helpers';/**
|
|
2
2
|
* Determines if the app supports the push opt-in feature
|
|
3
3
|
* @returns {boolean}
|
|
4
4
|
*/export var appSupportsPushOptIn=function appSupportsPushOptIn(){var _window,_window$SGAppInfo,_window$SGAppInfo$fea,_window$SGAppInfo$fea2,_window$SGAppInfo$fea3;if(!hasSGJavaScriptBridge()){// Always supported in development
|
|
5
5
|
return true;}if(!Array.isArray((_window=window)===null||_window===void 0?void 0:(_window$SGAppInfo=_window.SGAppInfo)===null||_window$SGAppInfo===void 0?void 0:(_window$SGAppInfo$fea=_window$SGAppInfo.featureFlags)===null||_window$SGAppInfo$fea===void 0?void 0:(_window$SGAppInfo$fea2=_window$SGAppInfo$fea.Push)===null||_window$SGAppInfo$fea2===void 0?void 0:(_window$SGAppInfo$fea3=_window$SGAppInfo$fea2['1'])===null||_window$SGAppInfo$fea3===void 0?void 0:_window$SGAppInfo$fea3.flags)){// Not supported on app versions that don't provide the featureFlags object
|
|
6
6
|
return false;}// Supported when the feature flags contain the push opt-in flag
|
|
7
|
-
return window.SGAppInfo.featureFlags.Push['1'].flags.includes(APP_FEATURE_PUSH_OPT_IN);}
|
|
7
|
+
return window.SGAppInfo.featureFlags.Push['1'].flags.includes(APP_FEATURE_PUSH_OPT_IN);};/**
|
|
8
|
+
* Determines if the app supports the cookie consent feature
|
|
9
|
+
* @returns {boolean}
|
|
10
|
+
*/export var appSupportsCookieConsent=function appSupportsCookieConsent(){var _window2,_window2$SGAppInfo,_window2$SGAppInfo$fe,_window2$SGAppInfo$fe2,_window2$SGAppInfo$fe3;if(!hasSGJavaScriptBridge()){// Always supported in development
|
|
11
|
+
return true;}if(!Array.isArray((_window2=window)===null||_window2===void 0?void 0:(_window2$SGAppInfo=_window2.SGAppInfo)===null||_window2$SGAppInfo===void 0?void 0:(_window2$SGAppInfo$fe=_window2$SGAppInfo.featureFlags)===null||_window2$SGAppInfo$fe===void 0?void 0:(_window2$SGAppInfo$fe2=_window2$SGAppInfo$fe.Analytics)===null||_window2$SGAppInfo$fe2===void 0?void 0:(_window2$SGAppInfo$fe3=_window2$SGAppInfo$fe2['1'])===null||_window2$SGAppInfo$fe3===void 0?void 0:_window2$SGAppInfo$fe3.flags)){// Not supported on app versions that don't provide the featureFlags object
|
|
12
|
+
return false;}// Supported when the feature flags contain the cookie consent flag
|
|
13
|
+
return window.SGAppInfo.featureFlags.Analytics['1'].flags.includes(APP_FEATURE_COOKIE_CONSENT);};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_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;}/**
|
|
2
|
+
* Regular expression to decode all possible types of base url from an url
|
|
3
|
+
*
|
|
4
|
+
* URLs of deployed apps
|
|
5
|
+
* https://sandbox.cdn.connect.shopgate.com/shop_30186/@shopgate/theme-ios11/6.22.4/11953/index.html
|
|
6
|
+
*
|
|
7
|
+
* URLs while local development
|
|
8
|
+
* http://192.168.0.1:8080
|
|
9
|
+
*/var baseUrlRegex=/https?:\/\/(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3}(?::[0-9]+)?)|(?:.+index.html))/gm;/**
|
|
10
|
+
* Decodes the base url from a passed url. When url parameter left empty, window.location.href will
|
|
11
|
+
* be used as source
|
|
12
|
+
* @param {string} [sourceUrl=''] An optional url to be used for decode process
|
|
13
|
+
* @return {string} The decoded base url
|
|
14
|
+
*/export var getAppBaseUrl=function getAppBaseUrl(){var sourceUrl=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';var _ref=(sourceUrl||window.location.href).match(baseUrlRegex)||[],_ref2=_slicedToArray(_ref,1),_ref2$=_ref2[0],basedUrl=_ref2$===void 0?'':_ref2$;return basedUrl;};
|
package/core/helpers/index.js
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
export*from"./appFeatures";export{getFullImageSource}from"./getFullImageSource";export{getImageFormat}from"./getImageFormat";export{i18n}from"./i18n";export{updateLegacyNavigationBar}from"./updateLegacyNavigationBar"
|
|
1
|
+
/** @module core */import{getCurrentRoute as getCurrentRouteHelper,router,history,parseQueryStringToObject,parseObjectToQueryString}from'@shopgate/pwa-common/helpers/router';export*from"./appFeatures";export*from"./baseUrl";export{getFullImageSource}from"./getFullImageSource";export{getImageFormat}from"./getImageFormat";export{i18n}from"./i18n";export{updateLegacyNavigationBar}from"./updateLegacyNavigationBar";// --------------- CORE --------------- //
|
|
2
|
+
export*from'@shopgate/pwa-core/helpers';export{default as logGroup}from'@shopgate/pwa-core/helpers/logGroup';export*from'@shopgate/pwa-core/helpers/version';export*from'@shopgate/pwa-common/helpers/data';export*from'@shopgate/pwa-common/helpers/date';export*from'@shopgate/pwa-common/helpers/dom';export*from'@shopgate/pwa-common/helpers/environment';export{default as decodeHTML}from'@shopgate/pwa-common/helpers/html/decodeHTML';export*from'@shopgate/pwa-common/helpers/html/handleDOM';export{default as parseHTML}from'@shopgate/pwa-common/helpers/html/parseHTML';export{default as getTranslator}from'@shopgate/pwa-common/helpers/i18n/getTranslator';export{default as getPriceFormatter}from'@shopgate/pwa-common/helpers/i18n/getPriceFormatter';export{default as getDateFormatter}from'@shopgate/pwa-common/helpers/i18n/getDateFormatter';export{default as getTimeFormatter}from'@shopgate/pwa-common/helpers/i18n/getTimeFormatter';export{default as getNumberFormatter}from'@shopgate/pwa-common/helpers/i18n/getNumberFormatter';export*from'@shopgate/pwa-common/helpers/legacy';// TODO: Can only be exported once the theme uses it. causes issues with the custom routes feature.
|
|
3
|
+
/*
|
|
4
|
+
export { default as portalCollection } from '@shopgate/pwa-common/helpers/portals/portalCollection';
|
|
5
|
+
export { default as routePortals } from '@shopgate/pwa-common/helpers/portals/routePortals';
|
|
6
|
+
*/export*from'@shopgate/pwa-common/helpers/redux';export*from'@shopgate/pwa-common/helpers/style';export*from'@shopgate/pwa-common/helpers/tracking';export*from'@shopgate/pwa-common/helpers/validation';// --------------- ROUTER --------------- //
|
|
7
|
+
export{getCurrentRouteHelper,router,history,parseQueryStringToObject,parseObjectToQueryString};export{push,pop,replace,reset}from"../router/helpers";
|
package/core/index.js
CHANGED
|
@@ -1,46 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
//
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export{default as GetAppPermissionsRequest}from'@shopgate/pwa-core/classes/AppPermissionsRequest/GetAppPermissionsRequest';export{default as RequestAppPermissionsRequest}from'@shopgate/pwa-core/classes/AppPermissionsRequest/RequestAppPermissionsRequest';export{default as BrightnessRequest}from'@shopgate/pwa-core/classes/BrightnessRequest';export{default as Conditioner}from'@shopgate/pwa-core/classes/Conditioner';export{default as DataRequest}from'@shopgate/pwa-core/classes/DataRequest';export{default as DevServerBridge}from'@shopgate/pwa-core/classes/DevServerBridge';export{default as errorManager,emitter}from'@shopgate/pwa-core/classes/ErrorManager';export{default as event}from'@shopgate/pwa-core/classes/Event';export{default as HttpRequest}from'@shopgate/pwa-core/classes/HttpRequest';export{default as PipelineRequest}from'@shopgate/pwa-core/classes/PipelineRequest';export{default as ScannerManager}from'@shopgate/pwa-core/classes/ScannerManager';export{default as WebStorageRequest}from'@shopgate/pwa-core/classes/WebStorageRequest';export{default as GeolocationRequest}from"./classes/GeolocationRequest";// Commands
|
|
6
|
-
export{default as analyticsSetCustomValues}from'@shopgate/pwa-core/commands/analyticsSetCustomValues';export*from'@shopgate/pwa-core/commands/appPermissions';export*from'@shopgate/pwa-core/commands/brightness';export{default as broadcastEvent}from'@shopgate/pwa-core/commands/broadcastEvent';export{default as cleanTab,cleanTabCmd}from'@shopgate/pwa-core/commands/cleanTab';export{default as closeInAppBrowser}from'@shopgate/pwa-core/commands/closeInAppBrowser';export{default as flushTab}from'@shopgate/pwa-core/commands/flushTab';export{default as hideMenuBar}from'@shopgate/pwa-core/commands/hideMenuBar';export{default as hideNavigationBar}from'@shopgate/pwa-core/commands/hideNavigationBar';export{default as hideSplashScreen}from'@shopgate/pwa-core/commands/hideSplashScreen';export{default as onload}from'@shopgate/pwa-core/commands/onload';export{default as openAppSettings}from'@shopgate/pwa-core/commands/openAppSettings';export{default as openPage}from'@shopgate/pwa-core/commands/openPage';export{default as openPageExtern}from'@shopgate/pwa-core/commands/openPageExtern';export{default as performCommandsAfterDelay,performCommandsAfterDelayCmd}from'@shopgate/pwa-core/commands/performCommandsAfterDelay';export*from'@shopgate/pwa-core/commands/plotProjects';export{default as popTabToRoot,popTabToRootCmd}from'@shopgate/pwa-core/commands/popTabToRoot';export{default as registerEvents}from'@shopgate/pwa-core/commands/registerEvents';export*from'@shopgate/pwa-core/commands/scanner';export{default as setCookie}from'@shopgate/pwa-core/commands/setCookie';export{default as setDebugLoggingEnabled}from'@shopgate/pwa-core/commands/setDebugLoggingEnabled';export{default as setScrollingEnabled}from'@shopgate/pwa-core/commands/setScrollingEnabled';export{default as showNavigationBar}from'@shopgate/pwa-core/commands/showNavigationBar';export{default as showTab}from'@shopgate/pwa-core/commands/showTab';export*from'@shopgate/pwa-core/commands/unifiedTracking';// TODO: Contains circular dependency!
|
|
7
|
-
// export * from '@shopgate/pwa-core/commands/webStorage';
|
|
8
|
-
// Constants
|
|
9
|
-
export*from"./constants";// Emitters
|
|
10
|
-
export{default as UIEvents}from'@shopgate/pwa-core/emitters/ui';// Helpers
|
|
11
|
-
export*from'@shopgate/pwa-core/helpers';export{default as logGroup}from'@shopgate/pwa-core/helpers/logGroup';export*from'@shopgate/pwa-core/helpers/version';export*from'@shopgate/pwa-common/helpers/data';export*from'@shopgate/pwa-common/helpers/date';export*from'@shopgate/pwa-common/helpers/dom';export*from'@shopgate/pwa-common/helpers/environment';export{default as decodeHTML}from'@shopgate/pwa-common/helpers/html/decodeHTML';export*from'@shopgate/pwa-common/helpers/html/handleDOM';export{default as parseHTML}from'@shopgate/pwa-common/helpers/html/parseHTML';export{default as getTranslator}from'@shopgate/pwa-common/helpers/i18n/getTranslator';export{default as getPriceFormatter}from'@shopgate/pwa-common/helpers/i18n/getPriceFormatter';export{default as getDateFormatter}from'@shopgate/pwa-common/helpers/i18n/getDateFormatter';export{default as getTimeFormatter}from'@shopgate/pwa-common/helpers/i18n/getTimeFormatter';export{default as getNumberFormatter}from'@shopgate/pwa-common/helpers/i18n/getNumberFormatter';export*from'@shopgate/pwa-common/helpers/legacy';// TODO: Can only be exported once the theme uses it. causes issues with the custom routes feature.
|
|
12
|
-
/*
|
|
13
|
-
export { default as portalCollection } from '@shopgate/pwa-common/helpers/portals/portalCollection';
|
|
14
|
-
export { default as routePortals } from '@shopgate/pwa-common/helpers/portals/routePortals';
|
|
15
|
-
*/export*from'@shopgate/pwa-common/helpers/redux';export*from'@shopgate/pwa-common/helpers/style';export*from'@shopgate/pwa-common/helpers/tracking';export*from'@shopgate/pwa-common/helpers/validation';// STREAMS
|
|
16
|
-
export*from'@shopgate/pwa-common/streams/main';export*from'@shopgate/pwa-common/streams/error';// --------------- APP --------------- //
|
|
17
|
-
// ACTIONS
|
|
18
|
-
export{default as handleDeepLink}from'@shopgate/pwa-common/actions/app/handleDeepLink';export{default as handleUniversalLink}from'@shopgate/pwa-common/actions/app/handleUniversalLink';export{default as handleLink}from'@shopgate/pwa-common/actions/app/handleLink';export{default as handlePushNotification}from'@shopgate/pwa-common/actions/app/handlePushNotification';export{default as registerLinkEvents}from'@shopgate/pwa-common/actions/app/registerLinkEvents';export{default as updateStatusBarBackground}from"./actions/updateStatusBarBackground";export{default as grantPermissions}from"./actions/grantPermissions";export{default as grantPushPermissions}from"./actions/grantPushPermissions";export{default as grantCameraPermissions}from"./actions/grantCameraPermissions";export{default as grantGeolocationPermissions}from"./actions/grantGeolocationPermissions";export{default as requestAppPermission}from"./actions/requestAppPermission";export{default as requestAppPermissionStatus}from"./actions/requestAppPermissionStatus";export{default as getGeolocation}from"./actions/getGeolocation";// STREAMS
|
|
19
|
-
export*from'@shopgate/pwa-common/streams/app';// --------------- STORE --------------- //
|
|
20
|
-
export*from'@shopgate/pwa-common/store';// --------------- CLIENT --------------- //
|
|
21
|
-
// ACTIONS
|
|
22
|
-
export{default as fetchClientInformation}from'@shopgate/pwa-common/actions/client/fetchClientInformation';// SELECTORS
|
|
23
|
-
export*from'@shopgate/pwa-common/selectors/client';// STREAMS
|
|
24
|
-
export*from'@shopgate/pwa-common/streams/client';// --------------- COLLECTIONS --------------- //
|
|
25
|
-
export{default as appInitialization}from"./collections/AppInitialization";export{default as authRoutes}from'@shopgate/pwa-common/collections/AuthRoutes';export{default as redirects}from'@shopgate/pwa-common/collections/Redirects';export{default as configuration}from'@shopgate/pwa-common/collections/Configuration';export{default as embeddedMedia}from'@shopgate/pwa-common/collections/EmbeddedMedia';export{default as persistedReducers}from'@shopgate/pwa-common/collections/PersistedReducers';export{default as Vimeo}from'@shopgate/pwa-common/collections/media-providers/Vimeo';export{default as YouTube}from'@shopgate/pwa-common/collections/media-providers/YouTube';// --------------- CONTEXTS --------------- //
|
|
1
|
+
// --------------- CORE --------------- //
|
|
2
|
+
// Emitters
|
|
3
|
+
export{default as UIEvents}from'@shopgate/pwa-core/emitters/ui';// --------------- STORE --------------- //
|
|
4
|
+
export*from'@shopgate/pwa-common/store';// --------------- CONTEXTS --------------- //
|
|
26
5
|
export*from'@shopgate/pwa-common/context';export{default as AppContext}from"./contexts/AppContext";// --------------- PROVIDERS --------------- //
|
|
27
|
-
export{default as LoadingProvider}from'@shopgate/pwa-common/providers/loading';export{default as LoadingContext}from'@shopgate/pwa-common/providers/loading/context';export{default as ToastProvider}from'@shopgate/pwa-common/providers/toast';export{default as ToastContext}from'@shopgate/pwa-common/providers/toast/context';export{default as AppProvider}from"./providers/AppProvider";// ---------------
|
|
28
|
-
//
|
|
29
|
-
export{
|
|
30
|
-
export{getCurrentRouteHelper,router,history,parseQueryStringToObject,parseObjectToQueryString};export{push,pop,replace,reset}from"./router/helpers";// SELECTORS
|
|
31
|
-
export*from'@shopgate/pwa-common/selectors/router';export*from'@shopgate/pwa-common/selectors/history';// STREAMS
|
|
32
|
-
export*from'@shopgate/pwa-common/streams/router';// --------------- URL --------------- //
|
|
33
|
-
// ACTIONS
|
|
34
|
-
export{resetApp}from'@shopgate/pwa-common/action-creators/app';export*from'@shopgate/pwa-common/action-creators/url';// SELECTORS
|
|
35
|
-
export*from'@shopgate/pwa-common/selectors/url';// --------------- MENU --------------- //
|
|
36
|
-
// ACTIONS
|
|
37
|
-
export{default as fetchMenu}from'@shopgate/pwa-common/actions/menu/fetchMenu';// SELECTORS
|
|
38
|
-
export*from'@shopgate/pwa-common/selectors/menu';// --------------- MODAL --------------- //
|
|
39
|
-
// ACTIONS
|
|
40
|
-
export{default as closeModal}from'@shopgate/pwa-common/actions/modal/closeModal';export{default as promiseMap}from'@shopgate/pwa-common/actions/modal/promiseMap';export{default as showModal}from'@shopgate/pwa-common/actions/modal/showModal';// HELPERS
|
|
41
|
-
export{default as withShowModal}from'@shopgate/pwa-common/helpers/modal/withShowModal';// SELECTORS
|
|
42
|
-
export*from'@shopgate/pwa-common/selectors/modal';// --------------- HOOKS --------------- //
|
|
6
|
+
export{default as LoadingProvider}from'@shopgate/pwa-common/providers/loading';export{default as LoadingContext}from'@shopgate/pwa-common/providers/loading/context';export{default as ToastProvider}from'@shopgate/pwa-common/providers/toast';export{default as ToastContext}from'@shopgate/pwa-common/providers/toast/context';export{default as AppProvider}from"./providers/AppProvider";// --------------- MODAL --------------- //
|
|
7
|
+
// HOCs
|
|
8
|
+
export{default as withShowModal}from'@shopgate/pwa-common/helpers/modal/withShowModal';// --------------- HOOKS --------------- //
|
|
43
9
|
export{useRoute}from"./hooks/useRoute";export{useTheme}from"./hooks/useTheme";export{useCurrentProduct}from"./hooks/useCurrentProduct";export{useNavigation}from"./hooks/useNavigation";export{usePageConfig}from"./hooks/usePageConfig";export{usePageSettings}from"./hooks/usePageSettings";export{useWidgetConfig}from"./hooks/useWidgetConfig";export{useWidgetSettings}from"./hooks/useWidgetSettings";export{useWidgetStyles}from"./hooks/useWidgetStyles";export*from"./hooks/html";// --------------- HOCs --------------- //
|
|
44
10
|
export{withTheme}from"./hocs/withTheme";export{withRoute}from"./hocs/withRoute";export{withCurrentProduct}from"./hocs/withCurrentProduct";export{withForwardedRef}from"./hocs/withForwardedRef";export{withNavigation}from"./hocs/withNavigation";export{withWidgetSettings}from"./hocs/withWidgetSettings";export{withWidgetStyles}from"./hocs/withWidgetStyles";export{withApp}from"./hocs/withApp";// --------------- CONFIG --------------- //
|
|
45
|
-
export{ThemeConfigResolver}from"./config/ThemeConfigResolver";export{isBeta}from"./config/isBeta";export{getThemeConfig}from"./config/getThemeConfig";export{getThemeSettings}from"./config/getThemeSettings";export{getThemeColors}from"./config/getThemeColors";export{getThemeAssets}from"./config/getThemeAssets";export{getPageConfig}from"./config/getPageConfig";export{getPageSettings}from"./config/getPageSettings";export{getWidgetConfig}from"./config/getWidgetConfig";export{getWidgetSettings}from"./config/getWidgetSettings"
|
|
46
|
-
export{i18n}from"./helpers/i18n";export{updateLegacyNavigationBar}from"./helpers/updateLegacyNavigationBar";export{getFullImageSource}from"./helpers/getFullImageSource";export*from"./initialization";export*from"./selectors";
|
|
11
|
+
export{ThemeConfigResolver}from"./config/ThemeConfigResolver";export{isBeta}from"./config/isBeta";export{getThemeConfig}from"./config/getThemeConfig";export{getThemeSettings}from"./config/getThemeSettings";export{getThemeColors}from"./config/getThemeColors";export{getThemeAssets}from"./config/getThemeAssets";export{getPageConfig}from"./config/getPageConfig";export{getPageSettings}from"./config/getPageSettings";export{getWidgetConfig}from"./config/getWidgetConfig";export{getWidgetSettings}from"./config/getWidgetSettings";export*from"./actions";export*from"./classes";export*from"./commands";export*from"./collections";export*from"./constants";export*from"./helpers";export*from"./initialization";export*from"./selectors";export*from"./streams";
|
|
@@ -1,7 +1,9 @@
|
|
|
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{appConfig}from'@shopgate/engage';import{i18n,configureStore,fetchClientInformation}from'@shopgate/engage/core';import{appInitialization}from'@shopgate/engage/core/collections';import{
|
|
1
|
+
import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{appWillInit,appWillStart}from'@shopgate/pwa-common/action-creators/app';import{appConfig}from'@shopgate/engage';import{i18n,configureStore,fetchClientInformation}from'@shopgate/engage/core';import{appInitialization,configuration}from'@shopgate/engage/core/collections';import{CONFIGURATION_COLLECTION_KEY_BASE_URL}from'@shopgate/engage/core/constants';import{getAppBaseUrl}from'@shopgate/engage/core/helpers';var _appConfig$locales=appConfig.locales;_appConfig$locales=_appConfig$locales===void 0?{}:_appConfig$locales;var _appConfig$locales$cu=_appConfig$locales.currency,currencyLocale=_appConfig$locales$cu===void 0?null:_appConfig$locales$cu;/**
|
|
2
2
|
*
|
|
3
3
|
* @param {Object} locales An object with locales.
|
|
4
4
|
* @param {Function} reducers The reducers from the theme.
|
|
5
5
|
* @param {Array} subscribers The subscribers to the streams middleware.
|
|
6
|
-
*/export var initialize=/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(locales,reducers,subscribers){var store;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:i18n.init({locales:locales,lang:process.env.LOCALE,currencyLocale:currencyLocale});store=configureStore(reducers,subscribers);_context.prev=2;_context.next=5;return store.dispatch(fetchClientInformation());case 5:_context.next=9;break;case 7:_context.prev=7;_context.t0=_context["catch"](2);case 9
|
|
7
|
-
|
|
6
|
+
*/export var initialize=/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(locales,reducers,subscribers){var store;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:i18n.init({locales:locales,lang:process.env.LOCALE,currencyLocale:currencyLocale});store=configureStore(reducers,subscribers);_context.prev=2;_context.next=5;return store.dispatch(fetchClientInformation());case 5:_context.next=9;break;case 7:_context.prev=7;_context.t0=_context["catch"](2);case 9:// Save the base url inside the configuration collection before any other code can apply
|
|
7
|
+
// url manipulations.
|
|
8
|
+
configuration.set(CONFIGURATION_COLLECTION_KEY_BASE_URL,getAppBaseUrl());store.dispatch(appWillInit("".concat(window.location.pathname).concat(window.location.search)));// Execute all registered handlers from the AppInitialization collection
|
|
9
|
+
_context.next=13;return appInitialization.initialize({dispatch:store.dispatch,getState:store.getState});case 13:store.dispatch(appWillStart("".concat(window.location.pathname).concat(window.location.search)));return _context.abrupt("return",{store:store});case 15:case"end":return _context.stop();}}},_callee,null,[[2,7]]);}));return function initialize(_x,_x2,_x3){return _ref.apply(this,arguments);};}();
|
package/core/selectors/index.js
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
export*from"./app"
|
|
1
|
+
export*from"./app";// --------------- CLIENT --------------- //
|
|
2
|
+
export*from'@shopgate/pwa-common/selectors/client';// --------------- ROUTER --------------- //
|
|
3
|
+
export*from'@shopgate/pwa-common/selectors/router';export*from'@shopgate/pwa-common/selectors/history';// --------------- URL --------------- //
|
|
4
|
+
export*from'@shopgate/pwa-common/selectors/url';// --------------- MENU --------------- //
|
|
5
|
+
export*from'@shopgate/pwa-common/selectors/menu';// --------------- MODAL --------------- //
|
|
6
|
+
export*from'@shopgate/pwa-common/selectors/modal';
|
|
@@ -0,0 +1,8 @@
|
|
|
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 _toArray(arr){return _arrayWithHoles(arr)||_iterableToArray(arr)||_unsupportedIterableToArray(arr)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArray(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter);}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import{Observable}from'rxjs/Observable';import{ACTION_RESET}from'@virtuous/conductor';import{main$}from'@shopgate/pwa-common/streams/main';import{routeDidEnter$}from'@shopgate/pwa-common/streams';import{routeDidEnter}from'@shopgate/pwa-common/action-creators';import{getRouterStack}from'@shopgate/engage/core/selectors';import{RELOAD_APP}from"../constants";import{historyReset}from"../actions";/**
|
|
2
|
+
* Gets triggered when the app is supposed to be reloaded
|
|
3
|
+
* @type {Observable}
|
|
4
|
+
*/export var reloadApp$=main$.filter(function(_ref){var action=_ref.action;return action.type===RELOAD_APP;}).switchMap(function(params){var dispatch=params.dispatch,getState=params.getState;var _getRouterStack=getRouterStack(getState()),_getRouterStack2=_toArray(_getRouterStack),initialRoute=_getRouterStack2[0],otherRoutes=_getRouterStack2.slice(1);if(!otherRoutes.length){// When the initial route is the only route inside the router stack, routeDidEnter$ will
|
|
5
|
+
// not always be triggered, so just simulate it here.
|
|
6
|
+
return Observable.of(_extends({},params,{action:routeDidEnter(initialRoute,ACTION_RESET)}));}// The PWA can't be reloaded on any route, so we first need to reset to the first history entry
|
|
7
|
+
dispatch(historyReset());return routeDidEnter$// Emit when initial route is reached
|
|
8
|
+
.filter(function(_ref2){var action=_ref2.action;return action.route.id===(initialRoute===null||initialRoute===void 0?void 0:initialRoute.id);});});
|
package/core/streams/index.js
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export*from"./appPermissions";
|
|
1
|
+
export*from"./app";export*from"./appPermissions";export*from'@shopgate/pwa-common/streams/main';export*from'@shopgate/pwa-common/streams/error';// --------------- APP --------------- //
|
|
2
|
+
export*from'@shopgate/pwa-common/streams/app';// --------------- CLIENT --------------- //
|
|
3
|
+
export*from'@shopgate/pwa-common/streams/client';// --------------- ROUTER --------------- //
|
|
4
|
+
export*from'@shopgate/pwa-common/streams/router';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{appWillStart$}from'@shopgate/pwa-common/streams';import{configuration}from'@shopgate/engage/core/collections';import{CONFIGURATION_COLLECTION_KEY_BASE_URL}from'@shopgate/engage/core/constants';import{reloadApp$}from"../streams";import{reloadApp}from"../action-creators";/**
|
|
2
|
+
* App subscriptions
|
|
3
|
+
* @param {Function} subscribe The subscribe function
|
|
4
|
+
*/export default function app(subscribe){subscribe(appWillStart$,function(_ref){var dispatch=_ref.dispatch;// Add global function to enable PWA reload from the console
|
|
5
|
+
window.reloadSGApp=function(){dispatch(reloadApp());};});subscribe(reloadApp$,function(){// A deployed app can only be reloaded on the base url. So we first set this as current route
|
|
6
|
+
// before the reload happens.
|
|
7
|
+
window.history.replaceState({},null,configuration.get(CONFIGURATION_COLLECTION_KEY_BASE_URL));window.location.reload();});}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/engage",
|
|
3
|
-
"version": "6.23.0-beta.
|
|
3
|
+
"version": "6.23.0-beta.2",
|
|
4
4
|
"description": "Shopgate's ENGAGE library.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Shopgate <support@shopgate.com>",
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"connect"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@shopgate/pwa-common": "6.23.0-beta.
|
|
19
|
-
"@shopgate/pwa-common-commerce": "6.23.0-beta.
|
|
20
|
-
"@shopgate/pwa-core": "6.23.0-beta.
|
|
21
|
-
"@shopgate/pwa-ui-ios": "6.23.0-beta.
|
|
22
|
-
"@shopgate/pwa-ui-material": "6.23.0-beta.
|
|
23
|
-
"@shopgate/pwa-ui-shared": "6.23.0-beta.
|
|
18
|
+
"@shopgate/pwa-common": "6.23.0-beta.2",
|
|
19
|
+
"@shopgate/pwa-common-commerce": "6.23.0-beta.2",
|
|
20
|
+
"@shopgate/pwa-core": "6.23.0-beta.2",
|
|
21
|
+
"@shopgate/pwa-ui-ios": "6.23.0-beta.2",
|
|
22
|
+
"@shopgate/pwa-ui-material": "6.23.0-beta.2",
|
|
23
|
+
"@shopgate/pwa-ui-shared": "6.23.0-beta.2",
|
|
24
24
|
"@virtuous/conductor": "~2.4.0",
|
|
25
25
|
"babel-plugin-transform-es3-member-expression-literals": "^6.8.0",
|
|
26
26
|
"babel-plugin-transform-es3-property-literals": "^6.8.0",
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"react-helmet": "^5.1.3",
|
|
32
32
|
"react-player": "1.11.0",
|
|
33
33
|
"react-portal": "^3.1.0",
|
|
34
|
-
"react-swipeable": "^4.0.1"
|
|
34
|
+
"react-swipeable": "^4.0.1",
|
|
35
|
+
"rxjs": "~5.5.12"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"classnames": "^2.2.6",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{PAGE_PATH,PAGE_PATTERN}from'@shopgate/pwa-common/constants/RoutePaths';export*from'@shopgate/pwa-common/constants/PageIDs';export{PAGE_PATH,PAGE_PATTERN};export var IMPRINT_PATH="".concat(PAGE_PATH,"/imprint");export var PAYMENT_PATH="".concat(PAGE_PATH,"/payment");export var PRIVACY_PATH="".concat(PAGE_PATH,"/privacy");export var RETURN_POLICY_PATH="".concat(PAGE_PATH,"/return_policy");export var SHIPPING_PATH="".concat(PAGE_PATH,"/shipping");export var TERMS_PATH="".concat(PAGE_PATH,"/terms");
|
package/page/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @module page */
|
|
1
|
+
/** @module page */ // ACTIONS
|
|
2
2
|
export{default as fetchPageConfig}from'@shopgate/pwa-common/actions/page/fetchPageConfig';// CONSTANTS
|
|
3
|
-
export*from
|
|
3
|
+
export*from"./constants";// SELECTORS
|
|
4
4
|
export*from'@shopgate/pwa-common/selectors/page';
|
|
@@ -7,4 +7,4 @@ if(!modalImageURL&&!modalImageSVG){return pushImage;}// URL overwrite configured
|
|
|
7
7
|
if(modalImageURL){return modalImageURL;}// SVG overwrite configured -> create data url
|
|
8
8
|
try{// Remove any characters outside the Latin1 range
|
|
9
9
|
var decoded=decodeURIComponent(encodeURIComponent(modalImageSVG));// Now we can use btoa to convert the svg to base64
|
|
10
|
-
var base64=btoa(decoded);return"data:image/svg+xml;base64,".concat(base64);}catch(e){return pushImage;}},[modalImageSVG,modalImageURL]);if(!isPushOptInModalVisible){return null;}return/*#__PURE__*/React.createElement(Modal,{isOpened:isPushOptInModalVisible,classes:{content:styles.modalContent}},/*#__PURE__*/React.createElement(Grid,{className:classNames(styles.container,'push-opt-in-modal__container')},/*#__PURE__*/React.createElement(Grid.Item,{className:styles.item},/*#__PURE__*/React.createElement("img",{src:imageSRC,className:classNames(styles.image,'push-opt-in-modal__image'),alt:"","aria-hidden":"true"}),/*#__PURE__*/React.createElement(I18n.Text,{className:classNames(styles.title,'push-opt-in-modal__title'),string:modalTitle||'pushOptInModal.title'}),/*#__PURE__*/React.createElement(I18n.Text,{className:classNames('push-opt-in-modal__message'),string:modalMessage||'pushOptInModal.message'}),/*#__PURE__*/React.createElement(Button,{onClick:allowPushOptIn,type:"primary",className:classNames(styles.button,'push-opt-in-modal__button-allow')},/*#__PURE__*/React.createElement(I18n.Text,{string:modalButtonAllow||'pushOptInModal.buttonAllow'})),/*#__PURE__*/React.createElement(Button,{onClick:denyPushOptIn,type:"plain",className:classNames(styles.button,'push-opt-in-modal__button-deny')},/*#__PURE__*/React.createElement(I18n.Text,{string:modalButtonDeny||'pushOptInModal.buttonDeny',className:styles.buttonText})))));};export default connect(PushOptInModal);
|
|
10
|
+
var base64=btoa(decoded);return"data:image/svg+xml;base64,".concat(base64);}catch(e){return pushImage;}},[modalImageSVG,modalImageURL]);if(!isPushOptInModalVisible){return null;}return/*#__PURE__*/React.createElement(Modal,{isOpened:isPushOptInModalVisible,classes:{content:styles.modalContent,layout:styles.modalLayout}},/*#__PURE__*/React.createElement(Grid,{className:classNames(styles.container,'push-opt-in-modal__container')},/*#__PURE__*/React.createElement(Grid.Item,{className:styles.item},/*#__PURE__*/React.createElement("img",{src:imageSRC,className:classNames(styles.image,'push-opt-in-modal__image'),alt:"","aria-hidden":"true"}),/*#__PURE__*/React.createElement(I18n.Text,{className:classNames(styles.title,'push-opt-in-modal__title'),string:modalTitle||'pushOptInModal.title'}),/*#__PURE__*/React.createElement(I18n.Text,{className:classNames('push-opt-in-modal__message'),string:modalMessage||'pushOptInModal.message'}),/*#__PURE__*/React.createElement(Button,{onClick:allowPushOptIn,type:"primary",className:classNames(styles.button,'push-opt-in-modal__button-allow')},/*#__PURE__*/React.createElement(I18n.Text,{string:modalButtonAllow||'pushOptInModal.buttonAllow'})),/*#__PURE__*/React.createElement(Button,{onClick:denyPushOptIn,type:"plain",className:classNames(styles.button,'push-opt-in-modal__button-deny')},/*#__PURE__*/React.createElement(I18n.Text,{string:modalButtonDeny||'pushOptInModal.buttonDeny',className:styles.buttonText})))));};export default connect(PushOptInModal);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{css}from'glamor';import{themeColors}from'@shopgate/pwa-common/helpers/config';var modalContent=css({width:'100%'}).toString();var container=css({backgroundColor:themeColors.lightOverlay,
|
|
1
|
+
import{css}from'glamor';import{themeColors}from'@shopgate/pwa-common/helpers/config';var modalContent=css({width:'100%'}).toString();var modalLayout=css({backgroundColor:themeColors.lightOverlay}).toString();var container=css({backgroundColor:themeColors.lightOverlay,textAlign:'center',padding:'30px',justifyContent:'center',display:'flex',flexDirection:'column'}).toString();var title=css({fontWeight:'bold',fontSize:'1.35rem',paddingTop:'30px',paddingBottom:'30px'}).toString();var item=css({display:'flex',flexDirection:'column',alignItems:'center'}).toString();var link=css({paddingTop:'30px',textAlign:'center',color:themeColors.gray}).toString();var image=css({width:'80%',maxWidth:400}).toString();var button=css({marginTop:'30px'}).toString();var buttonText=css({color:themeColors.gray}).toString();export default{modalContent:modalContent,modalLayout:modalLayout,container:container,item:item,title:title,link:link,image:image,button:button,buttonText:buttonText};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _regeneratorRuntime from"@babel/runtime/regenerator";function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_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$,event,
|
|
1
|
+
import _regeneratorRuntime from"@babel/runtime/regenerator";function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_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$,event,logger}from'@shopgate/engage/core';import{appSupportsPushOptIn}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;});/**
|
|
2
2
|
* Push opt in subscriptions
|
|
3
3
|
* @param {Function} subscribe The subscribe function
|
|
4
4
|
*/export default function pushOptIn(subscribe){/**
|
|
@@ -8,5 +8,5 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function _typeof(obj
|
|
|
8
8
|
* @returns {void}
|
|
9
9
|
*/var showOptInAfterChecks=/*#__PURE__*/function(){var _ref3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref2,configKey,increaseCountAction){var dispatch,getState,_appConfig$pushOptIn,appStarts,ordersPlaced,rejectionMaxCount,minDaysBetweenOptIns,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$pushOptIn=_appConfig$pushOptIn===void 0?{}:_appConfig$pushOptIn;appStarts=_appConfig$pushOptIn.appStarts,ordersPlaced=_appConfig$pushOptIn.ordersPlaced,rejectionMaxCount=_appConfig$pushOptIn.rejectionMaxCount,minDaysBetweenOptIns=_appConfig$pushOptIn.minDaysBetweenOptIns;// Deactivate feature when config is invalid
|
|
10
10
|
if(!(typeof minDaysBetweenOptIns!=='number'||typeof rejectionMaxCount!=='number'||_typeof(ordersPlaced)!=='object'||_typeof(appStarts)!=='object')){_context.next=9;break;}logger.error('PushOptInTrigger - Config invalid',appConfig===null||appConfig===void 0?void 0:appConfig.pushOptIn);return _context.abrupt("return");case 9:_context.next=11;return dispatch(requestAppPermissionStatus({permissionId:PERMISSION_ID_PUSH}));case 11:pushStatus=_context.sent;if(!(pushStatus!==PERMISSION_STATUS_NOT_DETERMINED)){_context.next=14;break;}return _context.abrupt("return");case 14: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=23;break;}return _context.abrupt("return");case 23: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 27: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
|
-
subscribe(
|
|
12
|
-
subscribe(
|
|
11
|
+
subscribe(cookieConsentInitialized$,/*#__PURE__*/function(){var _ref5=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref4){var dispatch,getState;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:dispatch=_ref4.dispatch,getState=_ref4.getState;_context2.next=3;return showOptInAfterChecks({dispatch:dispatch,getState:getState},'appStarts',increaseAppStartCount);case 3:case"end":return _context2.stop();}}},_callee2);}));return function(_x4){return _ref5.apply(this,arguments);};}());// event subscriber to handle order based push opt in
|
|
12
|
+
subscribe(cookieConsentInitialized$,function(_ref6){var dispatch=_ref6.dispatch,getState=_ref6.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(_ref8){var dispatch=_ref8.dispatch;dispatch(increaseRejectionCount());});}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import{UPDATE_COOKIE_CONSENT,COOKIE_CONSENT_HANDLED,HIDE_COOKIE_CONSENT_MODAL,SHOW_COOKIE_CONSENT_MODAL}from"../constants";/**
|
|
2
|
+
* action to be dispatched when the cookie consent modal should be shown
|
|
3
|
+
* @returns {Function}
|
|
4
|
+
*/export var showCookieConsentModal=function showCookieConsentModal(){return{type:SHOW_COOKIE_CONSENT_MODAL};};/**
|
|
5
|
+
* action to be dispatched when the cookie consent modal should be hidden
|
|
6
|
+
* @returns {Function}
|
|
7
|
+
*/export var hideCookieConsentModal=function hideCookieConsentModal(){return{type:HIDE_COOKIE_CONSENT_MODAL};};/**
|
|
8
|
+
* action to be dispatched when the user accepted the selected cookies in the custom modal
|
|
9
|
+
* @param {Object} params Action params
|
|
10
|
+
* @param {boolean} [params.comfortCookiesAccepted=false] whether this cookie type was accepted
|
|
11
|
+
* by user
|
|
12
|
+
* @param {boolean} [params.statisticsCookiesAccepted=false] whether this cookie type was accepted
|
|
13
|
+
* by user
|
|
14
|
+
* @returns {Function}
|
|
15
|
+
*/export var updateCookieConsent=function updateCookieConsent(_ref){var _ref$comfortCookiesAc=_ref.comfortCookiesAccepted,comfortCookiesAccepted=_ref$comfortCookiesAc===void 0?false:_ref$comfortCookiesAc,_ref$statisticsCookie=_ref.statisticsCookiesAccepted,statisticsCookiesAccepted=_ref$statisticsCookie===void 0?false:_ref$statisticsCookie;return{type:UPDATE_COOKIE_CONSENT,comfortCookiesAccepted:comfortCookiesAccepted,statisticsCookiesAccepted:statisticsCookiesAccepted};};/**
|
|
16
|
+
* action to be dispatched when the cookies have been handled either by user or by merchant
|
|
17
|
+
* and native modal should be triggered for setting the permission
|
|
18
|
+
* @param {Object} params Action params
|
|
19
|
+
* @param {boolean} [params.comfortCookiesAccepted=false] whether this cookie type was accepted
|
|
20
|
+
* by user
|
|
21
|
+
* @param {boolean} [params.statisticsCookiesAccepted=false] whether this cookie type was accepted
|
|
22
|
+
* by user
|
|
23
|
+
* @returns {Function}
|
|
24
|
+
*/export var handleCookieConsent=function handleCookieConsent(_ref2){var _ref2$comfortCookiesA=_ref2.comfortCookiesAccepted,comfortCookiesAccepted=_ref2$comfortCookiesA===void 0?false:_ref2$comfortCookiesA,_ref2$statisticsCooki=_ref2.statisticsCookiesAccepted,statisticsCookiesAccepted=_ref2$statisticsCooki===void 0?false:_ref2$statisticsCooki;return{type:COOKIE_CONSENT_HANDLED,comfortCookiesAccepted:comfortCookiesAccepted,statisticsCookiesAccepted:statisticsCookiesAccepted};};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./cookieConsent";
|
|
@@ -0,0 +1,21 @@
|
|
|
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";/**
|
|
2
|
+
* action to be dispatched when the user accepted all cookies in the custom modal
|
|
3
|
+
* and native modal should be triggered for setting the permission
|
|
4
|
+
* @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=2;return dispatch(grantAppTrackingTransparencyPermission());case 2:dispatch(updateCookieConsent({comfortCookiesAccepted:true,statisticsCookiesAccepted:true}));dispatch(hideCookieConsentModal());dispatch(historyPush({pathname:'/'}));case 5:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref.apply(this,arguments);};}();};/**
|
|
6
|
+
* action to be dispatched when the user accepted the selected cookies in the custom modal
|
|
7
|
+
* and native modal should be triggered for setting the permission
|
|
8
|
+
* @param {Object} params Action params
|
|
9
|
+
* @param {boolean|null} params.comfortCookiesAccepted whether this cookie type was accepted
|
|
10
|
+
* by user
|
|
11
|
+
* @param {boolean|null} params.statisticsCookiesAccepted whether this cookie type was accepted
|
|
12
|
+
* by user
|
|
13
|
+
* @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=3;break;}_context2.next=3;return dispatch(grantAppTrackingTransparencyPermission());case 3:dispatch(updateCookieConsent({comfortCookiesAccepted:comfortCookiesAccepted,statisticsCookiesAccepted:statisticsCookiesAccepted}));dispatch(hideCookieConsentModal());dispatch(historyPush({pathname:'/'}));case 6:case"end":return _context2.stop();}}},_callee2);}));return function(_x2){return _ref3.apply(this,arguments);};}();};/**
|
|
15
|
+
* action to be dispatched when the user selected only the required cookies in the custom modal
|
|
16
|
+
* and native modal should be triggered for setting the permission
|
|
17
|
+
* @returns {Function}
|
|
18
|
+
*/export var acceptRequiredCookies=function acceptRequiredCookies(){return function(dispatch){dispatch(updateCookieConsent({comfortCookiesAccepted:false,statisticsCookiesAccepted:false}));dispatch(hideCookieConsentModal());};};/**
|
|
19
|
+
* action to be dispatched when the user opted to configure cookie settings in the custom modal
|
|
20
|
+
* @returns {Function}
|
|
21
|
+
*/export var openPrivacySettings=function openPrivacySettings(){return function(dispatch){dispatch(historyPush({pathname:PRIVACY_SETTINGS_PATTERN}));dispatch(hideCookieConsentModal());};};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./cookieConsent";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{connect}from'react-redux';import{getIsCookieConsentModalVisible}from"../../selectors/cookieConsent";import{acceptAllCookies,acceptRequiredCookies,openPrivacySettings}from"../../actions";/**
|
|
2
|
+
* Maps the contents of the state to the component props.
|
|
3
|
+
* @param {Object} state The current application state.
|
|
4
|
+
* @return {Object} The extended component props.
|
|
5
|
+
*/var mapStateToProps=function mapStateToProps(state){return{isCookieConsentModalVisible:getIsCookieConsentModalVisible(state)};};/**
|
|
6
|
+
* Connects the dispatch function to a callable function in the props.
|
|
7
|
+
* @return {Object} The extended component props.
|
|
8
|
+
*/var mapDispatchToProps={acceptAllCookies:acceptAllCookies,acceptRequiredCookies:acceptRequiredCookies,openPrivacySettings:openPrivacySettings};export default connect(mapStateToProps,mapDispatchToProps);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
3
|
+
<svg width="100%" height="100%" viewBox="0 0 1107 791" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
|
4
|
+
<g transform="matrix(1,0,0,1,-88.9596,-502.577)">
|
|
5
|
+
<g transform="matrix(1.28381,0,0,1.28381,-145.009,-328.293)">
|
|
6
|
+
<g>
|
|
7
|
+
<g transform="matrix(0.738616,0,0,0.7166,142.625,351.19)">
|
|
8
|
+
<path d="M1052.9,1091.68C1052.9,1062.46 1029.88,1038.73 1001.53,1038.73L244.024,1038.73C215.667,1038.73 192.646,1062.46 192.646,1091.68L192.646,1219.08C192.646,1248.3 215.667,1272.03 244.024,1272.03L1001.53,1272.03C1029.88,1272.03 1052.9,1248.3 1052.9,1219.08L1052.9,1091.68Z" style="fill:rgb(193,193,193);"/>
|
|
9
|
+
</g>
|
|
10
|
+
<g transform="matrix(0.859568,0,0,0.833947,80.1965,145.713)">
|
|
11
|
+
<path d="M1052.9,1091.68C1052.9,1062.46 1029.88,1038.73 1001.53,1038.73L244.024,1038.73C215.667,1038.73 192.646,1062.46 192.646,1091.68L192.646,1219.08C192.646,1248.3 215.667,1272.03 244.024,1272.03L1001.53,1272.03C1029.88,1272.03 1052.9,1248.3 1052.9,1219.08L1052.9,1091.68Z" style="fill:rgb(216,216,216);"/>
|
|
12
|
+
</g>
|
|
13
|
+
<g transform="matrix(1.00203,0,0,0.972164,-10.791,-90.8989)">
|
|
14
|
+
<path d="M1052.9,1091.68C1052.9,1062.46 1029.88,1038.73 1001.53,1038.73L244.024,1038.73C215.667,1038.73 192.646,1062.46 192.646,1091.68L192.646,1219.08C192.646,1248.3 215.667,1272.03 244.024,1272.03L1001.53,1272.03C1029.88,1272.03 1052.9,1248.3 1052.9,1219.08L1052.9,1091.68Z" style="fill:rgb(235,235,235);"/>
|
|
15
|
+
</g>
|
|
16
|
+
<g transform="matrix(1.00203,0,0,0.972164,-10.791,-362.62)">
|
|
17
|
+
<path d="M1052.9,1091.68C1052.9,1062.46 1029.88,1038.73 1001.53,1038.73L244.024,1038.73C215.667,1038.73 192.646,1062.46 192.646,1091.68L192.646,1219.08C192.646,1248.3 215.667,1272.03 244.024,1272.03L1001.53,1272.03C1029.88,1272.03 1052.9,1248.3 1052.9,1219.08L1052.9,1091.68Z" style="fill:rgb(235,235,235);"/>
|
|
18
|
+
</g>
|
|
19
|
+
</g>
|
|
20
|
+
<g transform="matrix(1.00052,0,0,1,-19.3912,30.3377)">
|
|
21
|
+
<path d="M953.776,1037.91C953.776,1035.43 951.762,1033.42 949.281,1033.42L424.519,1033.42C422.039,1033.42 420.025,1035.43 420.025,1037.91L420.025,1061.27C420.025,1063.75 422.039,1065.77 424.519,1065.77L949.281,1065.77C951.762,1065.77 953.776,1063.75 953.776,1061.27L953.776,1037.91Z" style="fill:rgb(187,196,198);fill-opacity:0.65;"/>
|
|
22
|
+
</g>
|
|
23
|
+
<g transform="matrix(0.823791,0,0,1,54.8392,-16.3916)">
|
|
24
|
+
<path d="M953.776,1037.91C953.776,1035.43 951.33,1033.42 948.317,1033.42L425.484,1033.42C422.471,1033.42 420.025,1035.43 420.025,1037.91L420.025,1061.27C420.025,1063.75 422.471,1065.77 425.484,1065.77L948.317,1065.77C951.33,1065.77 953.776,1063.75 953.776,1061.27L953.776,1037.91Z" style="fill:rgb(187,196,198);fill-opacity:0.65;"/>
|
|
25
|
+
</g>
|
|
26
|
+
<g transform="matrix(0.904048,0,0,1,21.129,-67.1309)">
|
|
27
|
+
<path d="M953.776,1037.91C953.776,1035.43 951.547,1033.42 948.801,1033.42L424.999,1033.42C422.254,1033.42 420.025,1035.43 420.025,1037.91L420.025,1061.27C420.025,1063.75 422.254,1065.77 424.999,1065.77L948.801,1065.77C951.547,1065.77 953.776,1063.75 953.776,1061.27L953.776,1037.91Z" style="fill:rgb(187,196,198);fill-opacity:0.65;"/>
|
|
28
|
+
</g>
|
|
29
|
+
<g transform="matrix(1.02071,0,0,1.04641,-38.8586,-763.331)">
|
|
30
|
+
<path d="M393.702,1679.71C393.702,1660.56 377.767,1645.02 358.141,1645.02L287.019,1645.02C267.393,1645.02 251.458,1660.56 251.458,1679.71L251.458,1749.29C251.458,1768.44 267.393,1783.98 287.019,1783.98L358.141,1783.98C377.767,1783.98 393.702,1768.44 393.702,1749.29L393.702,1679.71Z" style="fill:rgb(255,115,115);"/>
|
|
31
|
+
<clipPath id="_clip1">
|
|
32
|
+
<path d="M393.702,1679.71C393.702,1660.56 377.767,1645.02 358.141,1645.02L287.019,1645.02C267.393,1645.02 251.458,1660.56 251.458,1679.71L251.458,1749.29C251.458,1768.44 267.393,1783.98 287.019,1783.98L358.141,1783.98C377.767,1783.98 393.702,1768.44 393.702,1749.29L393.702,1679.71Z"/>
|
|
33
|
+
</clipPath>
|
|
34
|
+
<g clip-path="url(#_clip1)">
|
|
35
|
+
<g transform="matrix(0.76313,0,0,0.744387,148.731,1102.32)">
|
|
36
|
+
<path d="M226.411,745.537L243.421,797.888L298.467,797.888L253.934,830.243L270.944,882.594L226.411,850.239L181.879,882.594L198.889,830.243L154.356,797.888L209.402,797.888L226.411,745.537Z" style="fill:white;"/>
|
|
37
|
+
</g>
|
|
38
|
+
</g>
|
|
39
|
+
</g>
|
|
40
|
+
<g transform="matrix(0.933678,0,0,1,8.6838,-241.981)">
|
|
41
|
+
<path d="M953.776,1037.91C953.776,1035.43 951.617,1033.42 948.959,1033.42L424.841,1033.42C422.183,1033.42 420.025,1035.43 420.025,1037.91L420.025,1061.27C420.025,1063.75 422.183,1065.77 424.841,1065.77L948.959,1065.77C951.617,1065.77 953.776,1063.75 953.776,1061.27L953.776,1037.91Z" style="fill:rgb(187,196,198);fill-opacity:0.65;"/>
|
|
42
|
+
</g>
|
|
43
|
+
<g transform="matrix(1,0,0,1,-19.173,-288.71)">
|
|
44
|
+
<path d="M953.776,1037.91C953.776,1035.43 951.761,1033.42 949.279,1033.42L424.522,1033.42C422.04,1033.42 420.025,1035.43 420.025,1037.91L420.025,1061.27C420.025,1063.75 422.04,1065.77 424.522,1065.77L949.279,1065.77C951.761,1065.77 953.776,1063.75 953.776,1061.27L953.776,1037.91Z" style="fill:rgb(187,196,198);fill-opacity:0.65;"/>
|
|
45
|
+
</g>
|
|
46
|
+
<g transform="matrix(0.844941,0,0,1,45.9556,-337.889)">
|
|
47
|
+
<path d="M953.776,1037.91C953.776,1035.43 951.391,1033.42 948.453,1033.42L425.347,1033.42C422.409,1033.42 420.025,1035.43 420.025,1037.91L420.025,1061.27C420.025,1063.75 422.409,1065.77 425.347,1065.77L948.453,1065.77C951.391,1065.77 953.776,1063.75 953.776,1061.27L953.776,1037.91Z" style="fill:rgb(187,196,198);fill-opacity:0.65;"/>
|
|
48
|
+
</g>
|
|
49
|
+
<g transform="matrix(1.02071,0,0,1.04641,-38.8586,-1035.65)">
|
|
50
|
+
<path d="M393.702,1679.71C393.702,1660.56 377.767,1645.02 358.141,1645.02L287.019,1645.02C267.393,1645.02 251.458,1660.56 251.458,1679.71L251.458,1749.29C251.458,1768.44 267.393,1783.98 287.019,1783.98L358.141,1783.98C377.767,1783.98 393.702,1768.44 393.702,1749.29L393.702,1679.71Z" style="fill:rgb(255,115,115);"/>
|
|
51
|
+
<clipPath id="_clip2">
|
|
52
|
+
<path d="M393.702,1679.71C393.702,1660.56 377.767,1645.02 358.141,1645.02L287.019,1645.02C267.393,1645.02 251.458,1660.56 251.458,1679.71L251.458,1749.29C251.458,1768.44 267.393,1783.98 287.019,1783.98L358.141,1783.98C377.767,1783.98 393.702,1768.44 393.702,1749.29L393.702,1679.71Z"/>
|
|
53
|
+
</clipPath>
|
|
54
|
+
<g clip-path="url(#_clip2)">
|
|
55
|
+
<g transform="matrix(0.979712,0,0,0.955649,69.3286,762.785)">
|
|
56
|
+
<text x="193.673px" y="1041.62px" style="font-family:'HelveticaNeue-Bold', 'Helvetica Neue';font-weight:700;font-size:128px;fill:white;">%</text>
|
|
57
|
+
</g>
|
|
58
|
+
</g>
|
|
59
|
+
</g>
|
|
60
|
+
</g>
|
|
61
|
+
</g>
|
|
62
|
+
</svg>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React,{useMemo}from'react';import PropTypes from'prop-types';import{Grid,I18n,Button,Modal,Link}from'@shopgate/engage/components';import{appConfig}from'@shopgate/engage';import{PRIVACY_PATH}from'@shopgate/engage/page';import classNames from'classnames';import connect from"./connector";import cookieImage from"./cookieConsent.svg";import styles from"./style";/**
|
|
2
|
+
* The cookie consent modal component.
|
|
3
|
+
* @param {Object} props The component props.
|
|
4
|
+
* @returns {JSX.Element}
|
|
5
|
+
*/var CookieConsentModal=function CookieConsentModal(_ref){var isCookieConsentModalVisible=_ref.isCookieConsentModalVisible,acceptAllCookies=_ref.acceptAllCookies,acceptRequiredCookies=_ref.acceptRequiredCookies,openPrivacySettings=_ref.openPrivacySettings;var _appConfig$cookieCons=appConfig.cookieConsent;_appConfig$cookieCons=_appConfig$cookieCons===void 0?{}:_appConfig$cookieCons;var modalMessage=_appConfig$cookieCons.modalMessage,modalTitle=_appConfig$cookieCons.modalTitle,modalButtonConfigureSettings=_appConfig$cookieCons.modalButtonConfigureSettings,modalButtonOnlyRequired=_appConfig$cookieCons.modalButtonOnlyRequired,modalButtonAcceptAll=_appConfig$cookieCons.modalButtonAcceptAll,modalImageURL=_appConfig$cookieCons.modalImageURL,modalImageSVG=_appConfig$cookieCons.modalImageSVG,showRequiredCookiesButton=_appConfig$cookieCons.showRequiredCookiesButton;var imageSRC=useMemo(function(){// if no overwrite configured: use default image
|
|
6
|
+
if(!modalImageURL&&!modalImageSVG){return cookieImage;}// if URL overwrite configured: use it
|
|
7
|
+
if(modalImageURL){return modalImageURL;}// if SVG overwrite configured: create data url
|
|
8
|
+
try{// Remove any characters outside the Latin1 range
|
|
9
|
+
var decoded=decodeURIComponent(encodeURIComponent(modalImageSVG));// Now we can use btoa to convert the svg to base64
|
|
10
|
+
var base64=btoa(decoded);return"data:image/svg+xml;base64,".concat(base64);}catch(e){return cookieImage;}},[modalImageSVG,modalImageURL]);if(!isCookieConsentModalVisible){return null;}return/*#__PURE__*/React.createElement(Modal,{isOpened:isCookieConsentModalVisible,classes:{content:styles.modalContent,layout:styles.modalLayout}},/*#__PURE__*/React.createElement(Grid,{component:"div",className:classNames(styles.container,'cookie-consent-modal__container')},/*#__PURE__*/React.createElement(Grid.Item,{component:"div",className:styles.item},/*#__PURE__*/React.createElement("img",{src:imageSRC,className:classNames(styles.image,'cookie-consent-modal__image'),alt:"","aria-hidden":"true"}),/*#__PURE__*/React.createElement(I18n.Text,{className:classNames(styles.title,'cookie-consent-modal__title'),string:modalTitle||'cookieConsentModal.title'}),/*#__PURE__*/React.createElement(I18n.Text,{string:modalMessage||'cookieConsentModal.message',className:classNames('cookie-consent-modal__message'),acceptPlainTextWithPlaceholders:true},/*#__PURE__*/React.createElement(I18n.Placeholder,{forKey:"privacyLink"},/*#__PURE__*/React.createElement(Link,{href:PRIVACY_PATH,tag:"span"},/*#__PURE__*/React.createElement(I18n.Text,{string:"cookieConsentModal.privacyText",className:styles.link})))),/*#__PURE__*/React.createElement(Grid.Item,{component:"div",className:styles.buttonWrapper},/*#__PURE__*/React.createElement(Button,{onClick:acceptAllCookies,type:"primary",className:classNames(styles.button,'cookie-consent-modal__button-accept-all')},/*#__PURE__*/React.createElement(I18n.Text,{string:modalButtonAcceptAll||'cookieConsentModal.buttonAcceptAll'})),showRequiredCookiesButton?/*#__PURE__*/React.createElement(Button,{onClick:acceptRequiredCookies,type:"simple",className:classNames(styles.button,'cookie-consent-modal__button-accept-required')},/*#__PURE__*/React.createElement(I18n.Text,{string:modalButtonOnlyRequired||'cookieConsentModal.modalButtonOnlyRequired'})):null,/*#__PURE__*/React.createElement(Button,{onClick:openPrivacySettings,type:"simple",className:classNames(styles.button,'cookie-consent-modal__button-open-settings')},/*#__PURE__*/React.createElement(I18n.Text,{string:modalButtonConfigureSettings||'cookieConsentModal.buttonConfigure'}))))));};export default connect(CookieConsentModal);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{css}from'glamor';import{themeColors}from'@shopgate/pwa-common/helpers/config';var modalContent=css({width:'100%'}).toString();var modalLayout=css({backgroundColor:themeColors.lightOverlay}).toString();var container=css({backgroundColor:themeColors.lightOverlay,padding:'30px',justifyContent:'center',display:'flex',flexDirection:'column',textAlign:'center'}).toString();var title=css({fontWeight:'bold',fontSize:'1.35rem',paddingTop:'30px',paddingBottom:'30px'}).toString();var item=css({display:'flex',flexDirection:'column',alignItems:'center'}).toString();var link=css({color:themeColors.accent,textDecoration:'underline'}).toString();var image=css({width:'60%',maxWidth:400}).toString();var button=css({marginTop:'20px'}).toString();var buttonText=css({color:themeColors.gray}).toString();var buttonWrapper=css({display:'flex',flexDirection:'column',marginBottom:'30px',width:'100%'}).toString();export default{modalContent:modalContent,modalLayout:modalLayout,container:container,item:item,title:title,link:link,image:image,button:button,buttonText:buttonText,buttonWrapper:buttonWrapper};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{connect}from'react-redux';import{acceptAllCookies,acceptSelectedCookies}from"../../actions";import{getAreComfortCookiesAccepted,getAreStatisticsCookiesAccepted}from"../../selectors/cookieConsent";/**
|
|
2
|
+
* Maps the contents of the state to the component props.
|
|
3
|
+
* @param {Object} state The current application state.
|
|
4
|
+
* @return {Object} The extended component props.
|
|
5
|
+
*/var mapStateToProps=function mapStateToProps(state){return{comfortCookiesAcceptedState:getAreComfortCookiesAccepted(state),statisticsCookiesAcceptedState:getAreStatisticsCookiesAccepted(state)};};/**
|
|
6
|
+
* Connects the dispatch function to a callable function in the props.
|
|
7
|
+
* @return {Object} The extended component props.
|
|
8
|
+
*/var mapDispatchToProps={acceptAllCookies:acceptAllCookies,acceptSelectedCookies:acceptSelectedCookies};export default connect(mapStateToProps,mapDispatchToProps);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_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 React,{useCallback,useState}from'react';import{Button,Grid,I18n,Link,Switch}from'@shopgate/engage/components';import PropTypes from'prop-types';import{PRIVACY_PATH}from'@shopgate/engage/page';import{appConfig}from'@shopgate/engage';import classNames from'classnames';import styles from"./style";import connect from"./connector";/**
|
|
2
|
+
* The PrivacySettings component.
|
|
3
|
+
* @returns {JSX.Element}
|
|
4
|
+
*/var PrivacySettings=function PrivacySettings(_ref){var acceptAllCookies=_ref.acceptAllCookies,acceptSelectedCookies=_ref.acceptSelectedCookies,comfortCookiesAcceptedState=_ref.comfortCookiesAcceptedState,statisticsCookiesAcceptedState=_ref.statisticsCookiesAcceptedState;var _appConfig$cookieCons=appConfig.cookieConsent;_appConfig$cookieCons=_appConfig$cookieCons===void 0?{}:_appConfig$cookieCons;var settingsComfortText=_appConfig$cookieCons.settingsComfortText,settingsComfortTitle=_appConfig$cookieCons.settingsComfortTitle,settingsStatisticsText=_appConfig$cookieCons.settingsStatisticsText,settingsStatisticsTitle=_appConfig$cookieCons.settingsStatisticsTitle,settingsRequiredText=_appConfig$cookieCons.settingsRequiredText,settingsRequiredTitle=_appConfig$cookieCons.settingsRequiredTitle;var _useState=useState(comfortCookiesAcceptedState!==null?comfortCookiesAcceptedState:false),_useState2=_slicedToArray(_useState,2),areComfortCookiesSelected=_useState2[0],setAreComfortCookiesSelected=_useState2[1];var _useState3=useState(statisticsCookiesAcceptedState!==null?statisticsCookiesAcceptedState:false),_useState4=_slicedToArray(_useState3,2),areStatisticsCookiesSelected=_useState4[0],setAreStatisticsCookiesSelected=_useState4[1];var handleChangeComfortCookies=useCallback(function(){setAreComfortCookiesSelected(!areComfortCookiesSelected);},[areComfortCookiesSelected]);var handleChangeStatisticsCookies=useCallback(function(){setAreStatisticsCookiesSelected(!areStatisticsCookiesSelected);},[areStatisticsCookiesSelected]);var handleAcceptAllCookies=useCallback(function(){setAreStatisticsCookiesSelected(true);setAreComfortCookiesSelected(true);acceptAllCookies();},[acceptAllCookies]);return/*#__PURE__*/React.createElement(Grid,{component:"div",className:styles.container},/*#__PURE__*/React.createElement(Grid.Item,{component:"div",className:styles.item},/*#__PURE__*/React.createElement(Grid.Item,{component:"div",className:styles.switchWrapper},/*#__PURE__*/React.createElement("div",null,/*#__PURE__*/React.createElement("span",{className:styles.title},/*#__PURE__*/React.createElement(I18n.Text,{string:settingsComfortTitle||'cookieSettings.comfortTitle'})),/*#__PURE__*/React.createElement("span",null,/*#__PURE__*/React.createElement(I18n.Text,{string:settingsComfortText||'cookieSettings.comfort'}))),/*#__PURE__*/React.createElement(Switch,{onChange:handleChangeComfortCookies,checked:areComfortCookiesSelected})),/*#__PURE__*/React.createElement(Grid.Item,{component:"div",className:styles.switchWrapper},/*#__PURE__*/React.createElement("div",null,/*#__PURE__*/React.createElement("span",{className:styles.title},/*#__PURE__*/React.createElement(I18n.Text,{string:settingsStatisticsTitle||'cookieSettings.statisticsTitle'})),/*#__PURE__*/React.createElement("span",null,/*#__PURE__*/React.createElement(I18n.Text,{string:settingsStatisticsText||'cookieSettings.statistics'}))),/*#__PURE__*/React.createElement(Switch,{onChange:handleChangeStatisticsCookies,checked:areStatisticsCookiesSelected})),/*#__PURE__*/React.createElement(Grid.Item,{component:"div",className:styles.switchWrapper},/*#__PURE__*/React.createElement("div",null,/*#__PURE__*/React.createElement("span",{className:styles.title},/*#__PURE__*/React.createElement(I18n.Text,{string:settingsRequiredTitle||'cookieSettings.requiredTitle'})),/*#__PURE__*/React.createElement("span",null,/*#__PURE__*/React.createElement(I18n.Text,{string:settingsRequiredText||'cookieSettings.required'}))),/*#__PURE__*/React.createElement(Switch,{disabled:true,checked:true}))),/*#__PURE__*/React.createElement(Grid.Item,{component:"div",className:styles.buttonWrapper},/*#__PURE__*/React.createElement(Button,{onClick:function onClick(){return handleAcceptAllCookies();},type:"primary",className:classNames(styles.button,'privacy-settings__button-accept-all')},/*#__PURE__*/React.createElement(I18n.Text,{string:"cookieConsentModal.buttonAcceptAll"})),/*#__PURE__*/React.createElement(Button,{onClick:function onClick(){return acceptSelectedCookies({comfortCookiesAccepted:areComfortCookiesSelected,statisticsCookiesAccepted:areStatisticsCookiesSelected});},type:"simple",className:classNames(styles.button,'privacy-settings__button-accept-selected')},/*#__PURE__*/React.createElement(I18n.Text,{string:"cookieConsentModal.modalButtonConfirmSelected"}))),/*#__PURE__*/React.createElement(Grid.Item,{component:"div"},/*#__PURE__*/React.createElement(I18n.Text,{string:"cookieSettings.privacy"},/*#__PURE__*/React.createElement(I18n.Placeholder,{forKey:"privacyLink"},/*#__PURE__*/React.createElement(Link,{href:PRIVACY_PATH,tag:"span"},/*#__PURE__*/React.createElement(I18n.Text,{string:"cookieConsentModal.privacyText",className:styles.link}))))));};PrivacySettings.defaultProps={comfortCookiesAcceptedState:null,statisticsCookiesAcceptedState:null};export default connect(PrivacySettings);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{css}from'glamor';import{themeColors}from'@shopgate/pwa-common/helpers/config';var button=css({marginTop:'20px'}).toString();var container=css({flexDirection:'column',height:'100vh',textAlign:'center',padding:'30px',justifyContent:'center',display:'flex'}).toString();var buttonWrapper=css({display:'flex',flexDirection:'column',marginBottom:'30px'}).toString();var item=css({display:'flex',flexDirection:'column'}).toString();var link=css({color:themeColors.accent,textDecoration:'underline'}).toString();var switchWrapper=css({marginBottom:'25px',display:'flex',textAlign:'left',justifyContent:'space-between'}).toString();var title=css({fontWeight:'bold',display:'block',marginRight:'32px'});export default{button:button,container:container,buttonWrapper:buttonWrapper,link:link,item:item,switchWrapper:switchWrapper,title:title};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{default as CookieConsentModal}from"./CookieConsentModal";export{default as PrivacySettings}from"./PrivacySettings";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var SHOW_COOKIE_CONSENT_MODAL='SHOW_COOKIE_CONSENT_MODAL';export var HIDE_COOKIE_CONSENT_MODAL='HIDE_COOKIE_CONSENT_MODAL';export var UPDATE_COOKIE_CONSENT='UPDATE_COOKIE_CONSENT';export var COOKIE_CONSENT_HANDLED='COOKIE_CONSENT_HANDLED';export var PRIVACY_SETTINGS_PATTERN='/privacy-settings';
|
|
@@ -0,0 +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_COOKIE_CONSENT_MODAL,SHOW_COOKIE_CONSENT_MODAL}from"../constants";var defaultState={isCookieConsentModalVisible:false};/**
|
|
2
|
+
* Stores all states of the cookie consent modal.
|
|
3
|
+
* @param {Object} [state] The current state.
|
|
4
|
+
* @param {Object} action The action object.
|
|
5
|
+
* @return {Object} The new state.
|
|
6
|
+
*/var cookieConsentModalReducer=function cookieConsentModalReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:defaultState;var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case SHOW_COOKIE_CONSENT_MODAL:{return _extends({},state,{isCookieConsentModalVisible:true});}case HIDE_COOKIE_CONSENT_MODAL:{return _extends({},state,{isCookieConsentModalVisible:false});}default:return state;}};export default cookieConsentModalReducer;
|
|
@@ -0,0 +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{UPDATE_COOKIE_CONSENT}from"../constants";var defaultState={comfortCookiesAccepted:null,statisticsCookiesAccepted:null};/**
|
|
2
|
+
* Stores all states of the cookie settings.
|
|
3
|
+
* @param {Object} [state] The current state.
|
|
4
|
+
* @param {Object} action The action object.
|
|
5
|
+
* @return {Object} The new state.
|
|
6
|
+
*/var cookieSettingsReducer=function cookieSettingsReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:defaultState;var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case UPDATE_COOKIE_CONSENT:{return _extends({},state,{comfortCookiesAccepted:action.comfortCookiesAccepted,statisticsCookiesAccepted:action.statisticsCookiesAccepted});}default:return state;}};export default cookieSettingsReducer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{combineReducers}from'redux';import cookieConsentModal from"./cookieConsentModal";import cookieSettings from"./cookieSettings";export default combineReducers({cookieConsentModal:cookieConsentModal,cookieSettings:cookieSettings});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import{createSelector}from'reselect';/**
|
|
2
|
+
* Selects the cookie consent modal state.
|
|
3
|
+
* @param {Object} state The current state of the cookie consent modal.
|
|
4
|
+
* @returns {Object} whether cookie consent modal is shown.
|
|
5
|
+
*/export var getCookieConsentModalState=function getCookieConsentModalState(state){var _state$tracking;return(state===null||state===void 0?void 0:(_state$tracking=state.tracking)===null||_state$tracking===void 0?void 0:_state$tracking.cookieConsentModal)||{};};/**
|
|
6
|
+
* Selects the cookie settings state.
|
|
7
|
+
* @param {Object} state The current state of the cookie settings.
|
|
8
|
+
* @returns {Object} whether cookies have been accepted by the user.
|
|
9
|
+
*/export var getCookieSettingsState=function getCookieSettingsState(state){var _state$tracking2;return(state===null||state===void 0?void 0:(_state$tracking2=state.tracking)===null||_state$tracking2===void 0?void 0:_state$tracking2.cookieSettings)||{};};/**
|
|
10
|
+
* Selects the property of the comfort cookie settings.
|
|
11
|
+
* @returns {boolean|null} whether comfort cookies have been selected by the user.
|
|
12
|
+
*/export var getAreComfortCookiesAccepted=createSelector(getCookieSettingsState,function(settingsState){return settingsState.comfortCookiesAccepted;});/**
|
|
13
|
+
* Selects the property of the statistics cookie settings.
|
|
14
|
+
* @returns {boolean|null} whether statistics cookies have been selected by the user.
|
|
15
|
+
*/export var getAreStatisticsCookiesAccepted=createSelector(getCookieSettingsState,function(settingsState){return settingsState.statisticsCookiesAccepted;});/**
|
|
16
|
+
* Selects the property of the comfort cookie settings
|
|
17
|
+
* and returns true for tracking in case cookie feature is not activated (i.e. null)
|
|
18
|
+
* @returns {boolean} whether comfort cookies are set and should activate tracking.
|
|
19
|
+
*/export var getAreComfortCookiesSet=createSelector(getCookieSettingsState,function(settingsState){if(settingsState.comfortCookiesAccepted===null)return true;return settingsState.comfortCookiesAccepted;});/**
|
|
20
|
+
* Selects the property of the statistics cookie settings
|
|
21
|
+
* and returns true for tracking in case cookie feature is not activated (i.e. null)
|
|
22
|
+
* @returns {boolean} whether statistics cookies are set and should activate tracking.
|
|
23
|
+
*/export var getAreStatisticsCookiesSet=createSelector(getCookieSettingsState,function(settingsState){if(settingsState.statisticsCookiesAccepted===null)return true;return settingsState.statisticsCookiesAccepted;});/**
|
|
24
|
+
* Selects the visibility property of the cookie consent modal.
|
|
25
|
+
* @returns {boolean} whether cookie consent modal is shown.
|
|
26
|
+
*/export var getIsCookieConsentModalVisible=createSelector(getCookieConsentModalState,getAreComfortCookiesAccepted,getAreStatisticsCookiesAccepted,function(modalState,comfortCookiesState,statisticsCookiesState){return modalState.isCookieConsentModalVisible&&comfortCookiesState===null&&statisticsCookiesState===null;});/**
|
|
27
|
+
* Selects the cookie consent settings property.
|
|
28
|
+
* @returns {boolean} whether cookie consent settings have been chosen by the user.
|
|
29
|
+
*/export var getIsCookieConsentHandled=createSelector(getCookieSettingsState,function(settingsState){return(settingsState===null||settingsState===void 0?void 0:settingsState.comfortCookiesAccepted)!==null||(settingsState===null||settingsState===void 0?void 0:settingsState.statisticsCookiesAccepted)!==null;});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{getAreComfortCookiesSet}from"./cookieConsent";export{getAreStatisticsCookiesSet}from"./cookieConsent";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_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$}from'@shopgate/engage/core/streams';import'rxjs/add/observable/of';import{Observable}from'rxjs/Observable';import{COOKIE_CONSENT_HANDLED,UPDATE_COOKIE_CONSENT}from"../constants";/**
|
|
2
|
+
* Gets triggered when the cookie consent has been updated by the user or handled already.
|
|
3
|
+
* This stream is only for internal usage and will be triggered independent of changed payload.
|
|
4
|
+
* @type {Observable}
|
|
5
|
+
*/var cookieConsentSetInternal$=main$.filter(function(_ref){var action=_ref.action;return action.type===UPDATE_COOKIE_CONSENT||action.type===COOKIE_CONSENT_HANDLED;});/**
|
|
6
|
+
* Gets triggered when the cookie consent has been initially configured by the user or is
|
|
7
|
+
* handled already.
|
|
8
|
+
* @type {Observable}
|
|
9
|
+
*/export var cookieConsentInitialized$=cookieConsentSetInternal$.first();/**
|
|
10
|
+
* Gets triggered when cookie consent settings changed after initialization
|
|
11
|
+
* @type {Observable}
|
|
12
|
+
*/export var cookieConsentUpdated$=cookieConsentSetInternal$.pairwise().filter(function(_ref2){var _ref3=_slicedToArray(_ref2,2),actionPrev=_ref3[0].action,actionCurrent=_ref3[1].action;return actionPrev.comfortCookiesAccepted!==actionCurrent.comfortCookiesAccepted||actionPrev.statisticsCookiesAccepted!==actionCurrent.statisticsCookiesAccepted;}).switchMap(function(_ref4){var _ref5=_slicedToArray(_ref4,2),latest=_ref5[1];return Observable.of(latest);});/**
|
|
13
|
+
* Gets triggered when the cookie consent has been updated by the user or handled already.
|
|
14
|
+
* @type {Observable}
|
|
15
|
+
*/export var cookieConsentSet$=cookieConsentInitialized$.merge(cookieConsentUpdated$);/**
|
|
16
|
+
* Gets triggered when the cookie consent has been set either by user or merchant.
|
|
17
|
+
* @type {Observable}
|
|
18
|
+
*/export var comfortCookiesAccepted$=cookieConsentSet$.filter(function(_ref6){var action=_ref6.action;return action.comfortCookiesAccepted===true;});/**
|
|
19
|
+
* Gets triggered when the cookie consent has been set either by user or merchant.
|
|
20
|
+
* @type {Observable}
|
|
21
|
+
*/export var statisticsCookiesAccepted$=cookieConsentSet$.filter(function(_ref7){var action=_ref7.action;return action.statisticsCookiesAccepted===true;});/**
|
|
22
|
+
* Gets triggered when comfort cookies where accepted first and declined afterwards during an
|
|
23
|
+
* app session.
|
|
24
|
+
* @type {Observable}
|
|
25
|
+
*/export var comfortCookiesDeclined$=comfortCookiesAccepted$.switchMap(function(){return cookieConsentSet$.filter(function(_ref8){var action=_ref8.action;return action.comfortCookiesAccepted===false;}).first();});/**
|
|
26
|
+
* Gets triggered when statistics cookies where accepted first and declined afterwards during an
|
|
27
|
+
* app session.
|
|
28
|
+
* @type {Observable}
|
|
29
|
+
*/export var statisticsCookiesDeclined$=statisticsCookiesAccepted$.switchMap(function(){return cookieConsentSet$.filter(function(_ref9){var action=_ref9.action;return action.statisticsCookiesAccepted===false;}).first();});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./cookieConsent";
|
|
@@ -0,0 +1,11 @@
|
|
|
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}from'@shopgate/engage/core/helpers';import{analyticsSetConsent}from'@shopgate/engage/core/commands';import{cookieConsentInitialized$,cookieConsentUpdated$}from"../streams";/**
|
|
2
|
+
* Analytics subscriptions
|
|
3
|
+
* @param {Function} subscribe The subscribe function
|
|
4
|
+
*/export default function analytics(subscribe){/**
|
|
5
|
+
* Sends cookie consent decisions to the app
|
|
6
|
+
* @param {Object} params Function params
|
|
7
|
+
* @param {Object} params.action Cookie consent update action
|
|
8
|
+
*/var sendConsentToApp=/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref){var action,statisticsCookiesAccepted,comfortCookiesAccepted;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:action=_ref.action;if(appSupportsCookieConsent()){_context.next=3;break;}return _context.abrupt("return");case 3:statisticsCookiesAccepted=action.statisticsCookiesAccepted,comfortCookiesAccepted=action.comfortCookiesAccepted;// Send consent decisions to the app
|
|
9
|
+
_context.next=6;return analyticsSetConsent({statistics:statisticsCookiesAccepted,comfort:comfortCookiesAccepted});case 6:case"end":return _context.stop();}}},_callee);}));return function sendConsentToApp(_x){return _ref2.apply(this,arguments);};}();subscribe(cookieConsentInitialized$,/*#__PURE__*/function(){var _ref4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3){var action;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:action=_ref3.action;_context2.next=3;return sendConsentToApp({action:action});case 3:case"end":return _context2.stop();}}},_callee2);}));return function(_x2){return _ref4.apply(this,arguments);};}());subscribe(cookieConsentUpdated$,/*#__PURE__*/function(){var _ref6=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref5){var dispatch,action;return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:dispatch=_ref5.dispatch,action=_ref5.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
|
+
// are turned off
|
|
11
|
+
dispatch(reloadApp());case 4:case"end":return _context3.stop();}}},_callee3);}));return function(_x3){return _ref6.apply(this,arguments);};}());}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{main$,appDidStart$}from'@shopgate/engage/core/streams';import{ROUTE_WILL_LEAVE}from'@shopgate/engage/core/constants';import{PRIVACY_SETTINGS_PATTERN}from'@shopgate/engage/tracking/constants';import{appSupportsCookieConsent}from'@shopgate/engage/core/helpers';import{grantAppTrackingTransparencyPermission}from'@shopgate/engage/core/actions';import{handleCookieConsent,showCookieConsentModal}from"../action-creators";import{getIsCookieConsentHandled,getAreComfortCookiesSet,getAreStatisticsCookiesSet}from"../selectors/cookieConsent";import{appConfig}from"../../index";/**
|
|
2
|
+
* stream which gets triggered when the user navigates back from privacy settings page
|
|
3
|
+
* and cookie consent modal needs to be shown again.
|
|
4
|
+
* @type {Observable}
|
|
5
|
+
*/export var navigateBackToCookieModal$=main$.filter(function(_ref){var action=_ref.action;return action.type===ROUTE_WILL_LEAVE;}).filter(function(_ref2){var action=_ref2.action;return action.route.pathname===PRIVACY_SETTINGS_PATTERN;});/**
|
|
6
|
+
* determine whether to show the cookie consent modal at app start
|
|
7
|
+
* @param {Function} subscribe The subscribe function
|
|
8
|
+
*/export default function cookieConsent(subscribe){subscribe(appDidStart$,/*#__PURE__*/function(){var _ref4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref3){var dispatch,getState,state,isCookieConsentActivated,isCookieConsentHandled,comfortCookiesAccepted,statisticsCookiesAccepted;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:dispatch=_ref3.dispatch,getState=_ref3.getState;state=getState();isCookieConsentActivated=appConfig.cookieConsent.isCookieConsentActivated;isCookieConsentHandled=getIsCookieConsentHandled(state);/**
|
|
9
|
+
* if merchant has not activated the cookie feature OR if merchant has activated cookie feature
|
|
10
|
+
* and user has chosen cookies already trigger stream to run code that depends on the cookie
|
|
11
|
+
* consent.
|
|
12
|
+
*/if(!(!isCookieConsentActivated||isCookieConsentActivated&&isCookieConsentHandled||!appSupportsCookieConsent())){_context.next=12;break;}comfortCookiesAccepted=getAreComfortCookiesSet(state);statisticsCookiesAccepted=getAreStatisticsCookiesSet(state);dispatch(handleCookieConsent({comfortCookiesAccepted:comfortCookiesAccepted,statisticsCookiesAccepted:statisticsCookiesAccepted}));if(!(appSupportsCookieConsent()&&(comfortCookiesAccepted||statisticsCookiesAccepted))){_context.next=11;break;}_context.next=11;return dispatch(grantAppTrackingTransparencyPermission());case 11:return _context.abrupt("return");case 12:// if merchant has activated cookie feature but user has not chosen cookies yet:
|
|
13
|
+
// show cookie consent modal to make user choose them
|
|
14
|
+
if(isCookieConsentActivated&&!isCookieConsentHandled){dispatch(showCookieConsentModal());}case 13:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref4.apply(this,arguments);};}());subscribe(navigateBackToCookieModal$,function(_ref5){var dispatch=_ref5.dispatch,getState=_ref5.getState;var isCookieConsentActivated=appConfig.cookieConsent.isCookieConsentActivated;var isCookieConsentHandled=getIsCookieConsentHandled(getState());if(isCookieConsentActivated&&!isCookieConsentHandled){dispatch(showCookieConsentModal());}});}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import analytics from"./analytics";import cookieConsent from"./cookieConsent";export default(function(subscribe){analytics(subscribe);cookieConsent(subscribe);});
|