feat: add githash as query param (#49960)

This commit is contained in:
Oliver Eyton-Williams
2023-04-05 17:45:51 +02:00
committed by GitHub
parent 1d8e9fb0b7
commit 5ea1f4fffc
3 changed files with 12 additions and 4 deletions

View File

@@ -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<ResponseWithData<UserProfileResponse>> {
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({

View File

@@ -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
});

View File

@@ -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<string, unknown>);
if (expectedVariables.length !== actualVariables.length) {