diff options
author | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-11-21 03:39:31 +0800 |
---|---|---|
committer | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-11-21 03:39:31 +0800 |
commit | d2dd5f93d21404ee5424792a4e29e843140a7fa1 (patch) | |
tree | c27e345fb6489ae5537cbdb1a930fb5ce06af25f /packages | |
parent | ac1ffe53df90df9ecf4aca972a5625568f0b2a3a (diff) | |
download | dexon-sol-tools-d2dd5f93d21404ee5424792a4e29e843140a7fa1.tar dexon-sol-tools-d2dd5f93d21404ee5424792a4e29e843140a7fa1.tar.gz dexon-sol-tools-d2dd5f93d21404ee5424792a4e29e843140a7fa1.tar.bz2 dexon-sol-tools-d2dd5f93d21404ee5424792a4e29e843140a7fa1.tar.lz dexon-sol-tools-d2dd5f93d21404ee5424792a4e29e843140a7fa1.tar.xz dexon-sol-tools-d2dd5f93d21404ee5424792a4e29e843140a7fa1.tar.zst dexon-sol-tools-d2dd5f93d21404ee5424792a4e29e843140a7fa1.zip |
Introduce rollbar plugin
Diffstat (limited to 'packages')
-rw-r--r-- | packages/instant/.dogfood.discharge.json | 4 | ||||
-rw-r--r-- | packages/instant/.staging.discharge.json | 4 | ||||
-rw-r--r-- | packages/instant/package.json | 3 | ||||
-rw-r--r-- | packages/instant/webpack.config.js | 63 |
4 files changed, 59 insertions, 15 deletions
diff --git a/packages/instant/.dogfood.discharge.json b/packages/instant/.dogfood.discharge.json index ca36b3861..cea579c27 100644 --- a/packages/instant/.dogfood.discharge.json +++ b/packages/instant/.dogfood.discharge.json @@ -1,12 +1,12 @@ { "domain": "0x-instant-dogfood", - "build_command": "WEBPACK_OUTPUT_PATH=public yarn build:umd:prod", + "build_command": "WEBPACK_OUTPUT_PATH=public yarn build:umd:prod --env.dogfood", "upload_directory": "public", "index_key": "index.html", "error_key": "index.html", "trailing_slashes": true, "cache": 3600, - "aws_profile": "default", + "aws_profile": "0xproject", "aws_region": "us-east-1", "cdn": false, "dns_configured": true diff --git a/packages/instant/.staging.discharge.json b/packages/instant/.staging.discharge.json index c917a650b..9e63cb110 100644 --- a/packages/instant/.staging.discharge.json +++ b/packages/instant/.staging.discharge.json @@ -1,12 +1,12 @@ { "domain": "0x-instant-staging", - "build_command": "WEBPACK_OUTPUT_PATH=public yarn build:umd:prod", + "build_command": "WEBPACK_OUTPUT_PATH=public yarn build:umd:prod --env.staging", "upload_directory": "public", "index_key": "index.html", "error_key": "index.html", "trailing_slashes": true, "cache": 3600, - "aws_profile": "default", + "aws_profile": "0xproject", "aws_region": "us-east-1", "cdn": false, "dns_configured": true diff --git a/packages/instant/package.json b/packages/instant/package.json index 1813d61e5..e613e028c 100644 --- a/packages/instant/package.json +++ b/packages/instant/package.json @@ -64,6 +64,7 @@ "react-redux": "^5.0.7", "redux": "^4.0.0", "redux-devtools-extension": "^2.13.5", + "rollbar": "^2.5.0", "styled-components": "^4.0.2", "ts-optchain": "^0.1.1" }, @@ -88,7 +89,9 @@ "make-promises-safe": "^1.1.0", "npm-run-all": "^4.1.2", "nyc": "^11.0.1", + "rollbar-sourcemap-webpack-plugin": "^2.4.0", "shx": "^0.2.2", + "source-map-loader": "^0.2.4", "svg-react-loader": "^0.4.6", "ts-jest": "^23.10.3", "tslint": "5.11.0", diff --git a/packages/instant/webpack.config.js b/packages/instant/webpack.config.js index 161e7d1b0..2375bbd31 100644 --- a/packages/instant/webpack.config.js +++ b/packages/instant/webpack.config.js @@ -1,6 +1,7 @@ const childProcess = require('child_process'); const ip = require('ip'); const path = require('path'); +const RollbarSourceMapPlugin = require('rollbar-sourcemap-webpack-plugin'); const webpack = require('webpack'); // The common js bundle (not this one) is built using tsc. @@ -34,9 +35,59 @@ const getHeapAnalyticsId = environmentName => { return undefined; }; +const getRollbarPlugin = environmentName => { + if (!environmentName) { + return undefined; + } + + const publishToken = process.env.INSTANT_ROLLBAR_PUBLISH_TOKEN; + if (!publishToken) { + return undefined; + } + + let rollbarPublicPath; + if (environmentName === 'dogfood') { + rollbarPublicPath = 'http://0x-instant-dogfood.s3-website-us-east-1.amazonaws.com'; + } else if (environmentName === 'staging') { + rollbarPublicPath = 'http://0x-instant-staging.s3-website-us-east-1.amazonaws.com'; + } + + if (!rollbarPublicPath) { + console.log('No rollbar public path'); + return undefined; + } + + const rollbarPluginOptions = { + accessToken: publishToken, + version: GIT_SHA, + publicPath: rollbarPublicPath, + }; + return new RollbarSourceMapPlugin(rollbarPluginOptions); +}; + module.exports = (env, argv) => { const environmentName = getEnvironmentName(env, argv); const outputPath = process.env.WEBPACK_OUTPUT_PATH || 'umd'; + + 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.INSTANT_ROLLBAR_CLIENT_TOKEN), + }, + }), + ]; + const rollbarPlugin = getRollbarPlugin(environmentName); + if (rollbarPlugin) { + console.log('Using rollbar plugin'); + plugins = plugins.concat(rollbarPlugin); + } else { + console.log('Not using rollbar plugin'); + } + const config = { entry: { instant: './src/index.umd.ts', @@ -47,17 +98,7 @@ module.exports = (env, argv) => { library: 'zeroExInstant', libraryTarget: 'umd', }, - 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.INSTANT_ROLLBAR_CLIENT_TOKEN), - }, - }), - ], + plugins, devtool: 'source-map', resolve: { extensions: ['.js', '.json', '.ts', '.tsx'], |