Skip to content

Commit

Permalink
improvement: added more headers to checkForUpdates
Browse files Browse the repository at this point in the history
  • Loading branch information
10ko committed Sep 11, 2019
1 parent df8ca4b commit 8f1c443
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions garden-service/src/cli/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import axios from "axios"
import chalk from "chalk"
import ci = require("ci-info")
import { pathExists } from "fs-extra"
import { difference, flatten, range, reduce } from "lodash"
import moment = require("moment")
import { platform, release } from "os"
import qs = require("qs")

import {
ChoicesParameter,
ParameterValues,
Expand All @@ -18,15 +25,10 @@ import {
} from "../exceptions"
import { LogLevel } from "../logger/log-node"
import { getEnumKeys, getPackageVersion } from "../util/util"
import axios from "axios"
import qs = require("qs")
import { platform, release } from "os"
import { LogEntry } from "../logger/log-entry"
import { STATIC_DIR, VERSION_CHECK_URL } from "../constants"
import { printWarningMessage } from "../logger/util"
import { GlobalConfigStore, globalConfigKeys } from "../config-store"
import moment = require("moment")
import { pathExists } from "fs-extra"

// Parameter types T which map between the Parameter<T> class and the Sywac cli library.
// In case we add types that aren't supported natively by Sywac, see: http://sywac.io/docs/sync-config.html#custom
Expand Down Expand Up @@ -239,7 +241,15 @@ export async function checkForUpdates(config: GlobalConfigStore, logger: LogEntr
platformVersion: release(),
}
try {
const res = await axios.get(`${VERSION_CHECK_URL}?${qs.stringify(query)}`)
const globalConfig = await config.get()
const headers = {}
headers["X-user-id"] = globalConfig.analytics ? globalConfig.analytics.userId : "unknown"
headers["X-ci-check"] = ci.isCI
if (ci.isCI) {
headers["X-ci-name"] = ci.name
}

const res = await axios.get(`${VERSION_CHECK_URL}?${qs.stringify(query)}`, { headers })
const configObj = await config.get()
const showMessage = (configObj.lastVersionCheck
&& moment().subtract(1, "days").isAfter(moment(configObj.lastVersionCheck.lastRun)))
Expand Down

0 comments on commit 8f1c443

Please sign in to comment.