Comparing version 0.3.0 to 0.3.1
@@ -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 @@ } |
@@ -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", |
@@ -148,2 +148,3 @@ Mixpanel-node | ||
- [Nick Chang](https://github.com/maeldur) | ||
- [Michael G](https://github.com/gmichael225) | ||
@@ -150,0 +151,0 @@ License |
@@ -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(); |
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67126
1456
155