@capillarytech/creatives-library 6.4.0 → 6.5.0

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 CHANGED
@@ -6,6 +6,8 @@ import createHistory from 'history/lib/createBrowserHistory';
6
6
  import { applyRouterMiddleware, Router, useRouterHistory } from 'react-router';
7
7
  import { syncHistoryWithStore } from 'react-router-redux';
8
8
  import { useScroll } from 'react-router-scroll';
9
+ import Bugsnag from '@bugsnag/js';
10
+ import BugsnagPluginReact from '@bugsnag/plugin-react';
9
11
  import CapV2 from 'v2Containers/Cap';
10
12
  import Cap from 'containers/Cap';
11
13
  import { LocaleProvider } from 'antd';
@@ -35,6 +37,53 @@ const history = syncHistoryWithStore(browserHistory, store, {
35
37
  selectLocationState: makeSelectLocationState(),
36
38
  });
37
39
 
40
+ const bugSnagErrorCallback = event => {
41
+ let userId;
42
+ let userName;
43
+ let userEmail;
44
+ let orgId;
45
+ let orgName;
46
+ try {
47
+ const {
48
+ id,
49
+ firstName,
50
+ lastName,
51
+ loginName,
52
+ proxyOrgList,
53
+ } = JSON.parse(window.localStorage.getItem('user'));
54
+ orgId = window.localStorage.getItem('orgID');
55
+ userId = id;
56
+ userName = `${firstName} ${lastName}`;
57
+ userEmail = loginName;
58
+ orgName = proxyOrgList.find(({orgID}) => orgID === Number(orgId)).orgName;
59
+ } catch (error) {
60
+ userId = '';
61
+ userName = '';
62
+ userEmail = '';
63
+ orgId = '';
64
+ orgName = '';
65
+ }
66
+ event.addMetadata('org', {
67
+ name: orgName,
68
+ id: orgId,
69
+ })
70
+ event.setUser(userId, userEmail, userName);
71
+ };
72
+
73
+ Bugsnag.start({
74
+ // eslint-disable-next-line no-undef
75
+ appVersion: BUGSNAG_APP_VERSION,
76
+ // eslint-disable-next-line no-undef
77
+ apiKey: BUGSNAG_API_KEY,
78
+ releaseStage: window.location.hostname,
79
+ plugins: [new BugsnagPluginReact()],
80
+ onError: bugSnagErrorCallback,
81
+ });
82
+
83
+ const ErrorBoundary = Bugsnag.getPlugin('react').createErrorBoundary(React);
84
+
85
+ export const BugsnagClient = Bugsnag;
86
+
38
87
  const rootRoute = {
39
88
  component: (props) => {
40
89
  // eslint-disable-next-line react/prop-types
@@ -46,20 +95,24 @@ const rootRoute = {
46
95
  childRoutes: createRoutes(store),
47
96
  };
48
97
 
98
+ const ErrorScreen = () => <React.Fragment />;
99
+
49
100
  const render = (messages) => {
50
101
  ReactDOM.render(
51
102
  <Provider store={store}>
52
103
  <LocaleProvider>
53
- <LanguageProvider messages={messages}>
54
- <div>
55
- <Router
56
- history={(history)}
57
- routes={rootRoute}
58
- render={applyRouterMiddleware(useScroll())
59
- }
60
- />
61
- </div>
62
- </LanguageProvider>
104
+ <ErrorBoundary FallbackComponent={ErrorScreen}>
105
+ <LanguageProvider messages={messages}>
106
+ <div>
107
+ <Router
108
+ history={(history)}
109
+ routes={rootRoute}
110
+ render={applyRouterMiddleware(useScroll())
111
+ }
112
+ />
113
+ </div>
114
+ </LanguageProvider>
115
+ </ErrorBoundary>
63
116
  </LocaleProvider>
64
117
  </Provider>,
65
118
  document.getElementById('app')
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "6.4.0",
4
+ "version": "6.5.0",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -13,7 +13,9 @@
13
13
  "license": "LicenseRef-LICENSE",
14
14
  "dependencies": {
15
15
  "@babel/polyfill": "7.4.3",
16
- "@capillarytech/cap-ui-utils": "1.2.4",
16
+ "@bugsnag/js": "^7.2.1",
17
+ "@bugsnag/plugin-react": "^7.2.1",
18
+ "@capillarytech/cap-ui-utils": "1.2.6",
17
19
  "babel-cli": "^6.26.0",
18
20
  "chalk": "1.1.3",
19
21
  "jquery": "^3.3.1",
@@ -28,6 +30,7 @@
28
30
  "redux-immutable": "3.0.8",
29
31
  "reselect": "2.5.4",
30
32
  "styled-components": "^3.2.1",
31
- "whatwg-fetch": "2.0.1"
33
+ "whatwg-fetch": "2.0.1",
34
+ "webpack-bugsnag-plugins": "^1.4.3"
32
35
  }
33
36
  }
@@ -343,16 +343,16 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
343
343
  licenseCode: selectedWeChatAccount.sourceAccountIdentifier,
344
344
  };
345
345
  if (this.props.location.query && this.props.location.query.module !== 'dvs') {
346
- obj.definition.mode = this.props.Edit.templateDetails.mode || get(this, 'props.Edit.templateDetails.definition.mode');
346
+ obj.definition.mode = get(this, 'props.Edit.templateDetails.mode', '') || get(this, 'props.Edit.templateDetails.definition.mode', '');
347
347
  }
348
348
  const android = {};
349
- Object.keys(formData[0]).forEach((data) => {
349
+ Object.keys(formData[0] || {}).forEach((data) => {
350
350
  if (!!formData[0][data] && data !== "tabKey") {
351
351
  android[data] = formData[0][data];
352
352
  }
353
353
  });
354
354
  const ios = {};
355
- Object.keys(formData[1]).forEach((data) => {
355
+ Object.keys(formData[1] || {}).forEach((data) => {
356
356
  if (!!formData[1][data] && data !== "tabKey") {
357
357
  ios[data] = formData[1][data];
358
358
  }