aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util
diff options
context:
space:
mode:
authorSteve Klebanoff <steve@0xproject.com>2018-12-06 05:48:54 +0800
committerGitHub <noreply@github.com>2018-12-06 05:48:54 +0800
commite6acc0416a0de54d53c8f50e522ee2a952c58965 (patch)
tree795b2a0c9220886218f2cd336a32fe0a3b7a5551 /packages/instant/src/util
parente839e698f9360d3632f4717f8e37699b6c14dd78 (diff)
parent69d4e330cf312af99cf547add9cd2106e492c563 (diff)
downloaddexon-sol-tools-e6acc0416a0de54d53c8f50e522ee2a952c58965.tar
dexon-sol-tools-e6acc0416a0de54d53c8f50e522ee2a952c58965.tar.gz
dexon-sol-tools-e6acc0416a0de54d53c8f50e522ee2a952c58965.tar.bz2
dexon-sol-tools-e6acc0416a0de54d53c8f50e522ee2a952c58965.tar.lz
dexon-sol-tools-e6acc0416a0de54d53c8f50e522ee2a952c58965.tar.xz
dexon-sol-tools-e6acc0416a0de54d53c8f50e522ee2a952c58965.tar.zst
dexon-sol-tools-e6acc0416a0de54d53c8f50e522ee2a952c58965.zip
Merge pull request #1389 from 0xProject/fix/instant-rollbar-localhost
[instant] Don't report localhost errors to Rollbar
Diffstat (limited to 'packages/instant/src/util')
-rw-r--r--packages/instant/src/util/analytics.ts4
-rw-r--r--packages/instant/src/util/error_reporter.ts23
2 files changed, 22 insertions, 5 deletions
diff --git a/packages/instant/src/util/analytics.ts b/packages/instant/src/util/analytics.ts
index 6da37bedb..6da52db16 100644
--- a/packages/instant/src/util/analytics.ts
+++ b/packages/instant/src/util/analytics.ts
@@ -2,7 +2,7 @@ import { BuyQuote } from '@0x/asset-buyer';
import { BigNumber } from '@0x/utils';
import * as _ from 'lodash';
-import { GIT_SHA, HEAP_ENABLED, INSTANT_DISCHARGE_TARGET, NPM_PACKAGE_VERSION } from '../constants';
+import { GIT_SHA, HEAP_ENABLED, INSTANT_DISCHARGE_TARGET, NODE_ENV, NPM_PACKAGE_VERSION } from '../constants';
import {
AffiliateInfo,
Asset,
@@ -156,7 +156,7 @@ export const analytics = {
affiliateFeePercent,
selectedAssetName: selectedAsset ? selectedAsset.metaData.name : 'none',
selectedAssetData: selectedAsset ? selectedAsset.assetData : 'none',
- instantEnvironment: INSTANT_DISCHARGE_TARGET || `Local ${process.env.NODE_ENV}`,
+ instantEnvironment: INSTANT_DISCHARGE_TARGET || `Local ${NODE_ENV}`,
};
return eventOptions;
},
diff --git a/packages/instant/src/util/error_reporter.ts b/packages/instant/src/util/error_reporter.ts
index b1824eaf9..8d7481684 100644
--- a/packages/instant/src/util/error_reporter.ts
+++ b/packages/instant/src/util/error_reporter.ts
@@ -1,17 +1,34 @@
import { logUtils } from '@0x/utils';
import * as _ from 'lodash';
-import { GIT_SHA, HOST_DOMAINS, INSTANT_DISCHARGE_TARGET, ROLLBAR_CLIENT_TOKEN, ROLLBAR_ENABLED } from '../constants';
+import {
+ GIT_SHA,
+ HOST_DOMAINS_EXTERNAL,
+ HOST_DOMAINS_LOCAL,
+ INSTANT_DISCHARGE_TARGET,
+ NODE_ENV,
+ ROLLBAR_CLIENT_TOKEN,
+ ROLLBAR_ENABLED,
+} from '../constants';
// Import version of Rollbar designed for embedded components
// See https://docs.rollbar.com/docs/using-rollbarjs-inside-an-embedded-component
// tslint:disable-next-line:no-var-requires
const Rollbar = require('rollbar/dist/rollbar.noconflict.umd');
+const getRollbarHostDomains = (): string[] => {
+ if (NODE_ENV === 'development') {
+ return HOST_DOMAINS_EXTERNAL.concat(HOST_DOMAINS_LOCAL);
+ } else {
+ return HOST_DOMAINS_EXTERNAL;
+ }
+};
+
let rollbar: any;
// Configures rollbar and sets up error catching
export const setupRollbar = (): any => {
if (_.isUndefined(rollbar) && ROLLBAR_CLIENT_TOKEN && ROLLBAR_ENABLED) {
+ const hostDomains = getRollbarHostDomains();
rollbar = new Rollbar({
accessToken: ROLLBAR_CLIENT_TOKEN,
captureUncaught: true,
@@ -20,7 +37,7 @@ export const setupRollbar = (): any => {
itemsPerMinute: 10,
maxItems: 500,
payload: {
- environment: INSTANT_DISCHARGE_TARGET || `Local ${process.env.NODE_ENV}`,
+ environment: INSTANT_DISCHARGE_TARGET || `Local ${NODE_ENV}`,
client: {
javascript: {
source_map_enabled: true,
@@ -29,7 +46,7 @@ export const setupRollbar = (): any => {
},
},
},
- hostWhiteList: HOST_DOMAINS,
+ hostWhiteList: hostDomains,
uncaughtErrorLevel: 'error',
ignoredMessages: [
// Errors from the third-party scripts