diff --git a/front/components/navigation/NavigationSidebar.tsx b/front/components/navigation/NavigationSidebar.tsx index 505c3664d4ea..78ed32cde10f 100644 --- a/front/components/navigation/NavigationSidebar.tsx +++ b/front/components/navigation/NavigationSidebar.tsx @@ -184,18 +184,38 @@ export const NavigationSidebar = React.forwardRef< function AppStatusBanner() { const { appStatus } = useAppStatus(); - const { providerStatus } = appStatus ?? {}; - if (!appStatus || !providerStatus) { + if (!appStatus) { return null; } - return ( -
-
{providerStatus.name}
-
{providerStatus.description}
-
- ); + const { providersStatus, dustStatus } = appStatus; + + if (dustStatus) { + return ( +
+
{dustStatus.name}
+
{dustStatus.description}
+
+ Check our{" "} + + status page + {" "} + for updates. +
+
+ ); + } + if (providersStatus) { + return ( +
+
{providersStatus.name}
+
{providersStatus.description}
+
+ ); + } + + return null; } function SubscriptionEndBanner({ endDate }: { endDate: number }) { diff --git a/front/lib/api/config.ts b/front/lib/api/config.ts index de8b4ca96edc..87bcc7eeee35 100644 --- a/front/lib/api/config.ts +++ b/front/lib/api/config.ts @@ -140,8 +140,11 @@ const config = { return EnvironmentConfig.getEnvVariable("TEXT_EXTRACTION_URL"); }, // Status page. - getProviderStatusPageId: (): string => { - return EnvironmentConfig.getEnvVariable("PROVIDER_STATUS_PAGE_ID"); + getStatusPageProvidersPageId: (): string => { + return EnvironmentConfig.getEnvVariable("STATUS_PAGE_PROVIDERS_PAGE_ID"); + }, + getStatusPageDustPageId: (): string => { + return EnvironmentConfig.getEnvVariable("STATUS_PAGE_DUST_PAGE_ID"); }, getStatusPageApiToken: (): string => { return EnvironmentConfig.getEnvVariable("STATUS_PAGE_API_TOKEN"); diff --git a/front/lib/api/status/index.ts b/front/lib/api/status/index.ts index 2cb7f2f3e069..16cafd4cd856 100644 --- a/front/lib/api/status/index.ts +++ b/front/lib/api/status/index.ts @@ -3,33 +3,56 @@ import { cacheWithRedis, isDevelopment } from "@dust-tt/types"; import config from "@app/lib/api/config"; import { getUnresolvedIncidents } from "@app/lib/api/status/status_page"; -async function getProviderStatus() { +async function getProvidersStatus() { if (isDevelopment()) { return null; } - const providerIncidents = await getUnresolvedIncidents({ + const providersIncidents = await getUnresolvedIncidents({ apiToken: config.getStatusPageApiToken(), - pageId: config.getProviderStatusPageId(), + pageId: config.getStatusPageProvidersPageId(), }); - if (providerIncidents.length === 0) { + if (providersIncidents.length > 0) { + const [incident] = providersIncidents; + const { name, incident_updates: incidentUpdates } = incident; + const [latestUpdate] = incidentUpdates; + return { + name, + description: latestUpdate.body, + link: incident.shortlink, + }; + } + + return null; +} + +async function getDustStatus() { + if (isDevelopment()) { return null; } - const [incident] = providerIncidents; - const { name, incident_updates: incidentUpdates } = incident; - const [latestUpdate] = incidentUpdates; + const dustIncidents = await getUnresolvedIncidents({ + apiToken: config.getStatusPageApiToken(), + pageId: config.getStatusPageDustPageId(), + }); + + if (dustIncidents.length > 0) { + const [incident] = dustIncidents; + const { name, incident_updates: incidentUpdates } = incident; + const [latestUpdate] = incidentUpdates; + return { + name, + description: latestUpdate.body, + link: incident.shortlink, + }; + } - return { - name, - description: latestUpdate.body, - link: incident.shortlink, - }; + return null; } export const getProviderStatusMemoized = cacheWithRedis( - getProviderStatus, + getProvidersStatus, () => { return "provider-status"; }, @@ -37,3 +60,13 @@ export const getProviderStatusMemoized = cacheWithRedis( // Status page rate limit is pretty aggressive. 2 * 60 * 1000 ); + +export const getDustStatusMemoized = cacheWithRedis( + getDustStatus, + () => { + return "dust-status"; + }, + // Caches data for 2 minutes to limit frequent API calls. + // Status page rate limit is pretty aggressive. + 2 * 60 * 1000 +); diff --git a/front/pages/api/app-status.ts b/front/pages/api/app-status.ts index 7fb48f58e568..37e3990f7d0e 100644 --- a/front/pages/api/app-status.ts +++ b/front/pages/api/app-status.ts @@ -1,13 +1,21 @@ import type { WithAPIErrorResponse } from "@dust-tt/types"; import type { NextApiRequest, NextApiResponse } from "next"; -import { getProviderStatusMemoized } from "@app/lib/api/status"; +import { + getDustStatusMemoized, + getProviderStatusMemoized, +} from "@app/lib/api/status"; import { withSessionAuthentication } from "@app/lib/api/wrappers"; import { getSession } from "@app/lib/auth"; import { apiError } from "@app/logger/withlogging"; export interface GetAppStatusResponseBody { - providerStatus: { + dustStatus: { + description: string; + link: string; + name: string; + } | null; + providersStatus: { description: string; link: string; name: string; @@ -34,9 +42,12 @@ async function handler( }); } - const providerStatus = await getProviderStatusMemoized(); + const [providersStatus, dustStatus] = await Promise.all([ + getProviderStatusMemoized(), + getDustStatusMemoized(), + ]); - res.status(200).json({ providerStatus }); + res.status(200).json({ providersStatus, dustStatus }); } export default withSessionAuthentication(handler);