+14
-3
@@ -22,6 +22,8 @@ /* | ||
| // Default config | ||
| metrics.config = { | ||
| test: false, | ||
| debug: false, | ||
| verbose: false | ||
| verbose: false, | ||
| host: 'api.mixpanel.com' | ||
| }; | ||
@@ -58,3 +60,4 @@ | ||
| var request_options = { | ||
| host: 'api.mixpanel.com', | ||
| host: metrics.config.host, | ||
| port: metrics.config.port, | ||
| headers: {} | ||
@@ -691,3 +694,11 @@ }; | ||
| if (config.hasOwnProperty(c)) { | ||
| metrics.config[c] = config[c]; | ||
| if (c == "host") { // Split host, into host and port. | ||
| metrics.config.host = config[c].split(':')[0]; | ||
| var port = config[c].split(':')[1]; | ||
| if (port) { | ||
| metrics.config.port = Number(port); | ||
| } | ||
| } else { | ||
| metrics.config[c] = config[c]; | ||
| } | ||
| } | ||
@@ -694,0 +705,0 @@ } |
+1
-1
@@ -10,3 +10,3 @@ { | ||
| ], | ||
| "version": "0.3.0", | ||
| "version": "0.3.1", | ||
| "homepage": "https://github.com/mixpanel/mixpanel-node", | ||
@@ -13,0 +13,0 @@ "author": "Carl Sverre", |
+1
-0
@@ -148,2 +148,3 @@ Mixpanel-node | ||
| - [Nick Chang](https://github.com/maeldur) | ||
| - [Michael G](https://github.com/gmichael225) | ||
@@ -150,0 +151,0 @@ License |
+1
-1
@@ -11,3 +11,3 @@ var Mixpanel = require('../lib/mixpanel-node'); | ||
| test.deepEqual(this.mixpanel.config, | ||
| { test: false, debug: false, verbose: false }, | ||
| { test: false, debug: false, verbose: false, host: 'api.mixpanel.com' }, | ||
| "default config is incorrect"); | ||
@@ -14,0 +14,0 @@ test.done(); |
+29
-0
@@ -70,3 +70,32 @@ var Mixpanel = require('../lib/mixpanel-node'), | ||
| this.http_emitter.emit('error', 'error'); | ||
| }, | ||
| "uses correct hostname": function(test) { | ||
| var host = 'testhost.fakedomain'; | ||
| var customHostnameMixpanel = Mixpanel.init('token', { host: host }) | ||
| var expected_http_get = { | ||
| host: host | ||
| }; | ||
| customHostnameMixpanel.send_request('', {}); | ||
| test.ok(http.get.calledWithMatch(expected_http_get), "send_request didn't call http.get with correct hostname"); | ||
| test.done(); | ||
| }, | ||
| "uses correct port": function(test) { | ||
| var host = 'testhost.fakedomain:1337'; | ||
| var customHostnameMixpanel = Mixpanel.init('token', { host: host }) | ||
| var expected_http_get = { | ||
| host: 'testhost.fakedomain', | ||
| port: 1337 | ||
| }; | ||
| customHostnameMixpanel.send_request('', {}); | ||
| test.ok(http.get.calledWithMatch(expected_http_get), "send_request didn't call http.get with correct hostname and port"); | ||
| test.done(); | ||
| } | ||
| }; |
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
67126
2.34%1456
2.25%155
0.65%