aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-11-22 02:25:10 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-11-22 02:25:10 +0800
commite2a16f3f336c6787501c6a2366e7793a135009f8 (patch)
treea4ecb9d821cbb986a425136f3a2ead3ee4acfd85 /packages
parent70c99082496bbaed5b5ccc37bb259c0a9f02fab5 (diff)
downloaddexon-0x-contracts-e2a16f3f336c6787501c6a2366e7793a135009f8.tar
dexon-0x-contracts-e2a16f3f336c6787501c6a2366e7793a135009f8.tar.gz
dexon-0x-contracts-e2a16f3f336c6787501c6a2366e7793a135009f8.tar.bz2
dexon-0x-contracts-e2a16f3f336c6787501c6a2366e7793a135009f8.tar.lz
dexon-0x-contracts-e2a16f3f336c6787501c6a2366e7793a135009f8.tar.xz
dexon-0x-contracts-e2a16f3f336c6787501c6a2366e7793a135009f8.tar.zst
dexon-0x-contracts-e2a16f3f336c6787501c6a2366e7793a135009f8.zip
Use ROLLBAR_ENABLED constant, and change ROLLBAR_ENVIRONMENT to INSTANT_ENVIRONMENT
Diffstat (limited to 'packages')
-rw-r--r--packages/instant/src/constants.ts3
-rw-r--r--packages/instant/src/util/error_reporter.ts13
-rw-r--r--packages/instant/webpack.config.js28
3 files changed, 22 insertions, 22 deletions
diff --git a/packages/instant/src/constants.ts b/packages/instant/src/constants.ts
index 23660360d..dfa7520f8 100644
--- a/packages/instant/src/constants.ts
+++ b/packages/instant/src/constants.ts
@@ -21,12 +21,13 @@ export const COINBASE_API_BASE_URL = 'https://api.coinbase.com/v2';
export const PROGRESS_STALL_AT_WIDTH = '95%';
export const PROGRESS_FINISH_ANIMATION_TIME_MS = 200;
export const ROLLBAR_CLIENT_TOKEN = process.env.ROLLBAR_CLIENT_TOKEN;
-export const ROLLBAR_ENVIRONMENT = process.env.ROLLBAR_ENVIRONMENT as
+export const INSTANT_ENVIRONMENT = process.env.INSTANT_ENVIRONMENT as
| 'dogfood'
| 'staging'
| 'development'
| 'production'
| undefined;
+export const ROLLBAR_ENABLED = process.env.ROLLBAR_ENABLED;
export const COINBASE_WALLET_IOS_APP_STORE_URL = 'https://itunes.apple.com/us/app/coinbase-wallet/id1278383455?mt=8';
export const COINBASE_WALLET_ANDROID_APP_STORE_URL = 'https://play.google.com/store/apps/details?id=org.toshi&hl=en';
export const COINBASE_WALLET_SITE_URL = 'https://wallet.coinbase.com/';
diff --git a/packages/instant/src/util/error_reporter.ts b/packages/instant/src/util/error_reporter.ts
index c5766b469..89c5b6bd3 100644
--- a/packages/instant/src/util/error_reporter.ts
+++ b/packages/instant/src/util/error_reporter.ts
@@ -1,24 +1,17 @@
import { logUtils } from '@0x/utils';
import * as _ from 'lodash';
-import { ROLLBAR_CLIENT_TOKEN, ROLLBAR_ENVIRONMENT } from '../constants';
+import { INSTANT_ENVIRONMENT, 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 shouldAllowRollbar = () => {
- if (ROLLBAR_ENVIRONMENT === 'development') {
- return process.env.ROLLBAR_FORCE_DEVELOPMENT_REPORT ? true : false;
- }
- return true;
-};
-
let rollbar: any;
// Configures rollbar and sets up error catching
export const setupRollbar = (): any => {
- if (_.isUndefined(rollbar) && ROLLBAR_CLIENT_TOKEN && ROLLBAR_ENVIRONMENT && shouldAllowRollbar()) {
+ if (_.isUndefined(rollbar) && ROLLBAR_CLIENT_TOKEN && INSTANT_ENVIRONMENT && ROLLBAR_ENABLED) {
rollbar = new Rollbar({
accessToken: ROLLBAR_CLIENT_TOKEN,
captureUncaught: true,
@@ -27,7 +20,7 @@ export const setupRollbar = (): any => {
itemsPerMinute: 10,
maxItems: 500,
payload: {
- environment: ROLLBAR_ENVIRONMENT,
+ environment: INSTANT_ENVIRONMENT,
client: {
javascript: {
source_map_enabled: true,
diff --git a/packages/instant/webpack.config.js b/packages/instant/webpack.config.js
index b08fabedf..defdde250 100644
--- a/packages/instant/webpack.config.js
+++ b/packages/instant/webpack.config.js
@@ -89,25 +89,31 @@ module.exports = (env, argv) => {
const environmentName = getEnvironmentName(env, argv);
const outputPath = process.env.WEBPACK_OUTPUT_PATH || 'umd';
+ const envVars = {
+ GIT_SHA: JSON.stringify(GIT_SHA),
+ NPM_PACKAGE_VERSION: JSON.stringify(process.env.npm_package_version),
+ HEAP_ANALYTICS_ID: getHeapAnalyticsId(environmentName),
+ INSTANT_ENVIRONMENT: JSON.stringify(environmentName),
+ ROLLBAR_CLIENT_TOKEN: JSON.stringify(process.env[ROLLBAR_CLIENT_TOKEN_ENV_NAME]),
+ };
+
+ const canRollbarBeEnabled =
+ environmentName === 'development' ? process.env.INSTANT_ROLLBAR_FORCE_DEVELOPMENT_REPORT : true;
+ if (envVars.INSTANT_ENVIRONMENT && envVars.ROLLBAR_CLIENT_TOKEN && canRollbarBeEnabled) {
+ envVars['ROLLBAR_ENABLED'] = JSON.stringify(true);
+ }
+
let plugins = [
new webpack.DefinePlugin({
- 'process.env': {
- GIT_SHA: JSON.stringify(GIT_SHA),
- NPM_PACKAGE_VERSION: JSON.stringify(process.env.npm_package_version),
- HEAP_ANALYTICS_ID: getHeapAnalyticsId(environmentName),
- ROLLBAR_ENVIRONMENT: JSON.stringify(environmentName),
- ROLLBAR_CLIENT_TOKEN: JSON.stringify(process.env[ROLLBAR_CLIENT_TOKEN_ENV_NAME]),
- ROLLBAR_FORCE_DEVELOPMENT_REPORT: JSON.stringify(process.env.INSTANT_ROLLBAR_FORCE_DEVELOPMENT_REPORT),
- },
+ 'process.env': envVars,
}),
];
-
const rollbarPlugin = getRollbarPlugin(environmentName);
if (rollbarPlugin) {
- console.log('Using rollbar plugin');
+ console.log('Using rollbar source map plugin');
plugins = plugins.concat(rollbarPlugin);
} else {
- console.log('Not using rollbar plugin');
+ console.log('Not using rollbar source map plugin');
}
validateRollbarPresence(environmentName, rollbarPlugin);