diff --git a/client/src/utils/ajax.ts b/client/src/utils/ajax.ts index b284b6924d8..42b06d21cea 100644 --- a/client/src/utils/ajax.ts +++ b/client/src/utils/ajax.ts @@ -10,7 +10,7 @@ import type { User } from '../redux/prop-types'; -const { apiLocation } = envData; +const { apiLocation, gitHash } = envData; const base = apiLocation; @@ -179,7 +179,7 @@ export function getUserProfile( username: string ): Promise> { const responseWithData = get<{ entities?: ApiUser; result?: string }>( - `/api/users/get-public-profile?username=${username}` + `/api/users/get-public-profile?username=${username}&githash=${gitHash}` ); return responseWithData.then(({ response, data }) => { const { result, user } = parseApiResponseToClientUser({ diff --git a/config/read-env.js b/config/read-env.js index 50d07fbb1e5..90159d02684 100644 --- a/config/read-env.js +++ b/config/read-env.js @@ -1,4 +1,5 @@ const path = require('path'); +const { execSync } = require('child_process'); const envPath = path.resolve(__dirname, '../.env'); const { error } = require('dotenv').config({ path: envPath }); @@ -47,6 +48,10 @@ const locations = { : radioLocation }; +// This is used to identify the current deployment and is trimmed to remove +// the trailing newline. +const gitHash = execSync('git rev-parse HEAD', { encoding: 'utf8' }).trim(); + module.exports = Object.assign(locations, { clientLocale, curriculumLocale, @@ -82,5 +87,6 @@ module.exports = Object.assign(locations, { growthbookUri: !growthbookUri || growthbookUri === 'api_URI_from_Growthbook_dashboard' ? null - : growthbookUri + : growthbookUri, + gitHash }); diff --git a/tools/scripts/build/ensure-env.ts b/tools/scripts/build/ensure-env.ts index 53eef16a3fb..9308ee2b91a 100644 --- a/tools/scripts/build/ensure-env.ts +++ b/tools/scripts/build/ensure-env.ts @@ -57,13 +57,15 @@ if (FREECODECAMP_NODE_ENV !== 'development') { const donationKeys = ['stripePublicKey', 'paypalClientId', 'patreonClientId']; const loggingKeys = ['sentryClientDSN']; const abTestingKeys = ['growthbookUri']; + const diagnosticKeys = ['gitHash']; const expectedVariables = locationKeys.concat( deploymentKeys, searchKeys, donationKeys, loggingKeys, - abTestingKeys + abTestingKeys, + diagnosticKeys ); const actualVariables = Object.keys(env as Record); if (expectedVariables.length !== actualVariables.length) {