Skip to content

Commit ed228f2

Browse files
author
rubenmoya
committed
Send client metric only in production
1 parent fc98832 commit ed228f2

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"jasmine": true
77
},
88
"globals": {
9+
"__ENV__": true
910
},
1011
"rules": {
1112
"no-useless-escape": "off"

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@
149149
"test:browser": "grunt dev",
150150
"lint": "eslint .",
151151
"lint:fix": "eslint . --fix",
152-
"build": "rm -rf dist/public; webpack --config webpack/webpack.config.js && webpack --config webpack/webpack.min.config.js",
153-
"build:watch": "webpack -w --config webpack/webpack.config.js",
152+
"build": "rm -rf dist/public; NODE_ENV=production webpack --config webpack/webpack.config.js && NODE_ENV=production webpack --config webpack/webpack.min.config.js",
153+
"build:watch": "NODE_ENV=development webpack -w --config webpack/webpack.config.js",
154154
"build:internal": "grunt build",
155155
"docs": "rm -rf docs/public; jsdoc --configure config/jsdoc/public-conf.json",
156156
"docs:internal": "rm -rf docs/internal; jsdoc --configure config/jsdoc/internal-conf.json",

src/engine.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,20 +291,26 @@ Engine.prototype._buildOptions = function (options) {
291291
* @private
292292
*/
293293
Engine.prototype._buildParams = function (includeFilters) {
294-
var params = {
295-
client: this._windshaftSettings.client
296-
};
294+
var params = {};
295+
296+
if (__ENV__ === 'production') {
297+
params.client = this._windshaftSettings.client;
298+
}
299+
297300
if (includeFilters && !_.isEmpty(this._dataviewsCollection.getFilters())) {
298301
params.filters = this._dataviewsCollection.getFilters();
299302
}
303+
300304
if (this._windshaftSettings.apiKey) {
301305
params.api_key = this._windshaftSettings.apiKey;
302306
return params;
303307
}
308+
304309
if (this._windshaftSettings.authToken) {
305310
params.auth_token = this._windshaftSettings.authToken;
306311
return params;
307312
}
313+
308314
console.warn('Engine initialized with no apiKeys neither authToken');
309315
};
310316

webpack/webpack.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ module.exports = {
1212
},
1313
devtool: 'sourcemap',
1414
plugins: [
15+
new webpack.DefinePlugin({
16+
__ENV__: JSON.stringify(process.env.NODE_ENV)
17+
}),
1518
// Include only the lastest camshaft-reference
1619
new webpack.IgnorePlugin(/^\.\/((?!0\.59\.4).)*\/reference\.json$/),
1720
new webpack.BannerPlugin(banner)

webpack/webpack.min.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ module.exports = {
1212
libraryTarget: 'umd'
1313
},
1414
plugins: [
15+
new webpack.DefinePlugin({
16+
__ENV__: JSON.stringify(process.env.NODE_ENV)
17+
}),
1518
// Include only the lastest camshaft-reference
1619
new webpack.IgnorePlugin(/^\.\/((?!0\.59\.4).)*\/reference\.json$/),
1720
new UglifyJsPlugin(),

0 commit comments

Comments
 (0)