aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-11-22 01:35:24 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-11-22 01:35:24 +0800
commit22a31246622e7139185d080cae9bef275087e245 (patch)
treef61c7dae09567e2d70b8d76909eff90017c4ecc1 /packages/instant
parent35b505114842b8c8eac838fff8588adf17f54b45 (diff)
downloaddexon-sol-tools-22a31246622e7139185d080cae9bef275087e245.tar
dexon-sol-tools-22a31246622e7139185d080cae9bef275087e245.tar.gz
dexon-sol-tools-22a31246622e7139185d080cae9bef275087e245.tar.bz2
dexon-sol-tools-22a31246622e7139185d080cae9bef275087e245.tar.lz
dexon-sol-tools-22a31246622e7139185d080cae9bef275087e245.tar.xz
dexon-sol-tools-22a31246622e7139185d080cae9bef275087e245.tar.zst
dexon-sol-tools-22a31246622e7139185d080cae9bef275087e245.zip
Move rollbar setup into function, move setting up into provider
Diffstat (limited to 'packages/instant')
-rw-r--r--packages/instant/src/components/zero_ex_instant_container.tsx3
-rw-r--r--packages/instant/src/components/zero_ex_instant_provider.tsx2
-rw-r--r--packages/instant/src/util/error_reporter.ts66
3 files changed, 35 insertions, 36 deletions
diff --git a/packages/instant/src/components/zero_ex_instant_container.tsx b/packages/instant/src/components/zero_ex_instant_container.tsx
index 6d7cef7fd..47c938472 100644
--- a/packages/instant/src/components/zero_ex_instant_container.tsx
+++ b/packages/instant/src/components/zero_ex_instant_container.tsx
@@ -12,15 +12,12 @@ import { SelectedAssetInstantHeading } from '../containers/selected_asset_instan
import { ColorOption } from '../style/theme';
import { zIndex } from '../style/z_index';
import { OrderProcessState, SlideAnimationState } from '../types';
-import { setupRollbar } from '../util/error_reporter';
import { CSSReset } from './css_reset';
import { SlidingPanel } from './sliding_panel';
import { Container } from './ui/container';
import { Flex } from './ui/flex';
-setupRollbar();
-
export interface ZeroExInstantContainerProps {
orderProcessState: OrderProcessState;
}
diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx
index 9435d8c7c..00d3e95b2 100644
--- a/packages/instant/src/components/zero_ex_instant_provider.tsx
+++ b/packages/instant/src/components/zero_ex_instant_provider.tsx
@@ -15,11 +15,13 @@ import { AccountState, AffiliateInfo, AssetMetaData, Network, OrderSource } from
import { analytics, disableAnalytics } from '../util/analytics';
import { assetUtils } from '../util/asset';
import { errorFlasher } from '../util/error_flasher';
+import { setupRollbar } from '../util/error_reporter';
import { gasPriceEstimator } from '../util/gas_price_estimator';
import { Heartbeater } from '../util/heartbeater';
import { generateAccountHeartbeater, generateBuyQuoteHeartbeater } from '../util/heartbeater_factory';
import { providerStateFactory } from '../util/provider_state_factory';
+setupRollbar();
fonts.include();
export type ZeroExInstantProviderProps = ZeroExInstantProviderRequiredProps &
diff --git a/packages/instant/src/util/error_reporter.ts b/packages/instant/src/util/error_reporter.ts
index a03b5e65e..c5766b469 100644
--- a/packages/instant/src/util/error_reporter.ts
+++ b/packages/instant/src/util/error_reporter.ts
@@ -1,4 +1,5 @@
import { logUtils } from '@0x/utils';
+import * as _ from 'lodash';
import { ROLLBAR_CLIENT_TOKEN, ROLLBAR_ENVIRONMENT } from '../constants';
@@ -15,41 +16,40 @@ const shouldAllowRollbar = () => {
};
let rollbar: any;
-if (ROLLBAR_CLIENT_TOKEN && ROLLBAR_ENVIRONMENT && shouldAllowRollbar()) {
- rollbar = new Rollbar({
- accessToken: ROLLBAR_CLIENT_TOKEN,
- captureUncaught: true,
- captureUnhandledRejections: true,
- enabled: true,
- itemsPerMinute: 10,
- maxItems: 500,
- payload: {
- environment: ROLLBAR_ENVIRONMENT,
- client: {
- javascript: {
- source_map_enabled: true,
- code_version: process.env.GIT_SHA,
- guess_uncaught_frames: true,
+// Configures rollbar and sets up error catching
+export const setupRollbar = (): any => {
+ if (_.isUndefined(rollbar) && ROLLBAR_CLIENT_TOKEN && ROLLBAR_ENVIRONMENT && shouldAllowRollbar()) {
+ rollbar = new Rollbar({
+ accessToken: ROLLBAR_CLIENT_TOKEN,
+ captureUncaught: true,
+ captureUnhandledRejections: true,
+ enabled: true,
+ itemsPerMinute: 10,
+ maxItems: 500,
+ payload: {
+ environment: ROLLBAR_ENVIRONMENT,
+ client: {
+ javascript: {
+ source_map_enabled: true,
+ code_version: process.env.GIT_SHA,
+ guess_uncaught_frames: true,
+ },
},
},
- },
- uncaughtErrorLevel: 'error',
- ignoredMessages: [
- // Errors from the third-party scripts
- 'Script error',
- // Network errors or ad-blockers
- 'TypeError: Failed to fetch',
- 'Exchange has not been deployed to detected network (network/artifact mismatch)',
- // Source: https://groups.google.com/a/chromium.org/forum/#!topic/chromium-discuss/7VU0_VvC7mE
- "undefined is not an object (evaluating '__gCrWeb.autofill.extractForms')",
- // Source: http://stackoverflow.com/questions/43399818/securityerror-from-facebook-and-cross-domain-messaging
- 'SecurityError (DOM Exception 18)',
- ],
- });
-}
-
-export const setupRollbar = (): any => {
- return rollbar;
+ uncaughtErrorLevel: 'error',
+ ignoredMessages: [
+ // Errors from the third-party scripts
+ 'Script error',
+ // Network errors or ad-blockers
+ 'TypeError: Failed to fetch',
+ 'Exchange has not been deployed to detected network (network/artifact mismatch)',
+ // Source: https://groups.google.com/a/chromium.org/forum/#!topic/chromium-discuss/7VU0_VvC7mE
+ "undefined is not an object (evaluating '__gCrWeb.autofill.extractForms')",
+ // Source: http://stackoverflow.com/questions/43399818/securityerror-from-facebook-and-cross-domain-messaging
+ 'SecurityError (DOM Exception 18)',
+ ],
+ });
+ }
};
export const errorReporter = {