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