Skip to content

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

fix(web): fix export source docs links and point V4 migration guidance to Python v5 / JS v6 (#18851)

Hassieb Pakzada5a5b2502725
diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts
index c6627d5a93..fa367b4801 100644
--- a/packages/shared/src/index.ts
+++ b/packages/shared/src/index.ts
@@ -122,7 +122,10 @@ export * from "./errors/index";
export * from "./utils/environment";
export * from "./interfaces/search";
-export { normalizeIngestionSdkName } from "./server/ingestion/ingestionAttribution";
+export {
+ LANGFUSE_SDK_LATEST_MAJOR,
+ normalizeIngestionSdkName,
+} from "./server/ingestion/ingestionAttribution";
// domain
export * from "./domain";
diff --git a/packages/shared/src/server/ingestion/ingestionAttribution.test.ts b/packages/shared/src/server/ingestion/ingestionAttribution.test.ts
index ed74bcc8d2..330847dbe6 100644
--- a/packages/shared/src/server/ingestion/ingestionAttribution.test.ts
+++ b/packages/shared/src/server/ingestion/ingestionAttribution.test.ts
@@ -128,41 +128,41 @@ describe("ingestion attribution", () => {
it.each([
{
sdkName: "python",
- sdkVersion: "3.9.0",
+ sdkVersion: "4.14.0",
expected: {
canonicalSdkName: "python",
- latestMajor: 4,
- major: 3,
+ latestMajor: 5,
+ major: 4,
status: "outdated_major",
},
},
{
sdkName: "langfuse-python",
- sdkVersion: "4.0.0b1",
+ sdkVersion: "5.0.0b1",
expected: {
canonicalSdkName: "python",
- latestMajor: 4,
- major: 4,
+ latestMajor: 5,
+ major: 5,
status: "current",
},
},
{
sdkName: "javascript",
- sdkVersion: "4.6.0",
+ sdkVersion: "5.10.0",
expected: {
canonicalSdkName: "javascript",
- latestMajor: 5,
- major: 4,
+ latestMajor: 6,
+ major: 5,
status: "outdated_major",
},
},
{
sdkName: "@langfuse/tracing",
- sdkVersion: "5.1.2-rc.1",
+ sdkVersion: "6.1.2-rc.1",
expected: {
canonicalSdkName: "javascript",
- latestMajor: 5,
- major: 5,
+ latestMajor: 6,
+ major: 6,
status: "current",
},
},
@@ -191,7 +191,7 @@ describe("ingestion attribution", () => {
sdkVersion: "not-a-version",
expected: {
canonicalSdkName: "python",
- latestMajor: 4,
+ latestMajor: 5,
major: null,
status: "invalid_version",
},
diff --git a/packages/shared/src/server/ingestion/ingestionAttribution.ts b/packages/shared/src/server/ingestion/ingestionAttribution.ts
index 269a1d452c..212ff3682e 100644
--- a/packages/shared/src/server/ingestion/ingestionAttribution.ts
+++ b/packages/shared/src/server/ingestion/ingestionAttribution.ts
@@ -19,8 +19,8 @@ export const INTERNAL_INGESTION_SDK_NAMES = [
] as const;
export const LANGFUSE_SDK_LATEST_MAJOR = {
- python: 4,
- javascript: 5,
+ python: 5,
+ javascript: 6,
} as const;
export type IngestionSdkCanonicalName = keyof typeof LANGFUSE_SDK_LATEST_MAJOR;
diff --git a/web/src/features/blobstorage-integration/components/ExportSourceField.tsx b/web/src/features/blobstorage-integration/components/ExportSourceField.tsx
index 395060e3a8..cf5558e7a9 100644
--- a/web/src/features/blobstorage-integration/components/ExportSourceField.tsx
+++ b/web/src/features/blobstorage-integration/components/ExportSourceField.tsx
@@ -81,7 +81,7 @@ export const ExportSourceField = ({
))}
<div className="border-t pt-2">
<a
- href="https://langfuse.com/docs/integrations/export-sources"
+ href="https://langfuse.com/docs/api-and-data-platform/features/export-to-blob-storage#upgrade-path"
target="_blank"
rel="noopener noreferrer"
className="text-muted-foreground hover:text-primary inline-flex items-center gap-1 text-xs hover:underline"
diff --git a/web/src/features/mixpanel-integration/MixpanelIntegrationPage.tsx b/web/src/features/mixpanel-integration/MixpanelIntegrationPage.tsx
index 4b93f23f85..31f5389ea8 100644
--- a/web/src/features/mixpanel-integration/MixpanelIntegrationPage.tsx
+++ b/web/src/features/mixpanel-integration/MixpanelIntegrationPage.tsx
@@ -311,7 +311,7 @@ const MixpanelIntegrationSettingsForm = ({
))}
<div className="border-t pt-2">
<a
- href="https://langfuse.com/docs/integrations/export-sources"
+ href="https://langfuse.com/integrations/analytics/mixpanel#migrate-export-source"
target="_blank"
rel="noopener noreferrer"
className="text-muted-foreground hover:text-primary inline-flex items-center gap-1 text-xs hover:underline"
diff --git a/web/src/features/posthog-integration/components/PostHogIntegrationForm.tsx b/web/src/features/posthog-integration/components/PostHogIntegrationForm.tsx
index 7564a04eda..85b7d235fe 100644
--- a/web/src/features/posthog-integration/components/PostHogIntegrationForm.tsx
+++ b/web/src/features/posthog-integration/components/PostHogIntegrationForm.tsx
@@ -186,7 +186,7 @@ export function PostHogIntegrationForm({
))}
<div className="border-t pt-2">
<a
- href="https://langfuse.com/docs/integrations/export-sources"
+ href="https://langfuse.com/integrations/analytics/posthog#migrate-export-source"
target="_blank"
rel="noopener noreferrer"
className="text-muted-foreground hover:text-primary inline-flex items-center gap-1 text-xs hover:underline"
diff --git a/web/src/features/v4-migration/V4MigrationContent.clienttest.tsx b/web/src/features/v4-migration/V4MigrationContent.clienttest.tsx
index 7eb19e6622..91ed9bf115 100644
--- a/web/src/features/v4-migration/V4MigrationContent.clienttest.tsx
+++ b/web/src/features/v4-migration/V4MigrationContent.clienttest.tsx
@@ -414,6 +414,34 @@ describe("V4MigrationDetailsContent", () => {
).toHaveTextContent(/1 call · last seen/);
});
+ it("recommends the latest-major method and labels the previous-major fallback", () => {
+ mocks.migrationData.apiUsage = [
+ {
+ endpoint: "GET /api/public/scores/{id}",
+ count: 2,
+ lastSeen: "2026-07-23T10:37:00Z",
+ callers: [
+ {
+ sdkName: "python" as const,
+ sdkVersion: "4.9.0",
+ userAgent: "langfuse-python/4.9.0",
+ count: 2,
+ lastSeen: "2026-07-23T10:37:00Z",
+ },
+ ],
+ },
+ ];
+
+ render(<V4MigrationDetailsContent projectId="project-1" />);
+
+ const guidance = screen.getByText(
+ "client.api.scores.get_by_id",
+ ).parentElement!;
+ expect(guidance).toHaveTextContent(
+ "Replace client.api.scores.get_by_id with client.api.scores.get_many(id=...) (SDK v5). On 4.8.1–4.x, use client.api.scores_v3.get_many_v3.",
+ );
+ });
+
it("shows the caller and exact SDK migration action", () => {
mocks.migrationData.apiUsage = [
{
@@ -633,10 +661,37 @@ describe("V4MigrationDetailsContent", () => {
).toBeInTheDocument();
expect(screen.getByText("Python 4.7.1")).toBeInTheDocument();
expect(screen.getByText("otelcol 0.98.0")).toBeInTheDocument();
- expect(screen.getByText("· up to date")).toBeInTheDocument();
+ expect(screen.getByText(/Python SDK v5 is available/)).toBeInTheDocument();
+ expect(screen.getByRole("link", { name: "Upgrade guide" })).toHaveAttribute(
+ "href",
+ "https://langfuse.com/docs/observability/sdk/upgrade-path/python-v4-to-v5",
+ );
+ expect(screen.queryByText("· up to date")).not.toBeInTheDocument();
expect(screen.getByText("· real-time")).toBeInTheDocument();
});
+ it("shows SDK traffic on the latest major as up to date without an upgrade nudge", () => {
+ mocks.migrationData.sdk = {
+ ...cleanSdkState(),
+ sdkUsageSeries: [
+ makeSdkUsageSeries({ sdkVersion: "5.0.1" }),
+ makeSdkUsageSeries({
+ sdkName: "@langfuse/tracing",
+ sdkVersion: "6.0.0",
+ publicKey: "pk-lf-fedcba0987654321",
+ }),
+ ],
+ };
+
+ render(<V4MigrationDetailsContent projectId="project-1" />);
+
+ expect(screen.getAllByText("· up to date")).toHaveLength(2);
+ expect(screen.queryByText(/is available/)).not.toBeInTheDocument();
+ expect(
+ screen.queryByRole("link", { name: "Upgrade guide" }),
+ ).not.toBeInTheDocument();
+ });
+
it("lists only required SDK series in Update SDK and shows compatible ones as detected", () => {
mocks.migrationData.sdk = {
status: "legacy",
@@ -660,13 +715,15 @@ describe("V4MigrationDetailsContent", () => {
within(screen.getByText("Update SDK").closest("button")!).getByText("1"),
).toBeInTheDocument();
expect(screen.getByText("Python 2.60.3")).toBeInTheDocument();
- expect(screen.getByText(/upgrade required/)).toBeInTheDocument();
- // Compatible current-major traffic lands in the detected section.
+ expect(
+ screen.getByText("· upgrade required to v5 (>= 4.0.0 also works)"),
+ ).toBeInTheDocument();
+ // Compatible previous-major traffic lands in the detected section.
expect(
screen.getByText("Detected V4-compatible instrumentation"),
).toBeInTheDocument();
expect(screen.getByText("Python 4.6.9")).toBeInTheDocument();
- expect(screen.getByText("· up to date")).toBeInTheDocument();
+ expect(screen.getByText(/Python SDK v5 is available/)).toBeInTheDocument();
expect(
screen.queryByText("· recommended to upgrade to >= 4.7.0"),
).not.toBeInTheDocument();
diff --git a/web/src/features/v4-migration/V4MigrationContent.tsx b/web/src/features/v4-migration/V4MigrationContent.tsx
index ed02c75d8e..a61ee9b11a 100644
--- a/web/src/features/v4-migration/V4MigrationContent.tsx
+++ b/web/src/features/v4-migration/V4MigrationContent.tsx
@@ -30,6 +30,7 @@ import { copyTextToClipboard } from "@/src/utils/clipboard";
import {
formatSdkUpgradeRequirement,
formatSdkVersion,
+ getAvailableSdkMajorUpgrade,
getCustomInstrumentationSectionState,
getDetectedInstrumentationSeries,
getOtelSectionState,
@@ -521,9 +522,7 @@ export function V4MigrationSdkSection({
needsAction={isActionableSdkSeries}
suffix={(usage) => {
if (usage.v4MigrationStatus === "upgrade_required") {
- return (
- <span>· {formatSdkUpgradeRequirement(usage.latestSdkMajor)}</span>
- );
+ return <span>· {formatSdkUpgradeRequirement(usage)}</span>;
}
if (usage.v4MigrationStatus === "unknown") {
return <span>· version not recognized</span>;
@@ -676,21 +675,35 @@ export function V4MigrationDetectedInstrumentationSection({
tone="muted"
>
<p className="text-muted-foreground text-sm leading-relaxed">
- These configurations are already on the latest SDK major or use
- real-time OTel ingestion.
+ These configurations are on a V4-compatible SDK major or use real-time
+ OTel ingestion.
</p>
<SdkUsageSeriesRows
series={series}
projectId={projectId}
analyticsSection="detected_instrumentation"
needsAction={() => false}
- suffix={(usage) =>
- usage.remediationType === "update_sdk" ? (
- <span>· up to date</span>
- ) : (
- <span>· real-time</span>
- )
- }
+ suffix={(usage) => {
+ if (usage.remediationType !== "update_sdk") {
+ return <span>· real-time</span>;
+ }
+ const majorUpgrade = getAvailableSdkMajorUpgrade(usage);
+ if (!majorUpgrade) return <span>· up to date</span>;
+ return (
+ <span>
+ · {majorUpgrade.label} is available ·{" "}
+ <ExternalLink
+ href={majorUpgrade.upgradeGuideUrl}
+ analytics={{
+ section: "detected_instrumentation",
+ link: "sdk_major_upgrade_docs",
+ }}
+ >
+ Upgrade guide
+ </ExternalLink>
+ </span>
+ );
+ }}
/>
</Section>
);
@@ -1041,19 +1054,54 @@ export function V4MigrationApisSection({
) : guidance.currentMethod &&
guidance.replacementMethod ? (
<p className="text-muted-foreground mt-1 pl-5 text-xs">
- Replace{" "}
- <MonoValue>{guidance.currentMethod}</MonoValue>{" "}
- with{" "}
- <MonoValue>
- {guidance.replacementMethod}
- </MonoValue>
- {guidance.requiresUpgrade &&
- guidance.minimumVersion ? (
+ {guidance.currentMethod ===
+ guidance.replacementMethod ? (
<>
- . First upgrade to SDK version{" "}
+ Upgrade to SDK v{guidance.latestMajor},
+ where{" "}
<MonoValue>
- {guidance.minimumVersion} or newer
+ {guidance.replacementMethod}
+ </MonoValue>{" "}
+ calls the new API
+ </>
+ ) : (
+ <>
+ Replace{" "}
+ <MonoValue>
+ {guidance.currentMethod}
+ </MonoValue>{" "}
+ with{" "}
+ <MonoValue>
+ {guidance.replacementMethod}
+ </MonoValue>
+ {guidance.previousMajorReplacementMethod
+ ? ` (SDK v${guidance.latestMajor})`
+ : null}
+ </>
+ )}
+ {guidance.previousMajorReplacementMethod &&
+ guidance.minimumVersion &&
+ guidance.latestMajor ? (
+ <>
+ . On{" "}
+ <MonoValue>
+ {guidance.minimumVersion}–
+ {guidance.latestMajor - 1}.x
</MonoValue>
+ , use{" "}
+ <MonoValue>
+ {guidance.previousMajorReplacementMethod}
+ </MonoValue>
+ </>
+ ) : guidance.requiresUpgrade &&
+ guidance.minimumVersion ? (
+ <>
+ . First upgrade to SDK v
+ {guidance.latestMajor} (
+ <MonoValue>
+ {guidance.minimumVersion} or newer
+ </MonoValue>{" "}
+ also works)
</>
) : null}
.{" "}
diff --git a/web/src/features/v4-migration/apiMigrationGuidance.clienttest.ts b/web/src/features/v4-migration/apiMigrationGuidance.clienttest.ts
index 7ac327bc89..dea7ae3284 100644
--- a/web/src/features/v4-migration/apiMigrationGuidance.clienttest.ts
+++ b/web/src/features/v4-migration/apiMigrationGuidance.clienttest.ts
@@ -11,13 +11,14 @@ describe("getApiMigrationGuidance", () => {
).toEqual({
currentMethod: "client.api.trace.get",
replacementMethod: "client.api.observations.get_many",
+ latestMajor: 5,
replacement: "GET /api/public/v2/observations",
minimumVersion: "4.0.0",
requiresUpgrade: true,
});
});
- it("uses the language-specific Scores v3 client and version", () => {
+ it("recommends the JS v6 scores method with the v5 Scores v3 client as fallback", () => {
expect(
getApiMigrationGuidance(
"GET /api/public/v2/scores",
@@ -26,19 +27,37 @@ describe("getApiMigrationGuidance", () => {
),
).toMatchObject({
currentMethod: "client.api.scores.getMany",
- replacementMethod: "client.api.scoresV3.getManyV3",
+ replacementMethod: "client.api.scores.getMany",
+ previousMajorReplacementMethod: "client.api.scoresV3.getManyV3",
+ latestMajor: 6,
minimumVersion: "5.5.0",
requiresUpgrade: true,
});
});
- it("uses bare score methods for the legacy score endpoint", () => {
+ it("recommends the Python v5 scores lookup by ID for the legacy score endpoint", () => {
expect(
getApiMigrationGuidance("GET /api/public/scores/{id}", "python", "4.8.1"),
).toMatchObject({
currentMethod: "client.api.scores.get_by_id",
- replacementMethod: "client.api.scores_v3.get_many_v3",
+ replacementMethod: "client.api.scores.get_many(id=...)",
+ previousMajorReplacementMethod: "client.api.scores_v3.get_many_v3",
+ latestMajor: 5,
replacement: "GET /api/public/v3/scores",
+ requiresUpgrade: false,
+ });
+ });
+
+ it("recommends the JS v6 scores lookup by ID for the v2 score endpoint", () => {
+ expect(
+ getApiMigrationGuidance(
+ "GET /api/public/v2/scores/{id}",
+ "javascript",
+ "5.5.0",
+ ),
+ ).toMatchObject({
+ replacementMethod: "client.api.scores.getMany({ id })",
+ previousMajorReplacementMethod: "client.api.scoresV3.getManyV3",
});
});
@@ -152,6 +171,8 @@ describe("getApiMigrationGuidance", () => {
getApiMigrationGuidance(entrypoint, "javascript", "5.5.0"),
).toMatchObject({
replacementMethod: "client.api.experiments.listItems",
+ minimumVersion: "5.10.0",
+ requiresUpgrade: true,
});
});
@@ -164,8 +185,26 @@ describe("getApiMigrationGuidance", () => {
),
).toMatchObject({
replacementMethod: "client.api.experiments.list",
+ minimumVersion: "4.13.1",
+ requiresUpgrade: true,
});
});
+
+ it.each([
+ ["python", "4.13.1"],
+ ["javascript", "5.10.0"],
+ ] as const)(
+ "does not ask %s %s experiments callers to upgrade first",
+ (sdkName, sdkVersion) => {
+ expect(
+ getApiMigrationGuidance(
+ "GET /api/public/dataset-run-items",
+ sdkName,
+ sdkVersion,
+ ),
+ ).toMatchObject({ requiresUpgrade: false });
+ },
+ );
});
describe("getCodingAgentName", () => {
diff --git a/web/src/features/v4-migration/apiMigrationGuidance.ts b/web/src/features/v4-migration/apiMigrationGuidance.ts
index 8e57629f72..5288b150bc 100644
--- a/web/src/features/v4-migration/apiMigrationGuidance.ts
+++ b/web/src/features/v4-migration/apiMigrationGuidance.ts
@@ -1,8 +1,14 @@
+import { LANGFUSE_SDK_LATEST_MAJOR } from "@langfuse/shared";
+
export type MigrationSdkName = "python" | "javascript";
export type ApiMigrationGuidance = {
currentMethod?: string;
+ /** Method name on the latest SDK major. */
replacementMethod?: string;
+ /** Method name on the previous major, from `minimumVersion` onwards. */
+ previousMajorReplacementMethod?: string;
+ latestMajor?: number;
replacement: string;
minimumVersion?: string;
requiresUpgrade?: boolean;
@@ -10,7 +16,12 @@ export type ApiMigrationGuidance = {
type SdkMethods = Record<
MigrationSdkName,
- { current: string; replacement: string; minimumVersion?: string }
+ {
+ current: string;
+ replacement: string;
+ previousMajorReplacement?: string;
+ minimumVersion?: string;
+ }
>;
const observationsMethods = (current: SdkMethods): SdkMethods => current;
@@ -84,12 +95,14 @@ const guidanceByEndpoint: Record<
methods: {
python: {
current: "client.api.scores.get_many",
- replacement: "client.api.scores_v3.get_many_v3",
+ replacement: "client.api.scores.get_many",
+ previousMajorReplacement: "client.api.scores_v3.get_many_v3",
minimumVersion: "4.8.1",
},
javascript: {
current: "client.api.scores.getMany",
- replacement: "client.api.scoresV3.getManyV3",
+ replacement: "client.api.scores.getMany",
+ previousMajorReplacement: "client.api.scoresV3.getManyV3",
minimumVersion: "5.5.0",
},
},
@@ -99,12 +112,14 @@ const guidanceByEndpoint: Record<
methods: {
python: {
current: "client.api.scores.get_by_id",
- replacement: "client.api.scores_v3.get_many_v3",
+ replacement: "client.api.scores.get_many(id=...)",
+ previousMajorReplacement: "client.api.scores_v3.get_many_v3",
minimumVersion: "4.8.1",
},
javascript: {
current: "client.api.scores.getById",
- replacement: "client.api.scoresV3.getManyV3",
+ replacement: "client.api.scores.getMany({ id })",
+ previousMajorReplacement: "client.api.scoresV3.getManyV3",
minimumVersion: "5.5.0",
},
},
@@ -114,12 +129,14 @@ const guidanceByEndpoint: Record<
methods: {
python: {
current: "client.api.scores.get_by_id",
- replacement: "client.api.scores_v3.get_many_v3",
+ replacement: "client.api.scores.get_many(id=...)",
+ previousMajorReplacement: "client.api.scores_v3.get_many_v3",
minimumVersion: "4.8.1",
},
javascript: {
current: "client.api.scores.getById",
- replacement: "client.api.scoresV3.getManyV3",
+ replacement: "client.api.scores.getMany({ id })",
+ previousMajorReplacement: "client.api.scoresV3.getManyV3",
minimumVersion: "5.5.0",
},
},
@@ -173,10 +190,12 @@ const guidanceByEndpoint: Record<
python: {
current: "client.api.dataset_run_items.list",
replacement: "client.api.experiments.list_items",
+ minimumVersion: "4.13.1",
},
javascript: {
current: "client.api.datasetRunItems.list",
replacement: "client.api.experiments.listItems",
+ minimumVersion: "5.10.0",
},
},
},
@@ -186,10 +205,12 @@ const guidanceByEndpoint: Record<
python: {
current: "client.api.datasets.get_runs",
replacement: "client.api.experiments.list",
+ minimumVersion: "4.13.1",
},
javascript: {
current: "client.api.datasets.getRuns",
replacement: "client.api.experiments.list",
+ minimumVersion: "5.10.0",
},
},
},
@@ -199,10 +220,12 @@ const guidanceByEndpoint: Record<
python: {
current: "client.api.datasets.get_run",
replacement: "client.api.experiments.list_items",
+ minimumVersion: "4.13.1",
},
javascript: {
current: "client.api.datasets.getRun",
replacement: "client.api.experiments.listItems",
+ minimumVersion: "5.10.0",
},
},
},
@@ -242,11 +265,15 @@ export const getApiMigrationGuidance = (
genericReplacements[endpoint] ??
"the replacement API in the migration guide";
const methods = sdkName ? endpointGuidance?.methods?.[sdkName] : undefined;
- if (!methods) return { replacement };
+ if (!sdkName || !methods) return { replacement };
return {
currentMethod: methods.current,
replacementMethod: methods.replacement,
+ ...(methods.previousMajorReplacement
+ ? { previousMajorReplacementMethod: methods.previousMajorReplacement }
+ : {}),
+ latestMajor: LANGFUSE_SDK_LATEST_MAJOR[sdkName],
replacement,
minimumVersion: methods.minimumVersion,
requiresUpgrade: methods.minimumVersion
diff --git a/web/src/features/v4-migration/sdkVersionStatus.clienttest.ts b/web/src/features/v4-migration/sdkVersionStatus.clienttest.ts
index 3d734940e7..30782868ef 100644
--- a/web/src/features/v4-migration/sdkVersionStatus.clienttest.ts
+++ b/web/src/features/v4-migration/sdkVersionStatus.clienttest.ts
@@ -2,6 +2,7 @@
import {
formatSdkUpgradeRequirement,
formatSdkVersion,
+ getAvailableSdkMajorUpgrade,
getCustomInstrumentationSectionState,
getDetectedInstrumentationSeries,
getOtelSectionState,
@@ -320,13 +321,68 @@ describe("v4 migration SDK status", () => {
});
it.each([
- [5, "upgrade required to >= 5.0.0"],
- [4, "upgrade required to >= 4.0.0"],
- [null, "upgrade required"],
+ ["javascript", 5, "upgrade required to v6 (>= 5.0.0 also works)"],
+ ["python", 4, "upgrade required to v5 (>= 4.0.0 also works)"],
+ [null, 4, "upgrade required to >= 4.0.0"],
+ ["python", null, "upgrade required"],
] as const)(
- "formats latest major %s as upgrade guidance",
- (latestSdkMajor, expected) => {
- expect(formatSdkUpgradeRequirement(latestSdkMajor)).toBe(expected);
+ "recommends the latest %s major with minimum %s as the smallest step",
+ (canonicalSdkName, latestSdkMajor, expected) => {
+ expect(
+ formatSdkUpgradeRequirement({ canonicalSdkName, latestSdkMajor }),
+ ).toBe(expected);
},
);
+
+ it.each([
+ [
+ "4.14.0",
+ {
+ label: "Python SDK v5",
+ upgradeGuideUrl:
+ "https://langfuse.com/docs/observability/sdk/upgrade-path/python-v4-to-v5",
+ },
+ ],
+ ["5.0.1", null],
+ ] as const)(
+ "offers the next Python major to compatible %s traffic",
+ (sdkVersion, expected) => {
+ expect(getAvailableSdkMajorUpgrade(sdkSeries({ sdkVersion }))).toEqual(
+ expected,
+ );
+ },
+ );
+
+ it.each([
+ [
+ "5.10.0",
+ {
+ label: "JS SDK v6",
+ upgradeGuideUrl:
+ "https://langfuse.com/docs/observability/sdk/upgrade-path/js-v5-to-v6",
+ },
+ ],
+ ["6.0.0", null],
+ ] as const)(
+ "offers the next JS major to compatible %s traffic",
+ (sdkVersion, expected) => {
+ expect(
+ getAvailableSdkMajorUpgrade(
+ sdkSeries({ sdkName: "@langfuse/tracing", sdkVersion }),
+ ),
+ ).toEqual(expected);
+ },
+ );
+
+ it("does not offer a major upgrade to non-SDK traffic", () => {
+ expect(
+ getAvailableSdkMajorUpgrade(
+ sdkSeries({
+ source: "otel",
+ sdkName: "otelcol",
+ sdkVersion: "0.98.0",
+ }),
+ ),
+ ).toBeNull();
+ });
});
diff --git a/web/src/features/v4-migration/sdkVersionStatus.ts b/web/src/features/v4-migration/sdkVersionStatus.ts
index 4556aebd5d..98ebf7074f 100644
--- a/web/src/features/v4-migration/sdkVersionStatus.ts
+++ b/web/src/features/v4-migration/sdkVersionStatus.ts
@@ -1,6 +1,7 @@
/* eslint-disable no-nested-ternary */
import { type RouterOutputs } from "@/src/utils/api";
import { type SdkVersionInfo } from "@/src/features/sdk-version";
+import { LANGFUSE_SDK_LATEST_MAJOR } from "@langfuse/shared";
type V4MigrationSdkStatus =
| "checking"
@@ -208,10 +209,42 @@ export const formatSdkVersion = (sdkVersion: SdkVersionInfo | undefined) => {
return `${language} ${sdkVersion.version}`;
};
+const SDK_MAJOR_UPGRADE_GUIDE_URLS = {
+ python:
+ "https://langfuse.com/docs/observability/sdk/upgrade-path/python-v4-to-v5",
+ javascript:
+ "https://langfuse.com/docs/observability/sdk/upgrade-path/js-v5-to-v6",
+} as const satisfies Record<keyof typeof LANGFUSE_SDK_LATEST_MAJOR, string>;
+
+/** A newer SDK major for V4-compatible traffic still on the previous major. */
+export const getAvailableSdkMajorUpgrade = (
+ series: V4MigrationSdkUsageSeries,
+): { label: string; upgradeGuideUrl: string } | null => {
+ if (
+ series.remediationType !== "update_sdk" ||
+ !series.canonicalSdkName ||
+ series.sdkVersionMajor === null
+ ) {
+ return null;
+ }
+ const latestMajor = LANGFUSE_SDK_LATEST_MAJOR[series.canonicalSdkName];
+ if (series.sdkVersionMajor >= latestMajor) return null;
+ return {
+ label: `${series.canonicalSdkName === "python" ? "Python" : "JS"} SDK v${latestMajor}`,
+ upgradeGuideUrl: SDK_MAJOR_UPGRADE_GUIDE_URLS[series.canonicalSdkName],
+ };
+};
+
+/** `latestSdkMajor` is the minimum V4-compatible major from the SQL check. */
export const formatSdkUpgradeRequirement = (
- latestSdkMajor: V4MigrationSdkUsageSeries["latestSdkMajor"],
+ series: Pick<
+ V4MigrationSdkUsageSeries,
+ "canonicalSdkName" | "latestSdkMajor"
+ >,
) => {
- return latestSdkMajor
- ? `upgrade required to >= ${latestSdkMajor}.0.0`
- : "upgrade required";
+ if (!series.latestSdkMajor) return "upgrade required";
+ if (!series.canonicalSdkName) {
+ return `upgrade required to >= ${series.latestSdkMajor}.0.0`;
+ }
+ return `upgrade required to v${LANGFUSE_SDK_LATEST_MAJOR[series.canonicalSdkName]} (>= ${series.latestSdkMajor}.0.0 also works)`;
};