diff --git a/lib/classes/Utils.js b/lib/classes/Utils.js index 80c1e34a4..08273965c 100644 --- a/lib/classes/Utils.js +++ b/lib/classes/Utils.js @@ -15,6 +15,7 @@ const writeFileSync = require('../utils/fs/writeFileSync'); const readFileSync = require('../utils/fs/readFileSync'); const isDockerContainer = require('../utils/isDockerContainer'); const version = require('../../package.json').version; +const segment = require('../utils/segment'); const configUtils = require('../utils/config'); class Utils { @@ -151,24 +152,6 @@ class Utils { const options = serverless.processedInput.options; const commands = serverless.processedInput.commands; - const log = (data) => { - const writeKey = 'XXXX'; // TODO: Replace me before release - const auth = `${writeKey}:`; - - return fetch('https://api.segment.io/v1/track', { - headers: { - Authorization: `Basic ${new Buffer(auth).toString('base64')}`, - 'content-type': 'application/json', - }, - method: 'POST', - timeout: '1000', - body: JSON.stringify(data), - }) - .then((response) => response.json()) - .then(() => BbPromise.resolve()) - .catch(() => BbPromise.resolve()); - }; - return new BbPromise((resolve) => { const serverlessDirPath = path.join(os.homedir(), '.serverless'); const statsEnabledFilePath = path.join(serverlessDirPath, 'stats-enabled'); @@ -178,7 +161,7 @@ class Utils { return resolve(); } const config = configUtils.getConfig(); - console.log(config.slsStats); // eslint-disable-line + console.log(config.settings); // eslint-disable-line let userId = uuid.v1(); if (!this.fileExistsSync(statsEnabledFilePath)) { @@ -319,7 +302,7 @@ class Utils { }).then((data) => { // only log the data if it's there if (data) { - log(data); + segment.track(data); } }); }