Skip to content

πŸͺ’ Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(analytics-integrations): extend legacy export source cutoff gate to PostHog and Mixpanel (#13684)

Niklas Semmler00c7d7d20167
diff --git a/web/src/__tests__/server/mixpanel-integration.servertest.ts b/web/src/__tests__/server/mixpanel-integration.servertest.ts
new file mode 100644
index 0000000000..9de6a022e8
--- /dev/null
+++ b/web/src/__tests__/server/mixpanel-integration.servertest.ts
@@ -0,0 +1,184 @@
+import type { Session } from "next-auth";
+import { prisma } from "@langfuse/shared/src/db";
+import { appRouter } from "@/src/server/api/root";
+import { createInnerTRPCContext } from "@/src/server/api/trpc";
+import { createOrgProjectAndApiKey } from "@langfuse/shared/src/server";
+import { LEGACY_BLOB_EXPORT_CUTOFF } from "@langfuse/shared";
+import { env } from "@/src/env.mjs";
+
+const MS_PER_DAY = 24 * 60 * 60 * 1000;
+const PRE_CUTOFF = new Date(LEGACY_BLOB_EXPORT_CUTOFF.getTime() - MS_PER_DAY);
+const POST_CUTOFF = new Date(LEGACY_BLOB_EXPORT_CUTOFF.getTime() + MS_PER_DAY);
+
+const buildSession = (orgId: string, projectId: string): Session => ({
+ expires: "1",
+ user: {
+ id: "user-1",
+ name: "Demo User",
+ canCreateOrganizations: true,
+ organizations: [
+ {
+ id: orgId,
+ role: "OWNER",
+ plan: "cloud:hobby",
+ cloudConfig: undefined,
+ name: "Test Organization",
+ metadata: {},
+ projects: [
+ {
+ id: projectId,
+ role: "ADMIN",
+ name: "Test Project",
+ deletedAt: null,
+ retentionDays: null,
+ metadata: {},
+ },
+ ],
+ },
+ ],
+ featureFlags: {
+ templateFlag: true,
+ excludeClickhouseRead: false,
+ },
+ admin: true,
+ },
+ environment: {} as any,
+});
+
+describe("Mixpanel Integration legacy export source cutoff gate", () => {
+ const originalEncryptionKey = process.env.ENCRYPTION_KEY;
+
+ beforeAll(() => {
+ process.env.ENCRYPTION_KEY =
+ "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
+ });
+
+ afterAll(() => {
+ process.env.ENCRYPTION_KEY = originalEncryptionKey;
+ });
+
+ afterEach(() => {
+ vi.restoreAllMocks();
+ });
+
+ const baseConfig = {
+ mixpanelRegion: "api" as const,
+ mixpanelProjectToken: "test_token_12345",
+ enabled: true,
+ };
+
+ const prepare = async () => {
+ const { project, orgId } = await createOrgProjectAndApiKey();
+ const ctx = createInnerTRPCContext({
+ session: buildSession(orgId, project.id),
+ headers: {},
+ });
+ const caller = appRouter.createCaller({ ...ctx, prisma });
+ return { project, caller };
+ };
+
+ it("Cloud + pre-cutoff project + legacy source β†’ allow", async () => {
+ const originalRegion = env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION;
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = "us";
+ try {
+ const { caller, project } = await prepare();
+ await prisma.project.update({
+ where: { id: project.id },
+ data: { createdAt: PRE_CUTOFF },
+ });
+ await expect(
+ caller.mixpanelIntegration.update({
+ projectId: project.id,
+ ...baseConfig,
+ exportSource: "TRACES_OBSERVATIONS" as const,
+ }),
+ ).resolves.not.toThrow();
+ } finally {
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = originalRegion;
+ }
+ });
+
+ it("Cloud + post-cutoff project + legacy source β†’ BAD_REQUEST", async () => {
+ const originalRegion = env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION;
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = "us";
+ try {
+ const { caller, project } = await prepare();
+ await prisma.project.update({
+ where: { id: project.id },
+ data: { createdAt: POST_CUTOFF },
+ });
+ await expect(
+ caller.mixpanelIntegration.update({
+ projectId: project.id,
+ ...baseConfig,
+ exportSource: "TRACES_OBSERVATIONS" as const,
+ }),
+ ).rejects.toMatchObject({ code: "BAD_REQUEST" });
+ } finally {
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = originalRegion;
+ }
+ });
+
+ it("Cloud + post-cutoff project + TRACES_OBSERVATIONS_EVENTS β†’ BAD_REQUEST", async () => {
+ const originalRegion = env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION;
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = "us";
+ try {
+ const { caller, project } = await prepare();
+ await prisma.project.update({
+ where: { id: project.id },
+ data: { createdAt: POST_CUTOFF },
+ });
+ await expect(
+ caller.mixpanelIntegration.update({
+ projectId: project.id,
+ ...baseConfig,
+ exportSource: "TRACES_OBSERVATIONS_EVENTS" as const,
+ }),
+ ).rejects.toMatchObject({ code: "BAD_REQUEST" });
+ } finally {
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = originalRegion;
+ }
+ });
+
+ it("Cloud + post-cutoff project + EVENTS β†’ allow", async () => {
+ const originalRegion = env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION;
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = "us";
+ try {
+ const { caller, project } = await prepare();
+ await prisma.project.update({
+ where: { id: project.id },
+ data: { createdAt: POST_CUTOFF },
+ });
+ await expect(
+ caller.mixpanelIntegration.update({
+ projectId: project.id,
+ ...baseConfig,
+ exportSource: "EVENTS" as const,
+ }),
+ ).resolves.not.toThrow();
+ } finally {
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = originalRegion;
+ }
+ });
+
+ it("self-hosted + post-cutoff project + legacy source β†’ allow (bypass)", async () => {
+ const originalRegion = env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION;
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = undefined;
+ try {
+ const { caller, project } = await prepare();
+ await prisma.project.update({
+ where: { id: project.id },
+ data: { createdAt: POST_CUTOFF },
+ });
+ await expect(
+ caller.mixpanelIntegration.update({
+ projectId: project.id,
+ ...baseConfig,
+ exportSource: "TRACES_OBSERVATIONS" as const,
+ }),
+ ).resolves.not.toThrow();
+ } finally {
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = originalRegion;
+ }
+ });
+});
diff --git a/web/src/__tests__/server/posthog-integration.servertest.ts b/web/src/__tests__/server/posthog-integration.servertest.ts
index c10eee45b0..24c1bbfce4 100644
--- a/web/src/__tests__/server/posthog-integration.servertest.ts
+++ b/web/src/__tests__/server/posthog-integration.servertest.ts
@@ -3,6 +3,47 @@ import { prisma } from "@langfuse/shared/src/db";
import { appRouter } from "@/src/server/api/root";
import { createInnerTRPCContext } from "@/src/server/api/trpc";
import { createOrgProjectAndApiKey } from "@langfuse/shared/src/server";
+import { LEGACY_BLOB_EXPORT_CUTOFF } from "@langfuse/shared";
+import { env } from "@/src/env.mjs";
+
+const MS_PER_DAY = 24 * 60 * 60 * 1000;
+const PRE_CUTOFF = new Date(LEGACY_BLOB_EXPORT_CUTOFF.getTime() - MS_PER_DAY);
+const POST_CUTOFF = new Date(LEGACY_BLOB_EXPORT_CUTOFF.getTime() + MS_PER_DAY);
+
+const buildSession = (orgId: string, projectId: string): Session => ({
+ expires: "1",
+ user: {
+ id: "user-1",
+ name: "Demo User",
+ canCreateOrganizations: true,
+ organizations: [
+ {
+ id: orgId,
+ role: "OWNER",
+ plan: "cloud:hobby",
+ cloudConfig: undefined,
+ name: "Test Organization",
+ metadata: {},
+ projects: [
+ {
+ id: projectId,
+ role: "ADMIN",
+ name: "Test Project",
+ deletedAt: null,
+ retentionDays: null,
+ metadata: {},
+ },
+ ],
+ },
+ ],
+ featureFlags: {
+ templateFlag: true,
+ excludeClickhouseRead: false,
+ },
+ admin: true,
+ },
+ environment: {} as any,
+});
describe("PostHog Integration SSRF Protection", () => {
const originalEncryptionKey = process.env.ENCRYPTION_KEY;
@@ -26,42 +67,10 @@ describe("PostHog Integration SSRF Protection", () => {
projectId = setup.projectId;
orgId = setup.orgId;
- const session: Session = {
- expires: "1",
- user: {
- id: "user-1",
- name: "Demo User",
- canCreateOrganizations: true,
- organizations: [
- {
- id: orgId,
- role: "OWNER",
- plan: "cloud:hobby",
- cloudConfig: undefined,
- name: "Test Organization",
- metadata: {},
- projects: [
- {
- id: projectId,
- role: "ADMIN",
- name: "Test Project",
- deletedAt: null,
- retentionDays: null,
- metadata: {},
- },
- ],
- },
- ],
- featureFlags: {
- templateFlag: true,
- excludeClickhouseRead: false,
- },
- admin: true,
- },
- environment: {} as any,
- };
-
- const ctx = createInnerTRPCContext({ session, headers: {} });
+ const ctx = createInnerTRPCContext({
+ session: buildSession(orgId, projectId),
+ headers: {},
+ });
caller = appRouter.createCaller({ ...ctx, prisma });
});
@@ -76,3 +85,144 @@ describe("PostHog Integration SSRF Protection", () => {
).rejects.toThrow(/Invalid PostHog hostname.*Blocked/);
});
});
+
+describe("PostHog Integration legacy export source cutoff gate", () => {
+ const originalEncryptionKey = process.env.ENCRYPTION_KEY;
+
+ beforeAll(() => {
+ process.env.ENCRYPTION_KEY =
+ "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
+ });
+
+ afterAll(() => {
+ process.env.ENCRYPTION_KEY = originalEncryptionKey;
+ });
+
+ afterEach(() => {
+ vi.restoreAllMocks();
+ });
+
+ // PostHog uses webhook URL validation that rejects private IPs β€” including
+ // public DNS hosts the test container can reach is overkill for unit-testing
+ // the cutoff gate. We exercise the gate against a stable public hostname.
+ const baseConfig = {
+ posthogHostname: "https://us.posthog.com",
+ posthogProjectApiKey: "phc_test_key_12345",
+ enabled: true,
+ };
+
+ const prepare = async () => {
+ const { project, orgId } = await createOrgProjectAndApiKey();
+ const ctx = createInnerTRPCContext({
+ session: buildSession(orgId, project.id),
+ headers: {},
+ });
+ const caller = appRouter.createCaller({ ...ctx, prisma });
+ return { project, caller };
+ };
+
+ it("Cloud + pre-cutoff project + legacy source β†’ allow", async () => {
+ const originalRegion = env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION;
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = "us";
+ try {
+ const { caller, project } = await prepare();
+ await prisma.project.update({
+ where: { id: project.id },
+ data: { createdAt: PRE_CUTOFF },
+ });
+ await expect(
+ caller.posthogIntegration.update({
+ projectId: project.id,
+ ...baseConfig,
+ exportSource: "TRACES_OBSERVATIONS" as const,
+ }),
+ ).resolves.not.toThrow();
+ } finally {
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = originalRegion;
+ }
+ });
+
+ it("Cloud + post-cutoff project + legacy source β†’ BAD_REQUEST", async () => {
+ const originalRegion = env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION;
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = "us";
+ try {
+ const { caller, project } = await prepare();
+ await prisma.project.update({
+ where: { id: project.id },
+ data: { createdAt: POST_CUTOFF },
+ });
+ await expect(
+ caller.posthogIntegration.update({
+ projectId: project.id,
+ ...baseConfig,
+ exportSource: "TRACES_OBSERVATIONS" as const,
+ }),
+ ).rejects.toMatchObject({ code: "BAD_REQUEST" });
+ } finally {
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = originalRegion;
+ }
+ });
+
+ it("Cloud + post-cutoff project + TRACES_OBSERVATIONS_EVENTS β†’ BAD_REQUEST", async () => {
+ const originalRegion = env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION;
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = "us";
+ try {
+ const { caller, project } = await prepare();
+ await prisma.project.update({
+ where: { id: project.id },
+ data: { createdAt: POST_CUTOFF },
+ });
+ await expect(
+ caller.posthogIntegration.update({
+ projectId: project.id,
+ ...baseConfig,
+ exportSource: "TRACES_OBSERVATIONS_EVENTS" as const,
+ }),
+ ).rejects.toMatchObject({ code: "BAD_REQUEST" });
+ } finally {
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = originalRegion;
+ }
+ });
+
+ it("Cloud + post-cutoff project + EVENTS β†’ allow", async () => {
+ const originalRegion = env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION;
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = "us";
+ try {
+ const { caller, project } = await prepare();
+ await prisma.project.update({
+ where: { id: project.id },
+ data: { createdAt: POST_CUTOFF },
+ });
+ await expect(
+ caller.posthogIntegration.update({
+ projectId: project.id,
+ ...baseConfig,
+ exportSource: "EVENTS" as const,
+ }),
+ ).resolves.not.toThrow();
+ } finally {
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = originalRegion;
+ }
+ });
+
+ it("self-hosted + post-cutoff project + legacy source β†’ allow (bypass)", async () => {
+ const originalRegion = env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION;
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = undefined;
+ try {
+ const { caller, project } = await prepare();
+ await prisma.project.update({
+ where: { id: project.id },
+ data: { createdAt: POST_CUTOFF },
+ });
+ await expect(
+ caller.posthogIntegration.update({
+ projectId: project.id,
+ ...baseConfig,
+ exportSource: "TRACES_OBSERVATIONS" as const,
+ }),
+ ).resolves.not.toThrow();
+ } finally {
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = originalRegion;
+ }
+ });
+});
diff --git a/web/src/features/mixpanel-integration/mixpanel-integration-router.ts b/web/src/features/mixpanel-integration/mixpanel-integration-router.ts
index fc3de635e6..34174545a3 100644
--- a/web/src/features/mixpanel-integration/mixpanel-integration-router.ts
+++ b/web/src/features/mixpanel-integration/mixpanel-integration-router.ts
@@ -1,6 +1,7 @@
import { z } from "zod";
import { auditLog } from "@/src/features/audit-logs/auditLog";
+import { assertLegacyBlobExportSourceAllowed } from "@/src/features/blobstorage-integration/server/assertLegacyBlobExportSourceAllowed";
import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
import {
createTRPCRouter,
@@ -69,6 +70,21 @@ export const mixpanelIntegrationRouter = createTRPCRouter({
});
}
}
+
+ // Post-cutoff Cloud projects may not select a legacy export source.
+ // Mirrors the blob-storage gate (LFE-9688); shares the same helper.
+ if (input.exportSource) {
+ const project = await ctx.prisma.project.findUniqueOrThrow({
+ where: { id: input.projectId },
+ select: { createdAt: true },
+ });
+ assertLegacyBlobExportSourceAllowed({
+ project,
+ nextInternalExportSource: input.exportSource,
+ isCloud: Boolean(env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION),
+ });
+ }
+
await auditLog({
session: ctx.session,
action: "update",
diff --git a/web/src/features/posthog-integration/posthog-integration-router.ts b/web/src/features/posthog-integration/posthog-integration-router.ts
index b408c3bc99..30e0fe2c45 100644
--- a/web/src/features/posthog-integration/posthog-integration-router.ts
+++ b/web/src/features/posthog-integration/posthog-integration-router.ts
@@ -1,6 +1,7 @@
import { z } from "zod";
import { auditLog } from "@/src/features/audit-logs/auditLog";
+import { assertLegacyBlobExportSourceAllowed } from "@/src/features/blobstorage-integration/server/assertLegacyBlobExportSourceAllowed";
import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
import {
createTRPCRouter,
@@ -83,6 +84,20 @@ export const posthogIntegrationRouter = createTRPCRouter({
});
}
+ // Post-cutoff Cloud projects may not select a legacy export source.
+ // Mirrors the blob-storage gate (LFE-9688); shares the same helper.
+ if (input.exportSource) {
+ const project = await ctx.prisma.project.findUniqueOrThrow({
+ where: { id: input.projectId },
+ select: { createdAt: true },
+ });
+ assertLegacyBlobExportSourceAllowed({
+ project,
+ nextInternalExportSource: input.exportSource,
+ isCloud: Boolean(env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION),
+ });
+ }
+
await auditLog({
session: ctx.session,
action: "update",
diff --git a/web/src/pages/project/[projectId]/settings/integrations/mixpanel.tsx b/web/src/pages/project/[projectId]/settings/integrations/mixpanel.tsx
index e20162ca2a..5efb1f9774 100644
--- a/web/src/pages/project/[projectId]/settings/integrations/mixpanel.tsx
+++ b/web/src/pages/project/[projectId]/settings/integrations/mixpanel.tsx
@@ -35,8 +35,11 @@ import {
import {
AnalyticsIntegrationExportSource,
EXPORT_SOURCE_OPTIONS,
+ isLegacyBlobExportAllowed,
} from "@langfuse/shared";
import { useV4Beta } from "@/src/features/events/hooks/useV4Beta";
+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";
+import { useQueryProject } from "@/src/features/projects/hooks";
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
import { api } from "@/src/utils/api";
import { type RouterOutput } from "@/src/utils/types";
@@ -144,6 +147,17 @@ const MixpanelIntegrationSettingsForm = ({
}) => {
const capture = usePostHogClientCapture();
const { isBetaEnabled } = useV4Beta();
+ const { isLangfuseCloud } = useLangfuseCloudRegion();
+ const { project } = useQueryProject();
+
+ // Post-cutoff Cloud projects may only use OBSERVATIONS_V2 (EVENTS). The
+ // Export Source field is hidden in that case; the form value is pinned to
+ // EVENTS via the default below. Mirrors blob-storage settings (LFE-9688 / 9830).
+ const isPostCutoffCloud =
+ project?.createdAt != null &&
+ !isLegacyBlobExportAllowed(new Date(project.createdAt), isLangfuseCloud);
+ const showExportSourceField = isBetaEnabled && !isPostCutoffCloud;
+
const mixpanelForm = useForm({
resolver: zodResolver(mixpanelIntegrationFormSchema),
defaultValues: {
@@ -152,11 +166,12 @@ const MixpanelIntegrationSettingsForm = ({
MIXPANEL_REGIONS[0].subdomain,
mixpanelProjectToken: state?.mixpanelProjectToken ?? "",
enabled: state?.enabled ?? false,
- exportSource:
- state?.exportSource ??
- (isBetaEnabled
- ? AnalyticsIntegrationExportSource.EVENTS
- : AnalyticsIntegrationExportSource.TRACES_OBSERVATIONS),
+ exportSource: isPostCutoffCloud
+ ? AnalyticsIntegrationExportSource.EVENTS
+ : (state?.exportSource ??
+ (isBetaEnabled
+ ? AnalyticsIntegrationExportSource.EVENTS
+ : AnalyticsIntegrationExportSource.TRACES_OBSERVATIONS)),
},
disabled: isLoading,
});
@@ -168,11 +183,12 @@ const MixpanelIntegrationSettingsForm = ({
MIXPANEL_REGIONS[0].subdomain,
mixpanelProjectToken: state?.mixpanelProjectToken ?? "",
enabled: state?.enabled ?? false,
- exportSource:
- state?.exportSource ??
- (isBetaEnabled
- ? AnalyticsIntegrationExportSource.EVENTS
- : AnalyticsIntegrationExportSource.TRACES_OBSERVATIONS),
+ exportSource: isPostCutoffCloud
+ ? AnalyticsIntegrationExportSource.EVENTS
+ : (state?.exportSource ??
+ (isBetaEnabled
+ ? AnalyticsIntegrationExportSource.EVENTS
+ : AnalyticsIntegrationExportSource.TRACES_OBSERVATIONS)),
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [state]);
@@ -249,7 +265,7 @@ const MixpanelIntegrationSettingsForm = ({
</FormItem>
)}
/>
- {isBetaEnabled && (
+ {showExportSourceField && (
<FormField
control={mixpanelForm.control}
name="exportSource"
diff --git a/web/src/pages/project/[projectId]/settings/integrations/posthog.tsx b/web/src/pages/project/[projectId]/settings/integrations/posthog.tsx
index 828ba6500f..38cfefc00a 100644
--- a/web/src/pages/project/[projectId]/settings/integrations/posthog.tsx
+++ b/web/src/pages/project/[projectId]/settings/integrations/posthog.tsx
@@ -32,8 +32,11 @@ import { posthogIntegrationFormSchema } from "@/src/features/posthog-integration
import {
AnalyticsIntegrationExportSource,
EXPORT_SOURCE_OPTIONS,
+ isLegacyBlobExportAllowed,
} from "@langfuse/shared";
import { useV4Beta } from "@/src/features/events/hooks/useV4Beta";
+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";
+import { useQueryProject } from "@/src/features/projects/hooks";
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
import { api } from "@/src/utils/api";
import { type RouterOutput } from "@/src/utils/types";
@@ -141,17 +144,29 @@ const PostHogIntegrationSettings = ({
}) => {
const capture = usePostHogClientCapture();
const { isBetaEnabled } = useV4Beta();
+ const { isLangfuseCloud } = useLangfuseCloudRegion();
+ const { project } = useQueryProject();
+
+ // Post-cutoff Cloud projects may only use OBSERVATIONS_V2 (EVENTS). The
+ // Export Source field is hidden in that case; the form value is pinned to
+ // EVENTS via the default below. Mirrors blob-storage settings (LFE-9688 / 9830).
+ const isPostCutoffCloud =
+ project?.createdAt != null &&
+ !isLegacyBlobExportAllowed(new Date(project.createdAt), isLangfuseCloud);
+ const showExportSourceField = isBetaEnabled && !isPostCutoffCloud;
+
const posthogForm = useForm({
resolver: zodResolver(posthogIntegrationFormSchema),
defaultValues: {
posthogHostname: state?.posthogHostName ?? "",
posthogProjectApiKey: state?.posthogApiKey ?? "",
enabled: state?.enabled ?? false,
- exportSource:
- state?.exportSource ??
- (isBetaEnabled
- ? AnalyticsIntegrationExportSource.EVENTS
- : AnalyticsIntegrationExportSource.TRACES_OBSERVATIONS),
+ exportSource: isPostCutoffCloud
+ ? AnalyticsIntegrationExportSource.EVENTS
+ : (state?.exportSource ??
+ (isBetaEnabled
+ ? AnalyticsIntegrationExportSource.EVENTS
+ : AnalyticsIntegrationExportSource.TRACES_OBSERVATIONS)),
},
disabled: isLoading,
});
@@ -161,11 +176,12 @@ const PostHogIntegrationSettings = ({
posthogHostname: state?.posthogHostName ?? "",
posthogProjectApiKey: state?.posthogApiKey ?? "",
enabled: state?.enabled ?? false,
- exportSource:
- state?.exportSource ??
- (isBetaEnabled
- ? AnalyticsIntegrationExportSource.EVENTS
- : AnalyticsIntegrationExportSource.TRACES_OBSERVATIONS),
+ exportSource: isPostCutoffCloud
+ ? AnalyticsIntegrationExportSource.EVENTS
+ : (state?.exportSource ??
+ (isBetaEnabled
+ ? AnalyticsIntegrationExportSource.EVENTS
+ : AnalyticsIntegrationExportSource.TRACES_OBSERVATIONS)),
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [state]);
@@ -225,7 +241,7 @@ const PostHogIntegrationSettings = ({
</FormItem>
)}
/>
- {isBetaEnabled && (
+ {showExportSourceField && (
<FormField
control={posthogForm.control}
name="exportSource"