diff --git a/static/app/views/explore/conversations/onboarding.tsx b/static/app/views/explore/conversations/onboarding.tsx index fd8ab8c8259b4f..3211db7365003f 100644 --- a/static/app/views/explore/conversations/onboarding.tsx +++ b/static/app/views/explore/conversations/onboarding.tsx @@ -273,6 +273,39 @@ Sentry.setConversationId("my-conversation-123");`, }; } +function getSetUserStep(isPython: boolean): OnboardingStep { + const content: ContentBlock[] = [ + { + type: 'text', + text: t( + 'Identify the user behind each conversation so the Conversations view can show who sent each message:' + ), + }, + isPython + ? { + type: 'code' as const, + language: 'python', + code: `import sentry_sdk + +# Call this once per request / session, before any AI calls +sentry_sdk.set_user({"id": "user_123", "email": "jane@example.com", "username": "jane"})`, + } + : { + type: 'code' as const, + language: 'javascript', + code: `import * as Sentry from "@sentry/node"; + +// Call this once per request / session, before any AI calls +Sentry.setUser({ id: "user_123", email: "jane@example.com", username: "jane" });`, + }, + ]; + + return { + title: t('Identify Users (optional)'), + content, + }; +} + export function ConversationOnboarding({onDismiss}: {onDismiss: () => void}) { const api = useApi(); const {isSelfHosted, urlPrefix} = useLegacyStore(ConfigStore); @@ -369,6 +402,7 @@ export function ConversationOnboarding({onDismiss}: {onDismiss: () => void}) { ...(agentMonitoringDocs.install?.(docParams) || []), ...(agentMonitoringDocs.configure?.(docParams) || []), getConversationIdStep(selectedIntegration, isPythonPlatform), + getSetUserStep(isPythonPlatform), ...(agentMonitoringDocs.verify?.(docParams) || []), ].filter(s => !s.collapsible); diff --git a/static/app/views/insights/pages/agents/llmOnboardingInstructions.tsx b/static/app/views/insights/pages/agents/llmOnboardingInstructions.tsx index f8a4623c9ff6f2..56cbdc43155ea3 100644 --- a/static/app/views/insights/pages/agents/llmOnboardingInstructions.tsx +++ b/static/app/views/insights/pages/agents/llmOnboardingInstructions.tsx @@ -70,6 +70,7 @@ export const LLM_ONBOARDING_COPY_MARKDOWN = ` > The setup steps above contain the correct DSN and project-specific SDK configuration — complete them first. > Then follow the skill references below for instrumentation and agent naming. > If the app has multi-turn chats, set a conversation ID for each chat so Sentry can send the gen_ai.conversation.id attribute and show the session in Conversations. +> Also call setUser (JS) / sentry_sdk.set_user (Python) once per request or session so conversations are attributed to users in the Conversations view. # Instrument Sentry AI Agent Monitoring