@shopgate/pwa-common 7.30.0-alpha.7 → 7.30.0-alpha.8
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/App.js +48 -6
- package/action-creators/app/index.js +75 -12
- package/action-creators/app/spec.js +96 -1
- package/action-creators/client/index.js +27 -5
- package/action-creators/client/spec.js +44 -1
- package/action-creators/error/index.js +15 -3
- package/action-creators/index.js +9 -1
- package/action-creators/menu/index.js +23 -4
- package/action-creators/menu/spec.js +37 -1
- package/action-creators/modal/index.js +15 -3
- package/action-creators/modal/spec.js +26 -1
- package/action-creators/page/index.js +24 -4
- package/action-creators/page/spec.js +38 -1
- package/action-creators/router/index.js +48 -7
- package/action-creators/url/index.js +24 -4
- package/action-creators/url/spec.js +45 -1
- package/action-creators/user/index.js +90 -13
- package/action-creators/user/spec.js +186 -2
- package/actions/app/handleDeepLink.js +11 -2
- package/actions/app/handleLink.js +62 -6
- package/actions/app/handlePushNotification.js +32 -4
- package/actions/app/handleUniversalLink.js +11 -2
- package/actions/app/registerLinkEvents.js +24 -3
- package/actions/client/fetchClientInformation.js +26 -2
- package/actions/menu/fetchMenu.js +23 -2
- package/actions/modal/closeModal.js +18 -2
- package/actions/modal/promiseMap.js +3 -1
- package/actions/modal/showModal.js +54 -8
- package/actions/page/fetchPageConfig.js +69 -2
- package/actions/page/getPageConfig.js +6 -2
- package/actions/page/index.js +1 -1
- package/actions/router/historyPop.js +12 -2
- package/actions/router/historyPopToRoute.js +27 -2
- package/actions/router/historyPush.js +12 -2
- package/actions/router/historyRedirect.js +21 -2
- package/actions/router/historyReplace.js +20 -3
- package/actions/router/historyReset.js +11 -2
- package/actions/router/historyResetTo.js +12 -2
- package/actions/router/index.js +17 -1
- package/actions/router/routeDidPop.js +11 -2
- package/actions/router/routeDidPush.js +13 -2
- package/actions/router/routeDidReplace.js +11 -2
- package/actions/router/routeDidReset.js +11 -2
- package/actions/router/routeDidUpdate.js +10 -2
- package/actions/router/routeWillPop.js +11 -2
- package/actions/router/routeWillPush.js +13 -2
- package/actions/router/routeWillReplace.js +11 -2
- package/actions/router/routeWillReset.js +11 -2
- package/actions/router/windowOpenOverride.js +10 -2
- package/actions/user/fetchRegisterUrl.js +36 -2
- package/actions/user/fetchUser.js +29 -3
- package/actions/user/getUser.js +6 -2
- package/actions/user/index.js +1 -1
- package/actions/user/login.js +76 -9
- package/actions/user/logout.js +30 -2
- package/collections/AuthRoutes.js +73 -14
- package/collections/Configuration.js +54 -7
- package/collections/EmbeddedMedia.js +84 -11
- package/collections/PersistedReducers.js +41 -6
- package/collections/Redirects.js +103 -17
- package/collections/index.js +5 -1
- package/collections/media-providers/MediaProvider.js +151 -26
- package/collections/media-providers/Vimeo.js +113 -19
- package/collections/media-providers/YouTube.js +74 -14
- package/collections/media-providers/index.js +3 -1
- package/collections/media-providers/style.js +52 -2
- package/components/Backdrop/index.js +95 -6
- package/components/Backdrop/spec.js +23 -1
- package/components/Backdrop/style.js +11 -2
- package/components/Button/index.js +47 -5
- package/components/Button/spec.js +36 -1
- package/components/Button/style.js +6 -1
- package/components/Checkbox/index.js +126 -32
- package/components/Checkbox/spec.js +94 -3
- package/components/Consume/helpers/buildParams.js +13 -2
- package/components/Consume/index.js +14 -2
- package/components/CountdownTimer/index.js +115 -17
- package/components/CountdownTimer/spec.js +126 -12
- package/components/Drawer/index.js +131 -16
- package/components/Drawer/spec.js +76 -1
- package/components/Drawer/style.js +37 -1
- package/components/Dropdown/index.js +65 -6
- package/components/Dropdown/style.js +4 -1
- package/components/Dropdown/transitions.js +34 -1
- package/components/Ellipsis/index.js +16 -2
- package/components/Ellipsis/spec.js +13 -1
- package/components/EmbeddedMedia/index.js +56 -6
- package/components/EmbeddedMedia/spec.js +52 -3
- package/components/ErrorBoundary/connector.js +9 -2
- package/components/ErrorBoundary/index.js +43 -7
- package/components/Grid/components/Item/index.js +40 -4
- package/components/Grid/components/Item/spec.js +23 -1
- package/components/Grid/components/Item/style.js +17 -3
- package/components/Grid/index.js +36 -4
- package/components/Grid/spec.js +23 -1
- package/components/Grid/style.js +11 -2
- package/components/HtmlSanitizer/connector.js +24 -3
- package/components/HtmlSanitizer/index.js +104 -12
- package/components/HtmlSanitizer/spec.js +207 -6
- package/components/I18n/components/FormatDate/index.js +26 -2
- package/components/I18n/components/FormatDate/spec.js +46 -1
- package/components/I18n/components/FormatNumber/index.js +34 -2
- package/components/I18n/components/FormatNumber/spec.js +41 -2
- package/components/I18n/components/FormatPrice/index.js +32 -2
- package/components/I18n/components/FormatPrice/spec.js +46 -1
- package/components/I18n/components/FormatTime/index.js +26 -2
- package/components/I18n/components/FormatTime/spec.js +43 -2
- package/components/I18n/components/I18nProvider/index.js +52 -9
- package/components/I18n/components/I18nProvider/spec.js +39 -1
- package/components/I18n/components/Placeholder/index.js +8 -2
- package/components/I18n/components/Placeholder/spec.js +30 -1
- package/components/I18n/components/Translate/index.js +68 -7
- package/components/I18n/components/Translate/spec.js +30 -1
- package/components/I18n/index.js +16 -1
- package/components/Icon/index.js +25 -2
- package/components/Icon/style.js +6 -1
- package/components/Image/Image.js +176 -19
- package/components/Image/ImageInner.js +48 -2
- package/components/Image/index.js +1 -1
- package/components/Image/style.js +29 -2
- package/components/InfiniteContainer/index.js +381 -49
- package/components/InfiniteContainer/spec.js +199 -10
- package/components/Input/components/DateInput.js +262 -6
- package/components/Input/components/MultiLineInput.js +98 -12
- package/components/Input/components/SimpleInput.js +207 -31
- package/components/Input/index.js +32 -3
- package/components/Input/spec.js +122 -1
- package/components/KeyboardConsumer/index.js +48 -7
- package/components/Link/connector.js +7 -1
- package/components/Link/index.js +96 -11
- package/components/Link/spec.js +56 -1
- package/components/Link/style.js +10 -1
- package/components/List/components/Item/index.js +35 -3
- package/components/List/components/Item/style.js +16 -1
- package/components/List/index.js +20 -2
- package/components/List/spec.js +31 -1
- package/components/Loading/index.js +6 -2
- package/components/Modal/index.js +38 -3
- package/components/Modal/style.js +36 -1
- package/components/ModalContainer/connector.js +17 -3
- package/components/ModalContainer/index.js +36 -3
- package/components/ModalContainer/spec.js +105 -5
- package/components/Picker/components/Button/index.js +34 -2
- package/components/Picker/components/Button/style.js +19 -1
- package/components/Picker/components/List/index.js +33 -2
- package/components/Picker/components/List/style.js +17 -1
- package/components/Picker/components/Modal/index.js +60 -7
- package/components/Picker/components/Modal/style.js +78 -1
- package/components/Picker/index.js +167 -21
- package/components/Picker/spec.js +83 -2
- package/components/Portal/index.js +130 -19
- package/components/ProductCharacteristics/connector.js +33 -4
- package/components/ProductCharacteristics/context.js +2 -1
- package/components/ProductCharacteristics/helpers/index.js +135 -21
- package/components/ProductCharacteristics/index.js +266 -31
- package/components/RangeSlider/components/Handle/index.js +25 -2
- package/components/RangeSlider/components/Handle/style.js +14 -1
- package/components/RangeSlider/helper.js +43 -8
- package/components/RangeSlider/index.js +228 -38
- package/components/RangeSlider/style.js +14 -1
- package/components/Route/RouteNotFound.js +46 -3
- package/components/Route/index.js +78 -10
- package/components/Router/connector.js +9 -2
- package/components/Router/index.js +237 -31
- package/components/ScannerContainer/connector.js +9 -2
- package/components/ScannerContainer/index.js +42 -6
- package/components/Select/components/Item/index.js +20 -4
- package/components/Select/components/Item/style.js +4 -1
- package/components/Select/index.js +149 -28
- package/components/Select/spec.js +86 -2
- package/components/Select/style.js +17 -1
- package/components/SelectBox/components/Item/index.js +47 -5
- package/components/SelectBox/components/Item/style.js +7 -1
- package/components/SelectBox/index.js +173 -17
- package/components/SelectBox/spec.js +59 -3
- package/components/SelectBox/style.js +18 -1
- package/components/Slider/index.js +6 -2
- package/components/SurroundPortals/index.js +26 -2
- package/components/Swiper/components/SwiperItem/index.js +28 -4
- package/components/Swiper/components/SwiperItem/spec.js +17 -1
- package/components/Swiper/components/SwiperItem/styles.js +5 -1
- package/components/Swiper/index.js +210 -18
- package/components/Swiper/styles.js +75 -7
- package/components/Toaster/index.js +10 -2
- package/components/Transition/index.js +89 -13
- package/components/Widgets/components/Widget/index.js +52 -4
- package/components/Widgets/components/Widget/spec.js +68 -3
- package/components/Widgets/components/Widget/style.js +21 -3
- package/components/Widgets/components/WidgetGrid/index.js +52 -7
- package/components/Widgets/components/WidgetGrid/spec.js +46 -2
- package/components/Widgets/components/WidgetGrid/style.js +8 -1
- package/components/Widgets/helpers/shouldShowWidget.js +44 -7
- package/components/Widgets/index.js +127 -15
- package/components/Widgets/spec.js +213 -6
- package/components/index.js +9 -1
- package/constants/ActionTypes.js +97 -19
- package/constants/Configuration.js +12 -2
- package/constants/Device.js +29 -2
- package/constants/DisplayOptions.js +8 -1
- package/constants/MenuIDs.js +2 -1
- package/constants/ModalTypes.js +1 -1
- package/constants/PageIDs.js +1 -1
- package/constants/Pipelines.js +7 -1
- package/constants/Portals.js +136 -3
- package/constants/Registration.js +3 -1
- package/constants/RoutePaths.js +13 -2
- package/constants/Tracking.js +3 -1
- package/constants/client.js +6 -1
- package/constants/ui.js +2 -1
- package/constants/user.js +6 -2
- package/context/index.js +33 -3
- package/helpers/config/index.js +139 -21
- package/helpers/config/mock.js +200 -8
- package/helpers/config/theme.js +50 -4
- package/helpers/data/index.js +204 -29
- package/helpers/data/spec.js +187 -7
- package/helpers/date/index.js +58 -6
- package/helpers/date/spec.js +92 -1
- package/helpers/dom/index.js +48 -11
- package/helpers/environment/index.js +14 -2
- package/helpers/html/decodeHTML.js +7 -1
- package/helpers/html/handleDOM.js +172 -21
- package/helpers/html/parseHTML.js +67 -12
- package/helpers/i18n/getDateFormatter.js +23 -4
- package/helpers/i18n/getNumberFormatter.js +32 -4
- package/helpers/i18n/getPriceFormatter.js +38 -4
- package/helpers/i18n/getTimeFormatter.js +23 -4
- package/helpers/i18n/getTranslator.js +62 -8
- package/helpers/i18n/index.js +5 -1
- package/helpers/i18n/mergeTranslations.js +36 -9
- package/helpers/i18n/messageCache.js +3 -1
- package/helpers/legacy/index.js +47 -9
- package/helpers/modal/withShowModal.js +13 -2
- package/helpers/portals/portalCollection.js +28 -6
- package/helpers/portals/routePortals.js +12 -1
- package/helpers/redux/compareObjects.js +7 -2
- package/helpers/redux/generateResultHash.js +36 -3
- package/helpers/redux/generateSortedHash.js +7 -2
- package/helpers/redux/hasExpired.js +10 -2
- package/helpers/redux/index.js +7 -1
- package/helpers/redux/mutable.js +143 -24
- package/helpers/redux/shouldFetchData.js +46 -10
- package/helpers/redux/shouldFetchFilters.js +17 -4
- package/helpers/router/index.js +49 -5
- package/helpers/style/index.js +43 -4
- package/helpers/style/spec.js +108 -2
- package/helpers/tracking/index.js +52 -9
- package/helpers/validation/index.js +39 -12
- package/helpers/validation/spec.js +10 -1
- package/package.json +3 -3
- package/providers/index.js +4 -1
- package/providers/loading/context.js +2 -1
- package/providers/loading/index.js +137 -22
- package/providers/toast/context.js +2 -1
- package/providers/toast/index.js +105 -11
- package/reducers/client/connectivity.js +22 -2
- package/reducers/client/index.js +7 -1
- package/reducers/client/info.js +27 -2
- package/reducers/index.js +23 -4
- package/reducers/menu/index.js +5 -1
- package/reducers/menu/menusById.js +41 -2
- package/reducers/modal/index.js +14 -2
- package/reducers/page/index.js +68 -5
- package/reducers/router/index.js +48 -2
- package/reducers/url/index.js +42 -3
- package/reducers/user/data.js +27 -2
- package/reducers/user/index.js +7 -1
- package/reducers/user/login.js +65 -2
- package/selectors/client.js +138 -21
- package/selectors/history.js +49 -11
- package/selectors/menu.js +34 -6
- package/selectors/modal.js +15 -4
- package/selectors/page.js +25 -4
- package/selectors/router.js +154 -30
- package/selectors/url.js +25 -4
- package/selectors/user.js +90 -13
- package/store/index.js +60 -6
- package/store/middelwares/logger.js +7 -1
- package/store/middelwares/streams.js +19 -2
- package/streams/app.js +60 -8
- package/streams/client.js +8 -2
- package/streams/error.js +14 -3
- package/streams/index.js +6 -1
- package/streams/interval.js +6 -2
- package/streams/main.js +27 -2
- package/streams/router.js +45 -8
- package/streams/user.js +89 -15
- package/streams/view.js +97 -25
- package/styles/reset/form.js +57 -5
- package/styles/reset/index.js +6 -1
- package/styles/reset/media.js +22 -1
- package/styles/reset/root.js +33 -1
- package/styles/reset/table.js +10 -1
- package/styles/reset/typography.js +26 -1
- package/subscriptions/app.js +148 -17
- package/subscriptions/error.js +292 -13
- package/subscriptions/helpers/buildRegisterUrl.js +25 -6
- package/subscriptions/helpers/clearUpInAppBrowser.js +14 -3
- package/subscriptions/helpers/handleLinks.js +267 -25
- package/subscriptions/helpers/pipeline.js +12 -1
- package/subscriptions/history.js +34 -6
- package/subscriptions/index.js +25 -4
- package/subscriptions/menu.js +22 -5
- package/subscriptions/mock.js +39 -7
- package/subscriptions/router.js +336 -23
- package/subscriptions/user.js +93 -3
package/styles/reset/table.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @deprecated used @shopgate/engage/styles instead
|
|
3
|
-
*/
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { css } from 'glamor';
|
|
6
|
+
css.global('table', {
|
|
7
|
+
borderCollapse: 'collapse',
|
|
8
|
+
minWidth: '100%'
|
|
9
|
+
});
|
|
10
|
+
css.global('td, th', {
|
|
11
|
+
verticalAlign: 'top'
|
|
12
|
+
});
|
|
@@ -1,3 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @deprecated used @shopgate/engage/styles instead
|
|
3
|
-
*/
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { css } from 'glamor';
|
|
6
|
+
import { rem } from "../../helpers/style";
|
|
7
|
+
css.global('a', {
|
|
8
|
+
color: 'inherit',
|
|
9
|
+
textDecoration: 'none',
|
|
10
|
+
WebkitTextDecorationSkip: 'objects'
|
|
11
|
+
});
|
|
12
|
+
css.global('a:hover, a:focus, a:active, [tabindex]', {
|
|
13
|
+
outline: 0
|
|
14
|
+
});
|
|
15
|
+
css.global('ol, ul', {
|
|
16
|
+
listStyle: 'none',
|
|
17
|
+
margin: 0,
|
|
18
|
+
paddingLeft: 0
|
|
19
|
+
});
|
|
20
|
+
css.global('b, strong', {
|
|
21
|
+
fontWeight: 700
|
|
22
|
+
});
|
|
23
|
+
css.global('small', {
|
|
24
|
+
fontSize: rem(13)
|
|
25
|
+
});
|
|
26
|
+
css.global('sub, sup', {
|
|
27
|
+
lineHeight: 0
|
|
28
|
+
});
|
package/subscriptions/app.js
CHANGED
|
@@ -1,27 +1,158 @@
|
|
|
1
|
-
import{event,emitter as errorEmitter,registerEvents,closeInAppBrowser,onload}
|
|
1
|
+
import { event, emitter as errorEmitter, registerEvents, closeInAppBrowser, onload } from '@shopgate/pwa-core';
|
|
2
|
+
import { EVENT_KEYBOARD_WILL_CHANGE, APP_EVENT_VIEW_WILL_APPEAR, APP_EVENT_VIEW_DID_APPEAR, APP_EVENT_VIEW_WILL_DISAPPEAR, APP_EVENT_VIEW_DID_DISAPPEAR } from '@shopgate/pwa-core/constants/AppEvents';
|
|
3
|
+
import { SOURCE_APP, SOURCE_PIPELINE } from '@shopgate/pwa-core/constants/ErrorManager';
|
|
4
|
+
import pipelineManager from '@shopgate/pwa-core/classes/PipelineManager';
|
|
5
|
+
import * as errorCodes from '@shopgate/pwa-core/constants/Pipeline';
|
|
6
|
+
import { onWillPush, onDidPush, onWillPop, onDidPop, onWillReplace, onDidReplace, onWillReset, onDidReset, onUpdate } from '@virtuous/conductor';
|
|
7
|
+
import { appConfig } from '@shopgate/engage';
|
|
8
|
+
import { UI_VISIBILITY_CHANGE } from "../constants/ui";
|
|
9
|
+
import { appError, pipelineError, pwaDidAppear, pwaDidDisappear } from "../action-creators";
|
|
10
|
+
import { historyPush, routeWillPush, routeDidPush, routeWillPop, routeDidPop, routeWillReplace, routeDidReplace, routeWillReset, routeDidReset, routeDidUpdate } from "../actions/router";
|
|
11
|
+
import { receiveClientConnectivity } from "../action-creators/client";
|
|
12
|
+
import { appWillStart$, appDidStart$, clientInformationDidUpdate$, navigate$ } from "../streams";
|
|
13
|
+
import registerLinkEvents from "../actions/app/registerLinkEvents";
|
|
14
|
+
import { APP_PLATFORM } from "../constants/Configuration";
|
|
15
|
+
import { getPlatform, isAndroid } from "../selectors/client";
|
|
16
|
+
import { prepareLegacyNavigation, showPreviousTab, pageContext } from "../helpers/legacy";
|
|
17
|
+
import { embeddedMedia, configuration } from "../collections";
|
|
18
|
+
import { Vimeo, YouTube } from "../collections/media-providers";
|
|
19
|
+
import clearUpInAppBrowser from "./helpers/clearUpInAppBrowser";
|
|
20
|
+
|
|
21
|
+
/**
|
|
2
22
|
* App subscriptions.
|
|
3
23
|
* @param {Function} subscribe The subscribe function.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
24
|
+
*/
|
|
25
|
+
export default function app(subscribe) {
|
|
26
|
+
// Gets triggered before the app starts.
|
|
27
|
+
subscribe(appWillStart$, ({
|
|
28
|
+
dispatch,
|
|
29
|
+
action,
|
|
30
|
+
getState,
|
|
31
|
+
events
|
|
32
|
+
}) => {
|
|
33
|
+
embeddedMedia.addProvider(new Vimeo({
|
|
34
|
+
responsify: appConfig?.responsifyVideos?.vimeo
|
|
35
|
+
}));
|
|
36
|
+
embeddedMedia.addProvider(new YouTube({
|
|
37
|
+
responsify: appConfig?.responsifyVideos?.youTube
|
|
38
|
+
}));
|
|
39
|
+
dispatch(registerLinkEvents(action.location));
|
|
40
|
+
onWillPush(({
|
|
41
|
+
prev,
|
|
42
|
+
next
|
|
43
|
+
}) => dispatch(routeWillPush(prev, next)));
|
|
44
|
+
onDidPush(({
|
|
45
|
+
prev,
|
|
46
|
+
next
|
|
47
|
+
}) => dispatch(routeDidPush(prev, next)));
|
|
48
|
+
onWillPop(({
|
|
49
|
+
prev,
|
|
50
|
+
next
|
|
51
|
+
}) => dispatch(routeWillPop(prev, next)));
|
|
52
|
+
onDidPop(({
|
|
53
|
+
prev,
|
|
54
|
+
next
|
|
55
|
+
}) => dispatch(routeDidPop(prev, next)));
|
|
56
|
+
onWillReplace(({
|
|
57
|
+
prev,
|
|
58
|
+
next
|
|
59
|
+
}) => dispatch(routeWillReplace(prev, next)));
|
|
60
|
+
onDidReplace(({
|
|
61
|
+
prev,
|
|
62
|
+
next
|
|
63
|
+
}) => dispatch(routeDidReplace(prev, next)));
|
|
64
|
+
onWillReset(({
|
|
65
|
+
prev,
|
|
66
|
+
next
|
|
67
|
+
}) => dispatch(routeWillReset(prev, next)));
|
|
68
|
+
onDidReset(({
|
|
69
|
+
prev,
|
|
70
|
+
next
|
|
71
|
+
}) => dispatch(routeDidReset(prev, next)));
|
|
72
|
+
onUpdate(updated => dispatch(routeDidUpdate(updated)));
|
|
73
|
+
|
|
74
|
+
// Suppress errors globally
|
|
75
|
+
pipelineManager.addSuppressedErrors([errorCodes.EACCESS, errorCodes.ENOTFOUND, errorCodes.EVALIDATION]);
|
|
76
|
+
|
|
77
|
+
// Map the error events into the Observable streams.
|
|
78
|
+
errorEmitter.addListener(SOURCE_APP, error => dispatch(appError(error)));
|
|
79
|
+
errorEmitter.addListener(SOURCE_PIPELINE, error => dispatch(pipelineError(error)));
|
|
80
|
+
|
|
81
|
+
/** @returns {*} */
|
|
82
|
+
const viewVisibility = () => events.emit(UI_VISIBILITY_CHANGE);
|
|
83
|
+
event.addCallback('routeDidChange', viewVisibility);
|
|
84
|
+
event.addCallback(APP_EVENT_VIEW_DID_DISAPPEAR, () => {
|
|
85
|
+
dispatch(pwaDidDisappear());
|
|
86
|
+
viewVisibility();
|
|
87
|
+
});
|
|
88
|
+
event.addCallback(APP_EVENT_VIEW_DID_APPEAR, () => {
|
|
89
|
+
dispatch(pwaDidAppear());
|
|
90
|
+
clearUpInAppBrowser(isAndroid(getState()));
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
/**
|
|
8
95
|
* Gets triggered when the app starts.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
96
|
+
*/
|
|
97
|
+
subscribe(appDidStart$, ({
|
|
98
|
+
dispatch,
|
|
99
|
+
getState
|
|
100
|
+
}) => {
|
|
101
|
+
// Register for custom events
|
|
102
|
+
registerEvents([EVENT_KEYBOARD_WILL_CHANGE, 'showPreviousTab', 'closeInAppBrowser',
|
|
103
|
+
// TODO The iOS apps don't emit the event to the webviews without registration till Lib 15.2.
|
|
104
|
+
// This needs to be removed, when IOS-1886 is done and the the iOS apps are updated.
|
|
105
|
+
'httpResponse', 'connectivityDidChange']);
|
|
106
|
+
|
|
107
|
+
// Add event callbacks
|
|
108
|
+
event.addCallback('pageContext', pageContext);
|
|
109
|
+
// Handle native/legacy navigation bar
|
|
110
|
+
event.addCallback(APP_EVENT_VIEW_WILL_APPEAR, prepareLegacyNavigation);
|
|
111
|
+
event.addCallback('showPreviousTab', showPreviousTab);
|
|
112
|
+
/**
|
|
15
113
|
* This event is triggered form the desktop shop in the inAppBrowser.
|
|
16
114
|
* We have to close the inAppBrowser and redirect the user to the given url.
|
|
17
|
-
*/
|
|
115
|
+
*/
|
|
116
|
+
event.addCallback('closeInAppBrowser', (data = {}) => {
|
|
117
|
+
if (data.redirectTo) {
|
|
118
|
+
dispatch(historyPush({
|
|
119
|
+
pathname: data.redirectTo
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
closeInAppBrowser(isAndroid(getState()));
|
|
123
|
+
});
|
|
124
|
+
event.addCallback('connectivityDidChange', data => {
|
|
125
|
+
dispatch(receiveClientConnectivity(data));
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
/**
|
|
18
129
|
* The following events are sometimes sent by the app, but don't need to be handled right now.
|
|
19
130
|
* To avoid console warnings from the event system, empty handlers are registered here.
|
|
20
|
-
*/
|
|
21
|
-
|
|
131
|
+
*/
|
|
132
|
+
event.addCallback(APP_EVENT_VIEW_WILL_DISAPPEAR, () => {
|
|
133
|
+
// Stop all playing video
|
|
134
|
+
embeddedMedia.stop();
|
|
135
|
+
});
|
|
136
|
+
event.addCallback('pageInsetsChanged', () => {});
|
|
137
|
+
|
|
138
|
+
/*
|
|
22
139
|
* Onload must be send AFTER app did start.
|
|
23
140
|
* Interjections events (like openPushMessage) would not work if this command is sent
|
|
24
141
|
* before registering to interjections.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
|
|
142
|
+
*/
|
|
143
|
+
onload();
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// Add platform to runtime config
|
|
147
|
+
subscribe(clientInformationDidUpdate$, ({
|
|
148
|
+
getState
|
|
149
|
+
}) => {
|
|
150
|
+
const platform = getPlatform(getState());
|
|
151
|
+
configuration.set(APP_PLATFORM, platform);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// Stop all playing video on navigation
|
|
155
|
+
subscribe(navigate$, () => {
|
|
156
|
+
embeddedMedia.stop();
|
|
157
|
+
});
|
|
158
|
+
}
|
package/subscriptions/error.js
CHANGED
|
@@ -1,15 +1,294 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import after from 'lodash/after';
|
|
2
|
+
import before from 'lodash/before';
|
|
3
|
+
import over from 'lodash/over';
|
|
4
|
+
import { isAvailable } from '@shopgate/native-modules';
|
|
5
|
+
import { init, addBreadcrumb, configureScope, captureException, captureMessage, captureEvent, withScope, Severity as SentrySeverity } from '@sentry/browser';
|
|
6
|
+
import { EBIGAPI, emitter, errorManager, ETIMEOUT, ENETUNREACH, EUNKNOWN, EFAVORITE } from '@shopgate/pwa-core';
|
|
7
|
+
import { hasWebBridge } from '@shopgate/engage/core';
|
|
8
|
+
import { SOURCE_TRACKING, SOURCE_CONSOLE, Severity } from '@shopgate/pwa-core/constants/ErrorManager';
|
|
9
|
+
import { main$ } from "../streams/main";
|
|
10
|
+
import {
|
|
11
|
+
// eslint-disable-next-line import/no-named-default
|
|
12
|
+
default as appConfig, themeName, pckVersion } from "../helpers/config";
|
|
13
|
+
import { env } from "../helpers/environment";
|
|
14
|
+
import { transformGeneralPipelineError } from "./helpers/pipeline";
|
|
15
|
+
import { historyPop } from "../actions/router";
|
|
16
|
+
import showModal from "../actions/modal/showModal";
|
|
17
|
+
import { getUserData } from "../selectors/user";
|
|
18
|
+
import { userDidUpdate$ } from "../streams/user";
|
|
19
|
+
import { clientInformationDidUpdate$ } from "../streams/client";
|
|
20
|
+
import { appWillInit$, appWillStart$, appDidStart$ } from "../streams/app";
|
|
21
|
+
import { appError$, pipelineError$ } from "../streams/error";
|
|
22
|
+
import { getRouterStack } from "../selectors/router";
|
|
23
|
+
import { MODAL_PIPELINE_ERROR } from "../constants/ModalTypes";
|
|
24
|
+
import ToastProvider from "../providers/toast";
|
|
25
|
+
|
|
26
|
+
/**
|
|
3
27
|
* App errors subscriptions.
|
|
4
28
|
* @param {Function} subscribe The subscribe function.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
subscribe(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
29
|
+
*/
|
|
30
|
+
export default subscribe => {
|
|
31
|
+
/** Set general error transformations */
|
|
32
|
+
subscribe(appWillStart$, () => {
|
|
33
|
+
errorManager.setMessage({
|
|
34
|
+
code: EUNKNOWN,
|
|
35
|
+
message: transformGeneralPipelineError
|
|
36
|
+
}).setMessage({
|
|
37
|
+
code: EBIGAPI,
|
|
38
|
+
message: transformGeneralPipelineError
|
|
39
|
+
}).setMessage({
|
|
40
|
+
code: ETIMEOUT,
|
|
41
|
+
message: 'modal.body_error'
|
|
42
|
+
}).setMessage({
|
|
43
|
+
code: ENETUNREACH,
|
|
44
|
+
message: 'modal.body_error'
|
|
45
|
+
}).setMessage({
|
|
46
|
+
code: EFAVORITE,
|
|
47
|
+
message: 'favorites.error_general'
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
/** Show a message to the user in case of pipeline error */
|
|
52
|
+
subscribe(pipelineError$, ({
|
|
53
|
+
dispatch,
|
|
54
|
+
getState,
|
|
55
|
+
events,
|
|
56
|
+
action
|
|
57
|
+
}) => {
|
|
58
|
+
const {
|
|
59
|
+
error
|
|
60
|
+
} = action;
|
|
61
|
+
const {
|
|
62
|
+
message,
|
|
63
|
+
code,
|
|
64
|
+
context,
|
|
65
|
+
meta = {}
|
|
66
|
+
} = error;
|
|
67
|
+
const {
|
|
68
|
+
behavior
|
|
69
|
+
} = meta;
|
|
70
|
+
if (behavior) {
|
|
71
|
+
behavior({
|
|
72
|
+
dispatch,
|
|
73
|
+
getState,
|
|
74
|
+
events,
|
|
75
|
+
error
|
|
76
|
+
});
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Show modal thunk */
|
|
81
|
+
const showModalError = () => {
|
|
82
|
+
dispatch(showModal({
|
|
83
|
+
confirm: 'modal.ok',
|
|
84
|
+
dismiss: null,
|
|
85
|
+
title: null,
|
|
86
|
+
message,
|
|
87
|
+
type: MODAL_PIPELINE_ERROR,
|
|
88
|
+
params: {
|
|
89
|
+
pipeline: context,
|
|
90
|
+
request: meta.input,
|
|
91
|
+
message: meta.message,
|
|
92
|
+
code
|
|
93
|
+
}
|
|
94
|
+
}));
|
|
95
|
+
};
|
|
96
|
+
let shouldShowToast = message === 'error.general';
|
|
97
|
+
if ([ETIMEOUT, ENETUNREACH].includes(code) && message === 'modal.body_error') {
|
|
98
|
+
shouldShowToast = true;
|
|
99
|
+
}
|
|
100
|
+
// It was transformed general error. let it popup after 10 toast clicks
|
|
101
|
+
if (shouldShowToast) {
|
|
102
|
+
const showToastAfter = after(9, showModalError);
|
|
103
|
+
// Recursively show same toast message until clicked 10 times
|
|
104
|
+
const showToast = before(10, () => {
|
|
105
|
+
events.emit(ToastProvider.ADD, {
|
|
106
|
+
id: 'pipeline.error',
|
|
107
|
+
message: 'error.general',
|
|
108
|
+
action: over([showToast, showToastAfter])
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
showToast();
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
showModalError();
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// This subscription is always active despite sentry activation
|
|
118
|
+
subscribe(appError$, ({
|
|
119
|
+
dispatch
|
|
120
|
+
}) => {
|
|
121
|
+
// Show modal to user
|
|
122
|
+
dispatch(showModal({
|
|
123
|
+
confirm: null,
|
|
124
|
+
message: 'modal.body_error',
|
|
125
|
+
title: 'modal.title_error'
|
|
126
|
+
}));
|
|
127
|
+
dispatch(historyPop());
|
|
128
|
+
});
|
|
129
|
+
const {
|
|
130
|
+
enabled,
|
|
131
|
+
level,
|
|
132
|
+
sampleRate
|
|
133
|
+
} = appConfig.sentry;
|
|
134
|
+
// Is not enabled
|
|
135
|
+
if (!enabled) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const severityMap = {
|
|
139
|
+
[Severity.Fatal]: SentrySeverity.Fatal,
|
|
140
|
+
[Severity.Error]: SentrySeverity.Error,
|
|
141
|
+
[Severity.Critical]: SentrySeverity.Critical,
|
|
142
|
+
[Severity.Warning]: SentrySeverity.Warning,
|
|
143
|
+
[Severity.Info]: SentrySeverity.Info,
|
|
144
|
+
[Severity.Debug]: SentrySeverity.Debug
|
|
145
|
+
};
|
|
146
|
+
const ignoredDefaultBreadcrumbs = ['console', 'fetch', 'xhr', 'ui.click'];
|
|
147
|
+
let trackedSeverities = Object.getOwnPropertySymbols(severityMap).map(s => severityMap[s]);
|
|
148
|
+
const minSeverityIndex = trackedSeverities.indexOf(level);
|
|
149
|
+
if (minSeverityIndex > -1) {
|
|
150
|
+
trackedSeverities = trackedSeverities.slice(0, minSeverityIndex + 1);
|
|
151
|
+
}
|
|
152
|
+
subscribe(appWillInit$, ({
|
|
153
|
+
getState
|
|
154
|
+
}) => {
|
|
155
|
+
init({
|
|
156
|
+
dsn: 'https://1a444b262ac6405594ab33fb0102b377@sentry.io/1398210',
|
|
157
|
+
environment: appConfig.omniStage || env,
|
|
158
|
+
debug: env === 'development',
|
|
159
|
+
release: pckVersion,
|
|
160
|
+
attachStacktrace: true,
|
|
161
|
+
sampleRate,
|
|
162
|
+
beforeBreadcrumb(breadcrumb) {
|
|
163
|
+
if (ignoredDefaultBreadcrumbs.includes(breadcrumb.category)) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
return breadcrumb;
|
|
167
|
+
},
|
|
168
|
+
beforeSend(event) {
|
|
169
|
+
if (event.level && !trackedSeverities.includes(event.level)) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
// eslint-disable-next-line no-param-reassign
|
|
173
|
+
event.extra = {
|
|
174
|
+
...(event.extra || {}),
|
|
175
|
+
routerStack: getRouterStack(getState()).slice(-5)
|
|
176
|
+
};
|
|
177
|
+
return event;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
configureScope(scope => {
|
|
181
|
+
scope.setTag('marketId', appConfig.marketId);
|
|
182
|
+
scope.setTag('appId', appConfig.appId);
|
|
183
|
+
scope.setTag('pwaVersion', pckVersion);
|
|
184
|
+
scope.setTag('theme', themeName);
|
|
185
|
+
scope.setTag('language', appConfig.language);
|
|
186
|
+
scope.setTag('isWebsite', hasWebBridge());
|
|
187
|
+
scope.setTag('isReactNativeApp', isAvailable());
|
|
188
|
+
scope.setTag('merchantCode', appConfig.omniMerchantCode);
|
|
189
|
+
});
|
|
190
|
+
if (window) {
|
|
191
|
+
window.onerror = (message, source, lineno, colno, error) => {
|
|
192
|
+
captureException(error);
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
emitter.addListener(SOURCE_TRACKING, error => {
|
|
196
|
+
withScope(scope => {
|
|
197
|
+
if (error.context) {
|
|
198
|
+
scope.setExtra('trackerName', error.context);
|
|
199
|
+
}
|
|
200
|
+
captureException(error);
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
emitter.addListener(SOURCE_CONSOLE, args => {
|
|
204
|
+
withScope(scope => {
|
|
205
|
+
scope.setLevel(SentrySeverity.Error);
|
|
206
|
+
scope.setExtra('error', args);
|
|
207
|
+
captureMessage('Console error');
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
subscribe(main$, ({
|
|
212
|
+
action
|
|
213
|
+
}) => {
|
|
214
|
+
addBreadcrumb({
|
|
215
|
+
category: 'redux',
|
|
216
|
+
message: `[Redux] ${action.type}`,
|
|
217
|
+
level: SentrySeverity.Info,
|
|
218
|
+
data: {
|
|
219
|
+
...action
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
subscribe(userDidUpdate$, ({
|
|
224
|
+
getState
|
|
225
|
+
}) => {
|
|
226
|
+
const {
|
|
227
|
+
id: userId
|
|
228
|
+
} = getUserData(getState());
|
|
229
|
+
configureScope(scope => {
|
|
230
|
+
scope.setTag('userId', userId);
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// Add client lib versions
|
|
235
|
+
subscribe(clientInformationDidUpdate$, ({
|
|
236
|
+
action
|
|
237
|
+
}) => {
|
|
238
|
+
const {
|
|
239
|
+
appVersion,
|
|
240
|
+
libVersion,
|
|
241
|
+
deviceId
|
|
242
|
+
} = action.data;
|
|
243
|
+
configureScope(scope => {
|
|
244
|
+
scope.setTag('appVersion', appVersion);
|
|
245
|
+
scope.setTag('libVersion', libVersion);
|
|
246
|
+
scope.setTag('deviceId', deviceId);
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
// Add app start event for debugging
|
|
251
|
+
subscribe(appDidStart$, () => {
|
|
252
|
+
withScope(scope => {
|
|
253
|
+
scope.setLevel(SentrySeverity.Debug);
|
|
254
|
+
captureMessage('App did start');
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
// Add some stack trace and log to sentry
|
|
259
|
+
subscribe(appError$, ({
|
|
260
|
+
action
|
|
261
|
+
}) => {
|
|
262
|
+
withScope(scope => {
|
|
263
|
+
if (action.error.stack) {
|
|
264
|
+
scope.setExtra('stack', action.error.stack);
|
|
265
|
+
}
|
|
266
|
+
captureException(action.error);
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
const allErrors$ = pipelineError$.merge(appError$);
|
|
270
|
+
// Log all error messages which are presented to the user
|
|
271
|
+
subscribe(allErrors$, ({
|
|
272
|
+
action
|
|
273
|
+
}) => {
|
|
274
|
+
const {
|
|
275
|
+
error = {}
|
|
276
|
+
} = action;
|
|
277
|
+
const {
|
|
278
|
+
code,
|
|
279
|
+
message,
|
|
280
|
+
meta: {
|
|
281
|
+
message: metaMessage
|
|
282
|
+
} = {}
|
|
283
|
+
} = error;
|
|
284
|
+
withScope(scope => {
|
|
285
|
+
scope.setTag('error', 'E_USER');
|
|
286
|
+
scope.setTag('errorCode', code);
|
|
287
|
+
scope.setTag('errorMessage', message);
|
|
288
|
+
captureEvent({
|
|
289
|
+
message: metaMessage || message,
|
|
290
|
+
extra: error
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
};
|
|
@@ -1,11 +1,30 @@
|
|
|
1
|
-
import queryString from'query-string';
|
|
1
|
+
import queryString from 'query-string';
|
|
2
|
+
import { CHECKOUT_PATH, INDEX_PATH } from "../../constants/RoutePaths";
|
|
3
|
+
|
|
4
|
+
/**
|
|
2
5
|
* Generates an url for registrations via the webcheckout. It injects additional parameters
|
|
3
6
|
* for redirections after a successful registration or checkout.
|
|
4
7
|
* @param {string} url The pure register url.
|
|
5
8
|
* @param {string} [redirect=''] An url which is supposed to be opened after registration.
|
|
6
9
|
* @return {string}
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
parsed
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
*/
|
|
11
|
+
const getRegisterUrl = (url, redirect = '') => {
|
|
12
|
+
const parsed = queryString.parseUrl(url);
|
|
13
|
+
|
|
14
|
+
// Generate the final redirect url. Checkout redirects are mapped to the start page.
|
|
15
|
+
const redirectTo = redirect && !redirect.startsWith(CHECKOUT_PATH) ? redirect : INDEX_PATH;
|
|
16
|
+
|
|
17
|
+
// Build the callback data.
|
|
18
|
+
parsed.query.sgcloud_callback_data = JSON.stringify({
|
|
19
|
+
redirectTo
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// Explicitly check if we are about to be redirected to the checkout.
|
|
23
|
+
if (redirect.startsWith(CHECKOUT_PATH)) {
|
|
24
|
+
parsed.query.sgcloud_checkout = 1;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Recombine the url parts.
|
|
28
|
+
return `${parsed.url}?${queryString.stringify(parsed.query)}`;
|
|
29
|
+
};
|
|
30
|
+
export default getRegisterUrl;
|
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import cleanTab from'@shopgate/pwa-core/commands/cleanTab'
|
|
1
|
+
import cleanTab from '@shopgate/pwa-core/commands/cleanTab';
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* @param {boolean} isAndroid Tells if the function was called on an Android device.
|
|
3
|
-
*/
|
|
5
|
+
*/
|
|
6
|
+
const clearUpInAppBrowser = isAndroid => {
|
|
7
|
+
/**
|
|
4
8
|
* Remove leftover pages from the inAppBrowser on Android when the PWA view reappears.
|
|
5
9
|
* Otherwise it the previous page would get visible again when the native back button is pressed.
|
|
6
|
-
*/
|
|
10
|
+
*/
|
|
11
|
+
if (isAndroid) {
|
|
12
|
+
cleanTab({
|
|
13
|
+
targetTab: 'in_app_browser'
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export default clearUpInAppBrowser;
|