Skip to content

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

chore(agent): add project url to metadata (#15136)

Nimarc9284fbd5e6f
diff --git a/web/src/ee/features/in-app-agent/server/handler.ts b/web/src/ee/features/in-app-agent/server/handler.ts
index a7f37a714c..f631f317bf 100644
--- a/web/src/ee/features/in-app-agent/server/handler.ts
+++ b/web/src/ee/features/in-app-agent/server/handler.ts
@@ -51,6 +51,7 @@ import {
} from "@/src/features/public-api/server/RateLimitService";
import { getLangfuseAITraceSinkParams } from "@/src/features/ai-features/server/bedrockCompletion";
import { isProjectMemberOrAdmin } from "@/src/server/utils/checkProjectMembershipOrAdmin";
+import { getProductBaseUrl } from "@/src/utils/base-url";
import { assertUnreachable } from "@/src/utils/types";
import {
BaseError,
@@ -477,6 +478,10 @@ export default async function handler(request: Request) {
langfuse_ai_feature: "in-app-agent",
langfuse_user_id: userId,
langfuse_project_id: projectId,
+ langfuse_project_url: new URL(
+ `project/${encodeURIComponent(projectId)}`,
+ getProductBaseUrl(),
+ ).toString(),
conversation_id: conversation.id,
thread_id: sanitizedInput.threadId,
run_id: sanitizedInput.runId,
diff --git a/web/src/ee/features/in-app-agent/server/persistence.ts b/web/src/ee/features/in-app-agent/server/persistence.ts
index 059d308a87..ce815fea89 100644
--- a/web/src/ee/features/in-app-agent/server/persistence.ts
+++ b/web/src/ee/features/in-app-agent/server/persistence.ts
@@ -19,6 +19,7 @@ import {
generateLangfuseAIText,
getLangfuseAITraceSinkParams,
} from "@/src/features/ai-features/server/bedrockCompletion";
+import { getProductBaseUrl } from "@/src/utils/base-url";
import { truncate } from "@/src/utils/string";
import { assertUnreachable } from "@/src/utils/types";
import {
@@ -432,6 +433,10 @@ ${JSON.stringify(transcript, null, 2)}
traceName: "in-app-agent-conversation-title",
userId: params.userId,
metadata: {
+ langfuse_project_url: new URL(
+ `project/${encodeURIComponent(params.projectId)}`,
+ getProductBaseUrl(),
+ ).toString(),
conversation_id: params.conversationId,
},
})
diff --git a/web/src/features/search-bar/server/router.ts b/web/src/features/search-bar/server/router.ts
index e87f18bf2d..4435527ae8 100644
--- a/web/src/features/search-bar/server/router.ts
+++ b/web/src/features/search-bar/server/router.ts
@@ -34,6 +34,7 @@ import {
getLangfuseAITraceSinkParams,
isLangfuseAITracingConfigured,
} from "@/src/features/ai-features/server/bedrockCompletion";
+import { getProductBaseUrl } from "@/src/utils/base-url";
// Caps shared with `observedScoreNamesFromOptions` (the client-side builder),
// which sends a set as undefined instead of ever exceeding them.
@@ -160,6 +161,10 @@ export const searchBarRouter = createTRPCRouter({
userId: ctx.session.user.id,
metadata: {
langfuse_user_id: ctx.session.user.id,
+ langfuse_project_url: new URL(
+ `project/${encodeURIComponent(ctx.session.projectId)}`,
+ getProductBaseUrl(),
+ ).toString(),
...(ctx.session.user.email
? { langfuse_user_email: ctx.session.user.email }
: {}),