diff --git a/lib/api-requestor.js b/lib/api-requestor.js index 2f559a6..eb8e2c2 100644 --- a/lib/api-requestor.js +++ b/lib/api-requestor.js @@ -68,12 +68,12 @@ module.exports = class ApiRequestor { reqOpts.port = this._chargehound.options.port } - if (this._chargehound.options.protocol === 'https://') { - req = https.request(reqOpts).setTimeout(this.getTimeout()) - connectEv = 'secureConnect' - } else { + if (this._chargehound.options.env != null && this._chargehound.options.env === 'local') { req = http.request(reqOpts).setTimeout(this.getTimeout()) connectEv = 'connect' + } else { + req = https.request(reqOpts).setTimeout(this.getTimeout()) + connectEv = 'secureConnect' } req.on('timeout', function () { diff --git a/lib/index.js b/lib/index.js index f0d0e5e..172ec0b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -7,6 +7,7 @@ const CHARGEHOUND_PROTOCOL = 'https://' const CHARGEHOUND_HOST = 'api.chargehound.com' const CHARGEHOUND_BASE_PATH = '/v1/' const CHARGEHOUND_TIMEOUT = 60 * 1000 +const CHARGEHOUND_ENV = null function Chargehound (apiKey, options) { if (!(this instanceof Chargehound)) { @@ -27,6 +28,7 @@ function Chargehound (apiKey, options) { port: options.port || null, protocol: options.protocol || CHARGEHOUND_PROTOCOL, timeout: options.timeout || CHARGEHOUND_TIMEOUT, + env: options.env || CHARGEHOUND_ENV, version: options.version || null }