From 44000459da47aa804ef4bf9d92251c5f81eda730 Mon Sep 17 00:00:00 2001 From: Asher Date: Thu, 5 Sep 2019 15:26:35 -0500 Subject: [PATCH] Add environment variable for telemetry endpoint --- src/insights.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/insights.ts b/src/insights.ts index ee841620..3a580401 100644 --- a/src/insights.ts +++ b/src/insights.ts @@ -1,5 +1,6 @@ import * as appInsights from "applicationinsights"; import * as https from "https"; +import * as http from "http"; import * as os from "os"; export class TelemetryClient implements appInsights.TelemetryClient { @@ -35,10 +36,8 @@ export class TelemetryClient implements appInsights.TelemetryClient { } catch (error) {} try { - const request = https.request({ - host: "v1.telemetry.coder.com", - port: 443, - path: "/track", + const url = process.env.TELEMETRY_URL || "https://v1.telemetry.coder.com/track"; + const request = (/^http:/.test(url) ? http : https).request(url, { method: "POST", headers: { "Content-Type": "application/json",