Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat: Add status information on integrations screen directly (#18718)

jordibosch203ef11ab9f937
diff --git a/web/src/components/ui/StatusBadge/StatusBadge.stories.tsx b/web/src/components/ui/StatusBadge/StatusBadge.stories.tsx
index 1c430ad92e..ceaf9612e3 100644
--- a/web/src/components/ui/StatusBadge/StatusBadge.stories.tsx
+++ b/web/src/components/ui/StatusBadge/StatusBadge.stories.tsx
@@ -11,6 +11,7 @@ const representativeStatuses = [
"pending",
"delayed",
"disabled",
+ "not_configured",
"paused",
"completed",
"error",
diff --git a/web/src/components/ui/StatusBadge/StatusBadge.tsx b/web/src/components/ui/StatusBadge/StatusBadge.tsx
index e051734818..807f7bfe7e 100644
--- a/web/src/components/ui/StatusBadge/StatusBadge.tsx
+++ b/web/src/components/ui/StatusBadge/StatusBadge.tsx
@@ -22,6 +22,7 @@ const statusCategories = {
pending: ["pending", "waiting", "queued", "running", "processing"],
delayed: ["delayed"],
inactive: ["disabled", "inactive", "archived", "cancelled", "debug"],
+ notConfigured: ["not_configured"],
paused: ["paused"],
completed: ["completed", "done", "finished"],
error: ["error", "failed", "triggered"],
@@ -69,6 +70,12 @@ const categoryStyles: Record<
dotOuter: "bg-muted-foreground",
dotInner: "bg-muted-foreground",
},
+ notConfigured: {
+ background: "bg-muted-gray/50",
+ text: "text-muted-foreground",
+ dotOuter: "bg-muted-foreground/50",
+ dotInner: "bg-muted-foreground/50",
+ },
paused: {
background: "bg-light-yellow",
text: "text-dark-yellow",
@@ -158,7 +165,9 @@ export const StatusBadge = ({
)}
{showText && type && (
<span>
- {preserveCase ? type : type[0].toUpperCase() + type.slice(1)}
+ {preserveCase
+ ? type
+ : type[0].toUpperCase() + type.slice(1).replaceAll("_", " ")}
</span>
)}
{children}
diff --git a/web/src/features/blobstorage-integration/BlobStorageIntegrationPage.tsx b/web/src/features/blobstorage-integration/BlobStorageIntegrationPage.tsx
index efa69dee7d..39166f6167 100644
--- a/web/src/features/blobstorage-integration/BlobStorageIntegrationPage.tsx
+++ b/web/src/features/blobstorage-integration/BlobStorageIntegrationPage.tsx
@@ -7,64 +7,19 @@ import { Card } from "@/src/components/ui/card";
import { IntegrationSettingsSkeleton } from "@/src/features/analytics-integrations";
import Link from "next/link";
import { useRouter } from "next/router";
-import { useHasEntitlement } from "@/src/features/entitlements";
-import { useHasProjectAccess } from "@/src/features/rbac";
-import { api, type RouterOutputs } from "@/src/utils/api";
-import { deriveSyncStatus } from "@/src/features/blobstorage-integration/deriveSyncStatus";
-import { type BlobStorageSyncStatus } from "@/src/features/blobstorage-integration/types";
import { BlobStorageIntegrationContainer } from "@/src/features/blobstorage-integration/components/BlobStorageIntegrationContainer";
+import { useBlobStorageIntegration } from "@/src/features/blobstorage-integration/useBlobStorageIntegration";
import { BlobStorageStatusSection } from "@/src/features/blobstorage-integration/components/BlobStorageStatusSection";
-const syncStatusToBadge: Record<BlobStorageSyncStatus, string> = {
- up_to_date: "active",
- running: "running",
- queued: "queued",
- idle: "pending",
- disabled: "disabled",
- error: "error",
-};
-
-const syncStatusFromConfig = (
- config: NonNullable<RouterOutputs["blobStorageIntegration"]["get"]["config"]>,
-): BlobStorageSyncStatus =>
- deriveSyncStatus({
- enabled: config.enabled,
- lastError: config.lastError,
- lastSyncAt: config.lastSyncAt ? new Date(config.lastSyncAt) : null,
- nextSyncAt: config.nextSyncAt ? new Date(config.nextSyncAt) : null,
- runStartedAt: config.runStartedAt ? new Date(config.runStartedAt) : null,
- });
-
export default function BlobStorageIntegrationPage() {
const router = useRouter();
const projectId = router.query.projectId as string;
- const hasAccess = useHasProjectAccess({
- projectId,
- scope: "integrations:CRUD",
- });
- const hasEntitlement = useHasEntitlement("scheduled-blob-exports");
- const canLoadConfig = hasAccess && hasEntitlement;
- const state = api.blobStorageIntegration.get.useQuery(
- { projectId },
- {
- enabled: canLoadConfig,
- refetchOnMount: false,
- refetchOnWindowFocus: false,
- refetchOnReconnect: false,
- staleTime: 50 * 60 * 1000, // 50 minutes
- refetchInterval: (query) => {
- const cfg = query.state.data?.config;
- if (!cfg) return false;
- const status = syncStatusFromConfig(cfg);
- return status === "running" || status === "queued" ? 5_000 : false;
- },
- },
- );
-
- const syncStatus =
- state.isLoading || !canLoadConfig || !state.data?.config
- ? undefined
- : syncStatusFromConfig(state.data.config);
+ const {
+ hasAccess,
+ hasEntitlement,
+ query: state,
+ status,
+ } = useBlobStorageIntegration(projectId);
return (
<ContainerPage
@@ -73,9 +28,7 @@ export default function BlobStorageIntegrationPage() {
breadcrumb: [
{ name: "Settings", href: `/project/${projectId}/settings` },
],
- actionButtonsLeft: syncStatus && (
- <StatusBadge type={syncStatusToBadge[syncStatus]} />
- ),
+ actionButtonsLeft: status && <StatusBadge type={status} />,
actionButtonsRight: (
<Button asChild variant="secondary">
<Link
diff --git a/web/src/features/blobstorage-integration/deriveSyncStatus.ts b/web/src/features/blobstorage-integration/deriveSyncStatus.ts
index 0b8500ad72..b735b48990 100644
--- a/web/src/features/blobstorage-integration/deriveSyncStatus.ts
+++ b/web/src/features/blobstorage-integration/deriveSyncStatus.ts
@@ -1,5 +1,15 @@
+import type { Status } from "@/src/components/ui/StatusBadge/StatusBadge";
import type { BlobStorageSyncStatus } from "@/src/features/blobstorage-integration/types";
+export const syncStatusToBadge: Record<BlobStorageSyncStatus, Status> = {
+ up_to_date: "active",
+ running: "running",
+ queued: "queued",
+ idle: "pending",
+ disabled: "disabled",
+ error: "error",
+};
+
const MAX_RUN_AGE_MS = 2 * 60 * 60 * 1000;
export function deriveSyncStatus(integration: {
diff --git a/web/src/features/blobstorage-integration/useBlobStorageIntegration.clienttest.ts b/web/src/features/blobstorage-integration/useBlobStorageIntegration.clienttest.ts
new file mode 100644
index 0000000000..69d6293f47
--- /dev/null
+++ b/web/src/features/blobstorage-integration/useBlobStorageIntegration.clienttest.ts
@@ -0,0 +1,30 @@
+// @vitest-environment node
+
+import { getBlobStorageStatus } from "./useBlobStorageIntegration";
+
+const healthyConfig = {
+ enabled: true,
+ lastError: null,
+ lastSyncAt: new Date("2026-01-01T00:00:00Z"),
+ nextSyncAt: new Date(Date.now() + 60 * 60 * 1000),
+ runStartedAt: null,
+};
+
+describe("getBlobStorageStatus", () => {
+ it("returns undefined when not configured", () => {
+ expect(getBlobStorageStatus(null)).toBeUndefined();
+ });
+
+ it.each([
+ [{}, "active"],
+ [{ enabled: false }, "disabled"],
+ [{ lastError: "Access denied" }, "error"],
+ [{ runStartedAt: new Date() }, "running"],
+ [{ nextSyncAt: new Date(Date.now() - 1000) }, "queued"],
+ [{ lastSyncAt: null }, "pending"],
+ ])("maps %o to %s", (override, expected) => {
+ expect(getBlobStorageStatus({ ...healthyConfig, ...override })).toBe(
+ expected,
+ );
+ });
+});
diff --git a/web/src/features/blobstorage-integration/useBlobStorageIntegration.ts b/web/src/features/blobstorage-integration/useBlobStorageIntegration.ts
new file mode 100644
index 0000000000..9ac6fa1685
--- /dev/null
+++ b/web/src/features/blobstorage-integration/useBlobStorageIntegration.ts
@@ -0,0 +1,49 @@
+import { type Status } from "@/src/components/ui/StatusBadge/StatusBadge";
+import { useHasEntitlement } from "@/src/features/entitlements";
+import { useHasProjectAccess } from "@/src/features/rbac";
+import { api } from "@/src/utils/api";
+import {
+ deriveSyncStatus,
+ syncStatusToBadge,
+} from "@/src/features/blobstorage-integration/deriveSyncStatus";
+
+export function getBlobStorageStatus(
+ config: Parameters<typeof deriveSyncStatus>[0] | null,
+): Status | undefined {
+ if (!config) return undefined;
+ return syncStatusToBadge[deriveSyncStatus(config)];
+}
+
+/** Shared by the integration page and the integrations overview card. */
+export function useBlobStorageIntegration(
+ projectId: string,
+ meta?: Record<string, unknown>,
+) {
+ const hasAccess = useHasProjectAccess({
+ projectId,
+ scope: "integrations:CRUD",
+ });
+ const hasEntitlement = useHasEntitlement("scheduled-blob-exports");
+ const query = api.blobStorageIntegration.get.useQuery(
+ { projectId },
+ {
+ enabled: hasAccess && hasEntitlement,
+ meta,
+ refetchOnMount: false,
+ refetchOnWindowFocus: false,
+ refetchOnReconnect: false,
+ staleTime: 50 * 60 * 1000, // 50 minutes
+ // Poll while an export is in flight so the badge moves on by itself.
+ refetchInterval: (query) => {
+ const status = getBlobStorageStatus(query.state.data?.config ?? null);
+ return status === "running" || status === "queued" ? 5_000 : false;
+ },
+ },
+ );
+ const status =
+ hasAccess && hasEntitlement && query.data
+ ? getBlobStorageStatus(query.data.config)
+ : undefined;
+
+ return { hasAccess, hasEntitlement, query, status };
+}
diff --git a/web/src/features/external-media-storage/ExternalMediaStoragePage.tsx b/web/src/features/external-media-storage/ExternalMediaStoragePage.tsx
index 6ef6a0bd9e..045f6962bd 100644
--- a/web/src/features/external-media-storage/ExternalMediaStoragePage.tsx
+++ b/web/src/features/external-media-storage/ExternalMediaStoragePage.tsx
@@ -8,13 +8,14 @@ import { ConfirmationDialogController } from "@/src/components/design-system/Con
import { DialogController } from "@/src/components/design-system/DialogController/DialogController";
import { Tooltip } from "@/src/components/design-system/Tooltip/Tooltip";
import { Button } from "@/src/components/ui/button";
+import { StatusBadge } from "@/src/components/ui/StatusBadge/StatusBadge";
import { Card } from "@/src/components/ui/card";
import { IntegrationSettingsSkeleton } from "@/src/features/analytics-integrations";
import { ExternalMediaStorageForm } from "@/src/features/external-media-storage/components/ExternalMediaStorageForm/ExternalMediaStorageForm";
import { TestMediaObjectDialog } from "@/src/features/external-media-storage/components/TestMediaObjectDialog/TestMediaObjectDialog";
import { testSignedMediaUrlCors } from "@/src/features/external-media-storage/fns/testSignedMediaUrlCors";
import { type ExternalMediaStorageFormValues } from "@/src/features/external-media-storage/types";
-import { useHasProjectAccess } from "@/src/features/rbac";
+import { useExternalMediaStorage } from "@/src/features/external-media-storage/useExternalMediaStorage";
import { showErrorToast, showSuccessToast } from "@/src/features/notifications";
import { api } from "@/src/utils/api";
import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";
@@ -35,22 +36,14 @@ const defaultValues: ExternalMediaStorageFormValues = {
export default function ExternalMediaStoragePage() {
const router = useRouter();
const projectId = router.query.projectId as string;
- const hasAccess = useHasProjectAccess({
- projectId,
- scope: "integrations:CRUD",
- });
- const featureAvailability =
- api.externalMediaStorage.isFeatureEnabled.useQuery(
- { projectId },
- { enabled: Boolean(projectId) },
- );
- const isFeatureEnabled = featureAvailability.data === true;
- const canLoadConfig = Boolean(projectId && hasAccess && isFeatureEnabled);
+ const {
+ hasAccess,
+ featureAvailability,
+ isFeatureEnabled,
+ query: configuration,
+ status,
+ } = useExternalMediaStorage(projectId);
const utils = api.useUtils();
- const configuration = api.externalMediaStorage.get.useQuery(
- { projectId },
- { enabled: canLoadConfig },
- );
const updateMutation = api.externalMediaStorage.update.useMutation({
onSuccess: async () => {
await utils.externalMediaStorage.get.invalidate({ projectId });
@@ -173,6 +166,7 @@ export default function ExternalMediaStoragePage() {
breadcrumb: [
{ name: "Settings", href: `/project/${projectId}/settings` },
],
+ actionButtonsLeft: status && <StatusBadge type={status} />,
actionButtonsRight: (
<Button asChild variant="secondary">
<Link
diff --git a/web/src/features/external-media-storage/useExternalMediaStorage.clienttest.ts b/web/src/features/external-media-storage/useExternalMediaStorage.clienttest.ts
new file mode 100644
index 0000000000..73b17a6e1f
--- /dev/null
+++ b/web/src/features/external-media-storage/useExternalMediaStorage.clienttest.ts
@@ -0,0 +1,12 @@
+// @vitest-environment node
+
+import { getExternalMediaStorageStatus } from "./useExternalMediaStorage";
+
+describe("getExternalMediaStorageStatus", () => {
+ it.each([
+ [null, undefined],
+ [{ bucketName: "media" }, "active"],
+ ])("maps %o to %s", (config, expected) => {
+ expect(getExternalMediaStorageStatus(config)).toBe(expected);
+ });
+});
diff --git a/web/src/features/external-media-storage/useExternalMediaStorage.ts b/web/src/features/external-media-storage/useExternalMediaStorage.ts
new file mode 100644
index 0000000000..d01e9268f8
--- /dev/null
+++ b/web/src/features/external-media-storage/useExternalMediaStorage.ts
@@ -0,0 +1,35 @@
+import { type Status } from "@/src/components/ui/StatusBadge/StatusBadge";
+import { useHasProjectAccess } from "@/src/features/rbac";
+import { api } from "@/src/utils/api";
+
+export function getExternalMediaStorageStatus(
+ config: object | null,
+): Status | undefined {
+ return config ? "active" : undefined;
+}
+
+/** Shared by the integration page and the integrations overview card. */
+export function useExternalMediaStorage(
+ projectId: string,
+ meta?: Record<string, unknown>,
+) {
+ const hasAccess = useHasProjectAccess({
+ projectId,
+ scope: "integrations:CRUD",
+ });
+ const featureAvailability =
+ api.externalMediaStorage.isFeatureEnabled.useQuery(
+ { projectId },
+ { enabled: Boolean(projectId) },
+ );
+ const isFeatureEnabled = featureAvailability.data === true;
+ const query = api.externalMediaStorage.get.useQuery(
+ { projectId },
+ { enabled: Boolean(projectId && hasAccess && isFeatureEnabled), meta },
+ );
+ const status = query.data
+ ? getExternalMediaStorageStatus(query.data.config)
+ : undefined;
+
+ return { hasAccess, featureAvailability, isFeatureEnabled, query, status };
+}
diff --git a/web/src/features/mixpanel-integration/MixpanelIntegrationPage.tsx b/web/src/features/mixpanel-integration/MixpanelIntegrationPage.tsx
index e9a882537a..4b93f23f85 100644
--- a/web/src/features/mixpanel-integration/MixpanelIntegrationPage.tsx
+++ b/web/src/features/mixpanel-integration/MixpanelIntegrationPage.tsx
@@ -44,7 +44,7 @@ import {
} from "@/src/features/analytics-integrations";
import { useLangfuseCloudRegion } from "@/src/features/organizations";
import { useQueryProject } from "@/src/features/projects";
-import { useHasProjectAccess } from "@/src/features/rbac";
+import { useMixpanelIntegration } from "@/src/features/mixpanel-integration/useMixpanelIntegration";
import { api } from "@/src/utils/api";
import { type RouterOutput } from "@/src/utils/types";
import { zodResolver } from "@hookform/resolvers/zod";
@@ -60,29 +60,10 @@ export default function MixpanelIntegrationPage() {
const router = useRouter();
const projectId = router.query.projectId as string;
- const hasAccess = useHasProjectAccess({
- projectId,
- scope: "integrations:CRUD",
- });
- const state = api.mixpanelIntegration.get.useQuery(
- { projectId },
- {
- enabled: hasAccess,
- },
- );
+ const { hasAccess, query: state, status } = useMixpanelIntegration(projectId);
const { project } = useQueryProject();
- const status = (() => {
- if (state.isLoading || !hasAccess) {
- return undefined;
- }
- if (state.data?.config?.enabled) {
- return "active";
- }
- return "inactive";
- })();
-
return (
<ContainerPage
headerProps={{
diff --git a/web/src/features/mixpanel-integration/useMixpanelIntegration.clienttest.ts b/web/src/features/mixpanel-integration/useMixpanelIntegration.clienttest.ts
new file mode 100644
index 0000000000..c65c2da348
--- /dev/null
+++ b/web/src/features/mixpanel-integration/useMixpanelIntegration.clienttest.ts
@@ -0,0 +1,13 @@
+// @vitest-environment node
+
+import { getMixpanelStatus } from "./useMixpanelIntegration";
+
+describe("getMixpanelStatus", () => {
+ it.each([
+ [null, "inactive"],
+ [{ enabled: true }, "active"],
+ [{ enabled: false }, "inactive"],
+ ])("maps %o to %s", (config, expected) => {
+ expect(getMixpanelStatus(config)).toBe(expected);
+ });
+});
diff --git a/web/src/features/mixpanel-integration/useMixpanelIntegration.ts b/web/src/features/mixpanel-integration/useMixpanelIntegration.ts
new file mode 100644
index 0000000000..c758cf875d
--- /dev/null
+++ b/web/src/features/mixpanel-integration/useMixpanelIntegration.ts
@@ -0,0 +1,31 @@
+import { type Status } from "@/src/components/ui/StatusBadge/StatusBadge";
+import { useHasProjectAccess } from "@/src/features/rbac";
+import { api } from "@/src/utils/api";
+
+// An unconfigured integration reads as inactive on the integration page; the
+// overview card hides the badge instead (see `isConfigured`).
+export function getMixpanelStatus(config: { enabled: boolean } | null): Status {
+ return config?.enabled ? "active" : "inactive";
+}
+
+/** Shared by the integration page and the integrations overview card. */
+export function useMixpanelIntegration(
+ projectId: string,
+ meta?: Record<string, unknown>,
+) {
+ const hasAccess = useHasProjectAccess({
+ projectId,
+ scope: "integrations:CRUD",
+ });
+ const query = api.mixpanelIntegration.get.useQuery(
+ { projectId },
+ { enabled: hasAccess, meta },
+ );
+ const status =
+ query.isLoading || !hasAccess
+ ? undefined
+ : getMixpanelStatus(query.data?.config ?? null);
+ const isConfigured = Boolean(query.data?.config);
+
+ return { hasAccess, query, status, isConfigured };
+}
diff --git a/web/src/features/posthog-integration/PostHogIntegrationPage.tsx b/web/src/features/posthog-integration/PostHogIntegrationPage.tsx
index 31f86ac697..bf7f6dd3d7 100644
--- a/web/src/features/posthog-integration/PostHogIntegrationPage.tsx
+++ b/web/src/features/posthog-integration/PostHogIntegrationPage.tsx
@@ -23,7 +23,7 @@ import {
} from "@/src/features/analytics-integrations";
import { useLangfuseCloudRegion } from "@/src/features/organizations";
import { useQueryProject } from "@/src/features/projects";
-import { useHasProjectAccess } from "@/src/features/rbac";
+import { usePostHogIntegration } from "@/src/features/posthog-integration/usePostHogIntegration";
import { api } from "@/src/utils/api";
import { type RouterOutput } from "@/src/utils/types";
import { Card } from "@/src/components/ui/card";
@@ -35,34 +35,10 @@ export default function PostHogIntegrationPage() {
const router = useRouter();
const projectId = router.query.projectId as string;
- const hasAccess = useHasProjectAccess({
- projectId,
- scope: "integrations:CRUD",
- });
- const state = api.posthogIntegration.get.useQuery(
- { projectId },
- {
- enabled: hasAccess,
- },
- );
+ const { hasAccess, query: state, status } = usePostHogIntegration(projectId);
const { project } = useQueryProject();
- // A persisted fault outranks active/inactive: it is the state the admin has
- // to act on, and it is cleared by the next successful sync.
- const status = (() => {
- if (state.isLoading || !hasAccess) {
- return undefined;
- }
- if (state.data?.config?.lastError) {
- return "error";
- }
- if (state.data?.config?.enabled) {
- return "active";
- }
- return "inactive";
- })();
-
return (
<ContainerPage
headerProps={{
diff --git a/web/src/features/posthog-integration/usePostHogIntegration.clienttest.ts b/web/src/features/posthog-integration/usePostHogIntegration.clienttest.ts
new file mode 100644
index 0000000000..affc6810ab
--- /dev/null
+++ b/web/src/features/posthog-integration/usePostHogIntegration.clienttest.ts
@@ -0,0 +1,14 @@
+// @vitest-environment node
+
+import { getPostHogStatus } from "./usePostHogIntegration";
+
+describe("getPostHogStatus", () => {
+ it.each([
+ [null, "inactive"],
+ [{ enabled: true, lastError: null }, "active"],
+ [{ enabled: false, lastError: null }, "inactive"],
+ [{ enabled: false, lastError: "Invalid hostname" }, "error"],
+ ])("maps %o to %s", (config, expected) => {
+ expect(getPostHogStatus(config)).toBe(expected);
+ });
+});
diff --git a/web/src/features/posthog-integration/usePostHogIntegration.ts b/web/src/features/posthog-integration/usePostHogIntegration.ts
new file mode 100644
index 0000000000..74c60d57c7
--- /dev/null
+++ b/web/src/features/posthog-integration/usePostHogIntegration.ts
@@ -0,0 +1,35 @@
+import { type Status } from "@/src/components/ui/StatusBadge/StatusBadge";
+import { useHasProjectAccess } from "@/src/features/rbac";
+import { api } from "@/src/utils/api";
+
+// A persisted fault outranks active/inactive: it is the state the admin has
+// to act on, and it is cleared by the next successful sync. An unconfigured
+// integration reads as inactive on the integration page; the overview card
+// hides the badge instead (see `isConfigured`).
+export function getPostHogStatus(
+ config: { enabled: boolean; lastError: string | null } | null,
+): Status {
+ if (config?.lastError) return "error";
+ return config?.enabled ? "active" : "inactive";
+}
+
+/** Shared by the integration page and the integrations overview card. */
+export function usePostHogIntegration(
+ projectId: string,
+ meta?: Record<string, unknown>,
+) {
+ const hasAccess = useHasProjectAccess({
+ projectId,
+ scope: "integrations:CRUD",
+ });
+ const query = api.posthogIntegration.get.useQuery(
+ { projectId },
+ { enabled: hasAccess, meta },
+ );
+ const status =
+ query.isLoading || !hasAccess
+ ? undefined
+ : getPostHogStatus(query.data?.config ?? null);
+ const isConfigured = Boolean(query.data?.config);
+ return { hasAccess, query, status, isConfigured };
+}
diff --git a/web/src/features/projects/ProjectSettingsPage.tsx b/web/src/features/projects/ProjectSettingsPage.tsx
index 08242bb276..4a6affd58d 100644
--- a/web/src/features/projects/ProjectSettingsPage.tsx
+++ b/web/src/features/projects/ProjectSettingsPage.tsx
@@ -23,6 +23,7 @@ import { useHasEntitlement } from "@/src/features/entitlements";
import { useRouter } from "next/router";
import { SettingsDangerZone } from "@/src/components/SettingsDangerZone";
import { ActionButton } from "@/src/components/ActionButton";
+import { Webhook } from "lucide-react";
import { BatchExportsSettingsPage } from "@/src/features/batch-exports";
import { BatchActionsSettingsPage } from "@/src/features/batch-actions";
import { AuditLogsSettingsPage } from "@/src/ee/features/audit-log-viewer";
@@ -37,10 +38,19 @@ import { env } from "@/src/env.mjs";
import { PersonalNotificationSettings } from "@/src/features/notifications/components/PersonalNotificationSettings";
import { ProjectNotificationChannels } from "@/src/features/notifications/components/ProjectNotificationChannels";
import useSessionStorage from "@/src/components/useSessionStorage";
-import { WebCalloutIntegrationCard } from "@/src/features/web-callouts";
+import { useWebCallouts } from "@/src/features/web-callouts";
import { DeveloperToolsSettings } from "@/src/features/developer-tools";
import { useV4UpgradeUiFlag } from "@/src/features/v4-migration/useV4UpgradeUiEnabled";
import { api } from "@/src/utils/api";
+import {
+ StatusBadge,
+ type Status,
+} from "@/src/components/ui/StatusBadge/StatusBadge";
+import { usePostHogIntegration } from "@/src/features/posthog-integration/usePostHogIntegration";
+import { useMixpanelIntegration } from "@/src/features/mixpanel-integration/useMixpanelIntegration";
+import { useBlobStorageIntegration } from "@/src/features/blobstorage-integration/useBlobStorageIntegration";
+import { useExternalMediaStorage } from "@/src/features/external-media-storage/useExternalMediaStorage";
+import { useSlackIntegration } from "@/src/features/slack/useSlackIntegration";
type ProjectSettingsPageEntry = {
title: string;
@@ -410,27 +420,50 @@ function ProjectMembersSettings({
);
}
+const IntegrationCardHeader = (props: {
+ status: Status | undefined;
+ isLoading: boolean;
+ hasAccess: boolean;
+ children: React.ReactNode;
+}) => (
+ <div className="mb-4 flex items-center justify-between gap-2">
+ <div className="flex items-center gap-2">{props.children}</div>
+ {props.hasAccess && !props.isLoading && (
+ <StatusBadge type={props.status ?? "not_configured"} />
+ )}
+ </div>
+);
+
const Integrations = (props: { projectId: string }) => {
const hasAccess = useHasProjectAccess({
projectId: props.projectId,
scope: "integrations:CRUD",
});
- const showExternalMediaStorage =
- api.externalMediaStorage.isFeatureEnabled.useQuery({
- projectId: props.projectId,
- }).data === true;
- const allowBlobStorageIntegration = useHasEntitlement(
- "scheduled-blob-exports",
+ // Hide toast errors on integration screen. Error will appear inside integration
+ const silentError = { silentAllErrors: true };
+ const posthog = usePostHogIntegration(props.projectId, silentError);
+ const mixpanel = useMixpanelIntegration(props.projectId, silentError);
+ const blobStorage = useBlobStorageIntegration(props.projectId, silentError);
+ const externalMediaStorage = useExternalMediaStorage(
+ props.projectId,
+ silentError,
);
+ const slack = useSlackIntegration(props.projectId, silentError);
+ const webCallouts = useWebCallouts(props.projectId, silentError);
return (
<div>
<Header title="Integrations" />
<div className="space-y-6">
<Card className="p-3">
- {}
- <PostHogLogo className="text-foreground mb-4 w-40" />
+ <IntegrationCardHeader
+ status={posthog.isConfigured ? posthog.status : undefined}
+ isLoading={posthog.query.isLoading}
+ hasAccess={hasAccess}
+ >
+ <PostHogLogo className="text-foreground w-40" />
+ </IntegrationCardHeader>
<p className="text-primary mb-4 text-sm">
We have teamed up with PostHog (OSS product analytics) to make
Langfuse Events/Metrics available in your Posthog Dashboards.
@@ -455,7 +488,13 @@ const Integrations = (props: { projectId: string }) => {
</Card>
<Card className="p-3">
- <MixpanelLogo className="text-foreground mb-4 w-20" />
+ <IntegrationCardHeader
+ status={mixpanel.isConfigured ? mixpanel.status : undefined}
+ isLoading={mixpanel.query.isLoading}
+ hasAccess={hasAccess}
+ >
+ <MixpanelLogo className="text-foreground w-20" />
+ </IntegrationCardHeader>
<p className="text-primary mb-4 text-sm">
Integrate with Mixpanel to sync your Langfuse traces, generations,
and scores for advanced product analytics and insights.
@@ -480,7 +519,13 @@ const Integrations = (props: { projectId: string }) => {
</Card>
<Card className="p-3">
- <span className="font-bold">Blob Storage</span>
+ <IntegrationCardHeader
+ status={blobStorage.status}
+ isLoading={blobStorage.query.isLoading}
+ hasAccess={hasAccess}
+ >
+ <span className="font-bold">Blob Storage</span>
+ </IntegrationCardHeader>
<p className="text-primary mb-4 text-sm">
Configure scheduled exports of your trace data to S3 compatible
storages, Azure Blob Storage, or Google Cloud Storage. Set up a
@@ -491,7 +536,7 @@ const Integrations = (props: { projectId: string }) => {
<ActionButton
variant="secondary"
hasAccess={hasAccess}
- hasEntitlement={allowBlobStorageIntegration}
+ hasEntitlement={blobStorage.hasEntitlement}
href={`/project/${props.projectId}/settings/integrations/blobstorage`}
>
Configure
@@ -507,9 +552,15 @@ const Integrations = (props: { projectId: string }) => {
</div>
</Card>
- {showExternalMediaStorage ? (
+ {externalMediaStorage.isFeatureEnabled ? (
<Card className="p-3">
- <span className="font-bold">External Media Storage</span>
+ <IntegrationCardHeader
+ status={externalMediaStorage.status}
+ isLoading={externalMediaStorage.query.isLoading}
+ hasAccess={hasAccess}
+ >
+ <span className="font-bold">External Media Storage</span>
+ </IntegrationCardHeader>
<p className="text-primary mb-4 text-sm">
Resolve media referenced by s3:// URIs from your own Amazon S3 or
S3-compatible bucket.
@@ -535,10 +586,14 @@ const Integrations = (props: { projectId: string }) => {
) : null}
<Card className="p-3">
- <div className="mb-4 flex items-center gap-2">
+ <IntegrationCardHeader
+ status={slack.isConfigured ? slack.status : undefined}
+ isLoading={slack.query.isLoading}
+ hasAccess={hasAccess}
+ >
<SiSlack className="text-foreground icon-lg" />
<span className="font-bold">Slack</span>
- </div>
+ </IntegrationCardHeader>
<p className="text-primary mb-4 text-sm">
Connect a Slack workspace and create channel automations to receive
Langfuse alerts natively in Slack.
@@ -554,10 +609,27 @@ const Integrations = (props: { projectId: string }) => {
</div>
</Card>
- <WebCalloutIntegrationCard
- projectId={props.projectId}
- hasAccess={hasAccess}
- />
+ <Card className="p-3">
+ <IntegrationCardHeader
+ status={webCallouts.status}
+ isLoading={webCallouts.query.isLoading}
+ hasAccess={hasAccess}
+ >
+ <Webhook className="text-foreground icon-lg" />
+ <span className="font-bold">Web Callouts</span>
+ </IntegrationCardHeader>
+ <p className="text-primary mb-4 text-sm">
+ Send backend callouts from trace, observation, and session detail
+ views to your own application.
+ </p>
+ <ActionButton
+ variant="secondary"
+ hasAccess={hasAccess}
+ href={`/project/${props.projectId}/settings/integrations/web-callouts`}
+ >
+ Configure
+ </ActionButton>
+ </Card>
</div>
</div>
);
diff --git a/web/src/features/slack/SlackIntegrationPage.tsx b/web/src/features/slack/SlackIntegrationPage.tsx
index 63e7ed3e69..025072be6b 100644
--- a/web/src/features/slack/SlackIntegrationPage.tsx
+++ b/web/src/features/slack/SlackIntegrationPage.tsx
@@ -7,7 +7,7 @@ import {
type SlackChannel,
} from "@/src/features/slack/components/ChannelSelector";
import { SlackTestMessageButton } from "@/src/features/slack/components/SlackTestMessageButton";
-import { api } from "@/src/utils/api";
+import { useSlackIntegration } from "@/src/features/slack/useSlackIntegration";
import { useRouter } from "next/router";
import { useState, useEffect } from "react";
import { Badge } from "@/src/components/ui/badge";
@@ -64,21 +64,8 @@ export default function SlackIntegrationPage() {
}
}, [router.query]);
- const { data: integrationStatus, isLoading } =
- api.slack.getIntegrationStatus.useQuery(
- { projectId },
- { enabled: !!projectId },
- );
-
- const status = (() => {
- if (isLoading) {
- return undefined;
- }
- if (integrationStatus?.isConnected) {
- return "active";
- }
- return "inactive";
- })();
+ const { query, status } = useSlackIntegration(projectId);
+ const integrationStatus = query.data;
const [selectedChannel, setSelectedChannel] = useState<SlackChannel | null>(
null,
diff --git a/web/src/features/slack/useSlackIntegration.clienttest.ts b/web/src/features/slack/useSlackIntegration.clienttest.ts
new file mode 100644
index 0000000000..782dbf2445
--- /dev/null
+++ b/web/src/features/slack/useSlackIntegration.clienttest.ts
@@ -0,0 +1,13 @@
+// @vitest-environment node
+
+import { getSlackStatus } from "./useSlackIntegration";
+
+describe("getSlackStatus", () => {
+ it.each([
+ [undefined, "inactive"],
+ [{ isConnected: false }, "inactive"],
+ [{ isConnected: true }, "active"],
+ ])("maps %o to %s", (integration, expected) => {
+ expect(getSlackStatus(integration)).toBe(expected);
+ });
+});
diff --git a/web/src/features/slack/useSlackIntegration.ts b/web/src/features/slack/useSlackIntegration.ts
new file mode 100644
index 0000000000..da3e98738e
--- /dev/null
+++ b/web/src/features/slack/useSlackIntegration.ts
@@ -0,0 +1,32 @@
+import { type Status } from "@/src/components/ui/StatusBadge/StatusBadge";
+import { useHasProjectAccess } from "@/src/features/rbac";
+import { api } from "@/src/utils/api";
+
+// A stored workspace that fails validation reads as inactive, same as no
+// workspace; the overview card hides the badge when none is stored (see
+// `isConfigured`).
+export function getSlackStatus(
+ integration: { isConnected: boolean } | undefined,
+): Status {
+ return integration?.isConnected ? "active" : "inactive";
+}
+
+/** Shared by the integration page and the integrations overview card. */
+export function useSlackIntegration(
+ projectId: string,
+ meta?: Record<string, unknown>,
+) {
+ const hasAccess = useHasProjectAccess({
+ projectId,
+ scope: "automations:read",
+ });
+ const query = api.slack.getIntegrationStatus.useQuery(
+ { projectId },
+ { enabled: Boolean(projectId) && hasAccess, meta },
+ );
+ const status =
+ query.isLoading || !hasAccess ? undefined : getSlackStatus(query.data);
+ const isConfigured = Boolean(query.data?.teamId);
+
+ return { query, status, isConfigured };
+}
diff --git a/web/src/features/web-callouts/WebCalloutsPage.tsx b/web/src/features/web-callouts/WebCalloutsPage.tsx
index 0c8b9479d5..f6bffb07fe 100644
--- a/web/src/features/web-callouts/WebCalloutsPage.tsx
+++ b/web/src/features/web-callouts/WebCalloutsPage.tsx
@@ -1,4 +1,6 @@
import ContainerPage from "@/src/components/layouts/container-page";
+import { StatusBadge } from "@/src/components/ui/StatusBadge/StatusBadge";
+import { useWebCallouts } from "@/src/features/web-callouts/useWebCallouts";
import { WebCalloutSettingsPage } from "@/src/features/web-callouts/components/WebCalloutSettingsPage";
import { RouteParamsPendingFallback } from "@/src/hooks/useReadyRouteParams";
import { useRouter } from "next/router";
@@ -6,6 +8,7 @@ import { useRouter } from "next/router";
export default function WebCalloutsPage() {
const router = useRouter();
const projectId = router.query.projectId as string | undefined;
+ const { status } = useWebCallouts(projectId);
if (!projectId) {
return <RouteParamsPendingFallback />;
@@ -18,6 +21,7 @@ export default function WebCalloutsPage() {
breadcrumb: [
{ name: "Settings", href: `/project/${projectId}/settings` },
],
+ actionButtonsLeft: status && <StatusBadge type={status} />,
}}
>
<WebCalloutSettingsPage projectId={projectId} />
diff --git a/web/src/features/web-callouts/components/WebCalloutSettingsPage.tsx b/web/src/features/web-callouts/components/WebCalloutSettingsPage.tsx
index 908f04c0d3..5f35f19a33 100644
--- a/web/src/features/web-callouts/components/WebCalloutSettingsPage.tsx
+++ b/web/src/features/web-callouts/components/WebCalloutSettingsPage.tsx
@@ -1,15 +1,13 @@
import { showErrorToast, showSuccessToast } from "@/src/features/notifications";
import { zodResolver } from "@hookform/resolvers/zod";
-import { Plus, Webhook, X } from "lucide-react";
+import { Plus, X } from "lucide-react";
import { useState } from "react";
import { useFieldArray, useForm } from "react-hook-form";
import { z } from "zod";
-import { ActionButton } from "@/src/components/ActionButton";
import { DialogController } from "@/src/components/design-system/DialogController/DialogController";
import { Alert } from "@/src/components/design-system/Alert/Alert";
import { Button } from "@/src/components/ui/button";
-import { Card } from "@/src/components/ui/card";
import {
DialogBody,
DialogContent,
@@ -462,28 +460,3 @@ const hasExistingHeaderName = (
) ?? false
);
};
-
-export function WebCalloutIntegrationCard(props: {
- projectId: string;
- hasAccess: boolean;
-}) {
- return (
- <Card className="p-3">
- <div className="mb-4 flex items-center gap-2">
- <Webhook className="text-foreground icon-lg" />
- <span className="font-bold">Web Callouts</span>
- </div>
- <p className="text-primary mb-4 text-sm">
- Send backend callouts from trace, observation, and session detail views
- to your own application.
- </p>
- <ActionButton
- variant="secondary"
- hasAccess={props.hasAccess}
- href={`/project/${props.projectId}/settings/integrations/web-callouts`}
- >
- Configure
- </ActionButton>
- </Card>
- );
-}
diff --git a/web/src/features/web-callouts/index.ts b/web/src/features/web-callouts/index.ts
index 25fb8b6831..f855d15e34 100644
--- a/web/src/features/web-callouts/index.ts
+++ b/web/src/features/web-callouts/index.ts
@@ -4,4 +4,4 @@ export {
useWebCalloutAction,
WebCalloutButton,
} from "@/src/features/web-callouts/components/WebCalloutMenuItem";
-export { WebCalloutIntegrationCard } from "@/src/features/web-callouts/components/WebCalloutSettingsPage";
+export { useWebCallouts } from "@/src/features/web-callouts/useWebCallouts";
diff --git a/web/src/features/web-callouts/useWebCallouts.clienttest.ts b/web/src/features/web-callouts/useWebCallouts.clienttest.ts
new file mode 100644
index 0000000000..887a10c76b
--- /dev/null
+++ b/web/src/features/web-callouts/useWebCallouts.clienttest.ts
@@ -0,0 +1,14 @@
+// @vitest-environment node
+
+import { getWebCalloutsStatus } from "./useWebCallouts";
+
+describe("getWebCalloutsStatus", () => {
+ it.each([
+ [[], undefined],
+ [[{ enabled: true }], "active"],
+ [[{ enabled: false }, { enabled: true }], "active"],
+ [[{ enabled: false }, { enabled: false }], "inactive"],
+ ])("maps %o to %s", (endpoints, expected) => {
+ expect(getWebCalloutsStatus(endpoints)).toBe(expected);
+ });
+});
diff --git a/web/src/features/web-callouts/useWebCallouts.ts b/web/src/features/web-callouts/useWebCallouts.ts
new file mode 100644
index 0000000000..c005966d29
--- /dev/null
+++ b/web/src/features/web-callouts/useWebCallouts.ts
@@ -0,0 +1,30 @@
+import { type Status } from "@/src/components/ui/StatusBadge/StatusBadge";
+import { useHasProjectAccess } from "@/src/features/rbac";
+import { api } from "@/src/utils/api";
+
+// A project can have several endpoints; the integration counts as active as
+// soon as one of them is enabled.
+export function getWebCalloutsStatus(
+ endpoints: { enabled: boolean }[],
+): Status | undefined {
+ if (endpoints.length === 0) return undefined;
+ return endpoints.some((endpoint) => endpoint.enabled) ? "active" : "inactive";
+}
+
+/** Shared by the integration page and the integrations overview card. */
+export function useWebCallouts(
+ projectId: string | undefined,
+ meta?: Record<string, unknown>,
+) {
+ const hasAccess = useHasProjectAccess({
+ projectId,
+ scope: "integrations:CRUD",
+ });
+ const query = api.webCallouts.all.useQuery(
+ { projectId: projectId ?? "" },
+ { enabled: Boolean(projectId) && hasAccess, meta },
+ );
+ const status = query.data ? getWebCalloutsStatus(query.data) : undefined;
+
+ return { hasAccess, query, status };
+}