only use Nimbus in stage and prod APP_ENV (#3523)
This commit is contained in:
Родитель
f5aba0bdf5
Коммит
a229d4f75a
|
@ -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();
|
||||
|
|
Загрузка…
Ссылка в новой задаче