Skip to content

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

refactor: rename trace2 to trace and deprecate old trace view (#10903)

Michael Fröhlich7abd62aea062
diff --git a/web/src/components/layouts/app-layout/utils/pathClassification.ts b/web/src/components/layouts/app-layout/utils/pathClassification.ts
index e7e8b1d8ca..23a2ec972b 100644
--- a/web/src/components/layouts/app-layout/utils/pathClassification.ts
+++ b/web/src/components/layouts/app-layout/utils/pathClassification.ts
@@ -15,7 +15,6 @@ export const PATH_CONSTANTS = {
publishable: [
"/project/[projectId]/sessions/[sessionId]",
"/project/[projectId]/traces/[traceId]",
- "/project/[projectId]/traces2/[traceId]",
"/auth/reset-password",
] as const,
};
diff --git a/web/src/components/trace2/TracePage.tsx b/web/src/components/trace2/TracePage.tsx
index 3e22aae257..00697544b1 100644
--- a/web/src/components/trace2/TracePage.tsx
+++ b/web/src/components/trace2/TracePage.tsx
@@ -164,7 +164,7 @@ export function TracePage({
? `?${queryParams.toString()}`
: "";
- return `/project/${projectId as string}/traces2/${entry.id}${finalQueryString}`;
+ return `/project/${projectId as string}/traces/${entry.id}${finalQueryString}`;
}}
listKey="traces"
/>
diff --git a/web/src/pages/project/[projectId]/traces2/[traceId].tsx b/web/src/pages/project/[projectId]/traces-old/[traceId].tsx
similarity index 86%
rename from web/src/pages/project/[projectId]/traces2/[traceId].tsx
rename to web/src/pages/project/[projectId]/traces-old/[traceId].tsx
index bfa4f298db..1fd763d566 100644
--- a/web/src/pages/project/[projectId]/traces2/[traceId].tsx
+++ b/web/src/pages/project/[projectId]/traces-old/[traceId].tsx
@@ -1,4 +1,4 @@
-import { TracePage } from "@/src/components/trace2/TracePage";
+import { TracePage } from "@/src/components/trace/TracePage";
import { useRouter } from "next/router";
export default function Trace() {
diff --git a/web/src/pages/project/[projectId]/traces/setup.tsx b/web/src/pages/project/[projectId]/traces-old/setup.tsx
similarity index 100%
rename from web/src/pages/project/[projectId]/traces/setup.tsx
rename to web/src/pages/project/[projectId]/traces-old/setup.tsx
diff --git a/web/src/pages/project/[projectId]/traces/[traceId].tsx b/web/src/pages/project/[projectId]/traces/[traceId].tsx
index 1fd763d566..bfa4f298db 100644
--- a/web/src/pages/project/[projectId]/traces/[traceId].tsx
+++ b/web/src/pages/project/[projectId]/traces/[traceId].tsx
@@ -1,4 +1,4 @@
-import { TracePage } from "@/src/components/trace/TracePage";
+import { TracePage } from "@/src/components/trace2/TracePage";
import { useRouter } from "next/router";
export default function Trace() {
diff --git a/web/src/pages/trace-old/[traceId].tsx b/web/src/pages/trace-old/[traceId].tsx
new file mode 100644
index 0000000000..0b15cf4854
--- /dev/null
+++ b/web/src/pages/trace-old/[traceId].tsx
@@ -0,0 +1,80 @@
+import { ErrorPage } from "@/src/components/error-page";
+import { getTracesByIdsForAnyProject } from "@langfuse/shared/src/server";
+import { type GetServerSideProps } from "next";
+import { useRouter } from "next/router";
+
+export const getServerSideProps: GetServerSideProps = async (context) => {
+ if (!context.params) {
+ return {
+ props: {
+ notFound: true,
+ },
+ };
+ }
+
+ const traceId = context.params.traceId as string;
+
+ const traces = await getTracesByIdsForAnyProject([traceId]);
+
+ if (!traces || traces.length === 0) {
+ return {
+ props: {
+ notFound: true,
+ },
+ };
+ }
+
+ if (traces.length > 1) {
+ return {
+ props: {
+ duplicatesFound: true,
+ },
+ };
+ }
+
+ return {
+ redirect: {
+ destination: `/project/${traces[0].projectId}/traces/${traceId}`,
+ permanent: false,
+ },
+ };
+};
+
+const TraceRedirectPage = ({
+ notFound,
+ duplicatesFound,
+}: {
+ notFound?: boolean;
+ duplicatesFound?: boolean;
+}) => {
+ const router = useRouter();
+ if (router.isFallback) {
+ return <div className="p-3">Loading...</div>;
+ }
+
+ if (notFound) {
+ return (
+ <ErrorPage
+ title="Trace not found"
+ message="The trace is either still being processed or has been deleted."
+ additionalButton={{
+ label: "Retry",
+ onClick: () => void window.location.reload(),
+ }}
+ />
+ );
+ }
+
+ if (duplicatesFound) {
+ return (
+ <ErrorPage
+ title="Trace not found"
+ message="Please upgrade the SDK as the URL schema has changed."
+ />
+ );
+ }
+
+ return null;
+};
+
+export default TraceRedirectPage;
diff --git a/web/src/pages/trace/[traceId].tsx b/web/src/pages/trace/[traceId].tsx
index 0b15cf4854..7bace24e15 100644
--- a/web/src/pages/trace/[traceId].tsx
+++ b/web/src/pages/trace/[traceId].tsx
@@ -1,3 +1,7 @@
+// Redirect helper for /trace/[traceId] URLs
+// Looks up the projectId for a trace and redirects to /project/[projectId]/traces/[traceId]
+// which displays the current trace view
+
import { ErrorPage } from "@/src/components/error-page";
import { getTracesByIdsForAnyProject } from "@langfuse/shared/src/server";
import { type GetServerSideProps } from "next";