From 328bec6ef5a08e2fbb642b658acf901baee3c90d Mon Sep 17 00:00:00 2001 From: Josh GM Walker <56300765+Josh-Walker-GM@users.noreply.github.com> Date: Sat, 4 Nov 2023 23:12:22 +0000 Subject: [PATCH] telemetry: Insight into gitpod adoption (#9365) **Changes** 1. Checks for environment variables that starts with `GITPOD_` and records whether any are found. This should allow us to gain an insight into gitpod usage. I guess there could be false positive if non-gitpod machines have env vars with `GITPOD_` but we can likely assume this to be highly unlikely? --- packages/cli/src/telemetry/resource.js | 8 ++++++++ packages/create-redwood-app/src/telemetry.js | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/packages/cli/src/telemetry/resource.js b/packages/cli/src/telemetry/resource.js index 42060d7eecb7..976264031b75 100644 --- a/packages/cli/src/telemetry/resource.js +++ b/packages/cli/src/telemetry/resource.js @@ -59,6 +59,13 @@ export async function getResources() { const cpu = await system.cpu() const mem = await system.mem() + // Record any specific development environment + let developmentEnvironment = undefined + // Gitpod + if (Object.keys(process.env).some((key) => key.startsWith('GITPOD_'))) { + developmentEnvironment = 'gitpod' + } + // Must only call getConfig() once the project is setup - so not within telemetry for CRWA // Default to 'webpack' for new projects const webBundler = getConfig().web.bundler @@ -104,6 +111,7 @@ export async function getResources() { 'env.node_env': process.env.NODE_ENV || null, 'ci.redwood': !!process.env.REDWOOD_CI, 'ci.isci': ci.isCI, + 'dev.environment': developmentEnvironment, complexity, sides, experiments: JSON.stringify(experiments), diff --git a/packages/create-redwood-app/src/telemetry.js b/packages/create-redwood-app/src/telemetry.js index 973f1889e105..2f183e021840 100644 --- a/packages/create-redwood-app/src/telemetry.js +++ b/packages/create-redwood-app/src/telemetry.js @@ -57,6 +57,13 @@ export async function startTelemetry() { const cpu = await system.cpu() const mem = await system.mem() + // Record any specific development environment + let developmentEnvironment = undefined + // Gitpod + if (Object.keys(process.env).some((key) => key.startsWith('GITPOD_'))) { + developmentEnvironment = 'gitpod' + } + const resource = Resource.default().merge( new Resource({ [SemanticResourceAttributes.SERVICE_NAME]: packageName, @@ -73,6 +80,7 @@ export async function startTelemetry() { 'env.node_env': process.env.NODE_ENV || null, 'ci.redwood': !!process.env.REDWOOD_CI, 'ci.isci': ci.isCI, + 'dev.environment': developmentEnvironment, uid: UID, }) )