only use Nimbus in stage and prod APP_ENV (#3523)

This commit is contained in:
Robert Helmer 2023-10-18 10:59:06 -07:00 коммит произвёл GitHub
Родитель f5aba0bdf5
Коммит a229d4f75a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 21 добавлений и 19 удалений

Просмотреть файл

@ -14,26 +14,28 @@ import { captureException } from "@sentry/node";
export async function getExperiments(
userId: string | undefined,
): Promise<unknown> {
const serverUrl = process.env.NIMBUS_SIDECAR_URL;
if (!serverUrl) {
throw new Error("env var NIMBUS_SIDECAR_URL not set");
}
let features;
try {
features = await fetch(`${serverUrl}/v1/features/`, {
headers: {
"Content-Type": "application/json",
},
method: "POST",
body: JSON.stringify({
client_id: userId,
context: { key: "example-key" },
}),
});
} catch (ex) {
console.error(`Could not connect to Cirrus on ${serverUrl}`, ex);
captureException(ex);
if (["stage", "production"].includes(process.env.APP_ENV ?? "local")) {
const serverUrl = process.env.NIMBUS_SIDECAR_URL;
if (!serverUrl) {
throw new Error("env var NIMBUS_SIDECAR_URL not set");
}
try {
features = await fetch(`${serverUrl}/v1/features/`, {
headers: {
"Content-Type": "application/json",
},
method: "POST",
body: JSON.stringify({
client_id: userId,
context: { key: "example-key" },
}),
});
} catch (ex) {
console.error(`Could not connect to Cirrus on ${serverUrl}`, ex);
captureException(ex);
}
}
return features?.json();