Track individual end users interacting with your AI app in Netra. Associate traces with user IDs to analyze behavior, costs, and quality.
The Users view in Netra provides a list of all end users who have interacted with your AI applications. It helps you understand user activity, correlate behavior with system usage, and debug user-specific issues.
Viewing Users
Access the Users view from Observability → Users in the Netra dashboard.For each user, Netra displays:
Field
Description
User ID
The identifier you assigned via setUserId()
Tenant
The tenant this user belongs to (if configured)
First Interaction
When the user first interacted with the system
Last Interaction
When the user was most recently active
Sessions
Number of sessions generated by this user
Traces
Total number of traces from this user
Total Cost
Estimated cost incurred by this user’s activity
User Actions
Each user entry provides:
View Traces - Opens the Traces view filtered to this user, showing all their requests and executions
Configuring User Tracking
User tracking is configured by calling setUserId() in your application code. Once set, all subsequent traces will be associated with that user.
Setting the User ID
Call setUserId() after initializing Netra and when you know the user’s identity (e.g., after authentication):Set your Netra endpoint and API key before you call Netra.init(). Without NETRA_OTLP_ENDPOINT, the SDK prints spans to the console instead of sending them to Netra, and your dashboard stays empty.
Set these wherever your app runs, including Docker containers and CI jobs.
from netra import Netra# Initialize NetraNetra.init( app_name="my-ai-app", environment="production",)# After user authenticationdef on_user_login(user): Netra.set_user_id(user.id)# All subsequent traces will be associated with this userresponse = openai.chat.completions.create( model="gpt-4", messages=[{"role": "user", "content": query}],)
import { Netra } from "netra-sdk";// Initialize Netraawait Netra.init({ appName: "my-ai-app", environment: "production",});// After user authenticationfunction onUserLogin(user: User) { Netra.setUserId(user.id);}// All subsequent traces will be associated with this userconst response = await openai.chat.completions.create({ model: "gpt-4", messages: [{ role: "user", content: query }],});
User ID in Web Frameworks
For web applications, set the user ID in your request middleware:
from netra import Netrafrom fastapi import FastAPI, Depends, Requestapp = FastAPI()async def set_user_context(request: Request): if hasattr(request.state, "user") and request.state.user: Netra.set_user_id(request.state.user.id)@app.post("/api/chat")async def chat(message: str, _=Depends(set_user_context)): # This trace will be associated with the authenticated user response = await process_chat(message) return response
import { Netra } from "netra-sdk";import express from "express";const app = express();// Middleware to set user contextapp.use((req, res, next) => { if (req.user?.id) { Netra.setUserId(req.user.id); } next();});app.post("/api/chat", async (req, res) => { // This trace will be associated with the authenticated user const response = await processChat(req.body.message); res.json(response);});
Combining with Tenant and Session
For multi-tenant applications, combine user tracking with tenant and session IDs:
from netra import Netradef initialize_user_context(user, tenant, session_id: str): # Set all context attributes Netra.set_user_id(user.id) Netra.set_tenant_id(tenant.id) Netra.set_session_id(session_id) # Optionally add custom attributes Netra.set_custom_attributes("user.plan", user.plan) Netra.set_custom_attributes("user.region", user.region)# All traces will now include user, tenant, and session context
import { Netra } from "netra-sdk";function initializeUserContext(user: User, tenant: Tenant, sessionId: string) { // Set all context attributes Netra.setUserId(user.id); Netra.setTenantId(tenant.id); Netra.setSessionId(sessionId); // Optionally add custom attributes Netra.setCustomAttributes("user.plan", user.plan); Netra.setCustomAttributes("user.region", user.region);}// All traces will now include user, tenant, and session context
User Context Methods
Method
Description
setUserId(userId)
Associate traces with a user identifier
setTenantId(tenantId)
Associate traces with a tenant (for multi-tenant apps)
setSessionId(sessionId)
Group traces into a session
setCustomAttributes(key, value)
Add custom metadata to traces
Use Cases
Per-User Cost Analysis
Track costs incurred by each user to understand usage patterns and implement usage-based billing:
Navigate to Observability → Users
Sort by Total Cost to find highest-cost users
Click View Traces to understand their usage patterns
Debugging User-Specific Issues
When a user reports an issue:
Search for the user by their ID
Click View Traces to see their recent activity
Identify failed or slow traces
Drill into specific traces to debug
User Activity Monitoring
Track user engagement with your AI features:
Sessions count - How often users return
Traces count - How much they use AI features
Last interaction - When they were last active
Best Practices
Use stable user IDs - Use your application’s user ID, not ephemeral session tokens
Set user ID early - Call setUserId() as soon as authentication completes
Handle anonymous users - For unauthenticated users, consider using a consistent anonymous ID or skip user tracking
Combine with sessions - Use session IDs to group related traces within a user’s activity
Add relevant attributes - Include user plan, region, or other attributes useful for analysis
Privacy Considerations
User IDs are stored in Netra and appear in the dashboard
Avoid using PII (email, name) as user IDs—use opaque identifiers instead
In the Python SDK, user IDs are not sent to third-party hosts in the baggage header of outbound httpx and requests calls. Only hosts listed in NETRA_PROPAGATE_BAGGAGE_HOSTS receive it
Consider your data retention requirements when storing user activity
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Netra Docs","description":"Get started with Netra, the agent observability, evaluation, and simulation platform: quick start, features, configuration, SDKs, and analytics.","colors":{"primary":"#de8900","light":"#ffb030","dark":"#c28015"},"logo":{"light":"https://mintcdn.com/netra/1ia3d6PyPeHWosXy/images/logo.webp?fit=max\u0026auto=format\u0026n=1ia3d6PyPeHWosXy\u0026q=85\u0026s=e02f03f860c5d038c9e54a14d75f3bdc","dark":"https://mintcdn.com/netra/1ia3d6PyPeHWosXy/images/logo.webp?fit=max\u0026auto=format\u0026n=1ia3d6PyPeHWosXy\u0026q=85\u0026s=e02f03f860c5d038c9e54a14d75f3bdc","href":"https://getnetra.ai/"},"favicon":"https://mintlify.s3.us-west-1.amazonaws.com/netra/images/favicon.webp","navbar":{"links":[{"href":"https://getnetra.ai/contact-us/","label":"Help \u0026 Support"}],"primary":{"type":"button","label":"Get Netra","href":"https://getnetra.ai/"}},"footer":{"socials":{"linkedin":"https://www.linkedin.com/company/getnetra","youtube":"https://www.youtube.com/@getnetra","x-twitter":"https://x.com/getnetraAI"}},"integrations":{"ga4":{"measurementId":"G-3YDX95VL9Y"}},"contextual":{"options":["copy","view","chatgpt","claude"],"display":"header"},"metadata":{"timestamp":true},"styling":{"latex":false},"navigation":{"global":{"anchors":[{"anchor":"Github","icon":"github","href":"https://github.com/KeyValueSoftwareSystems/netra-sdk-py"},{"anchor":"Python SDK","icon":"python","href":"https://docs.getnetra.ai/sdk-reference/sdk/python"},{"anchor":"TypeScript SDK","icon":"js","href":"https://docs.getnetra.ai/sdk-reference/sdk/typescript"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"netra","hasAudioNarration":false,"actualSubdomain":"netra","customDomains":["docs.getnetra.ai"],"gitSource":{"type":"github","owner":"keyvaluesoftwaresystems","repo":"netra-ai-docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":"","_id":"6af407ae9addfc3ccdb95778"},"entitlements":{},"buildId":"6afac3c9e7db7ac255ac4c0f","clientVersion":"0.0.4177","searchFilterCounts":[{"language":"default","tag":"Documentation","count":61},{"language":"default","tag":"Integrations","count":43},{"language":"default","tag":"Observability","count":17},{"language":"default","tag":"LLM Providers","count":14},{"language":"default","tag":"SDK","count":14},{"language":"default","tag":"LLM Frameworks","count":10},{"language":"default","tag":"Cookbooks","count":9},{"language":"default","tag":"Traces","count":9},{"language":"default","tag":"Get Started","count":8},{"language":"default","tag":"Evaluations","count":8}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"Observability/Users","slug":"/Observability/Users","pageMetadata":{"title":"Users","description":"Track individual end users interacting with your AI app in Netra. Associate traces with user IDs to analyze behavior, costs, and quality.","og:description":"Track individual end users interacting with your AI app in Netra. Associate traces with user IDs to analyze behavior, costs, and quality.","icon":"user","href":"/Observability/Users"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Track individual end users interacting with your AI app in Netra. Associate traces with user IDs to analyze behavior, costs, and quality.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,CodeGroup,Heading,OptimizedImage,Table}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!CodeGroup)_missingMdxReference(`CodeGroup`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!OptimizedImage)_missingMdxReference(`OptimizedImage`,true);if(!Table)_missingMdxReference(`Table`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`The Users view in Netra provides a list of all end users who have interacted with your AI applications. It helps you understand user activity, correlate behavior with system usage, and debug user-specific issues.`}),`\n`,_jsx(Heading,{level:`2`,id:`viewing-users`,children:`Viewing Users`}),`\n`,_jsxs(_components.p,{children:[`Access the Users view from `,_jsx(_components.strong,{children:`Observability → Users`}),` in the Netra dashboard.`]}),`\n`,_jsx(OptimizedImage,{src:`https://mintcdn.com/netra/hTm20ddSCP9TtT6W/images/Users.png?fit=max\u0026auto=format\u0026n=hTm20ddSCP9TtT6W\u0026q=85\u0026s=d88dc04bb0c6fc6e33afa42292415fe6`,alt:`Users View`,\"data-og-width\":`1912`,width:`1912`,\"data-og-height\":`886`,height:`886`,\"data-path\":`images/Users.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/netra/hTm20ddSCP9TtT6W/images/Users.png?w=280\u0026fit=max\u0026auto=format\u0026n=hTm20ddSCP9TtT6W\u0026q=85\u0026s=3df31e5bf6f268df633e842ae8196cff 280w, https://mintcdn.com/netra/hTm20ddSCP9TtT6W/images/Users.png?w=560\u0026fit=max\u0026auto=format\u0026n=hTm20ddSCP9TtT6W\u0026q=85\u0026s=35d711579c4947b67e4ad48b20843c68 560w, https://mintcdn.com/netra/hTm20ddSCP9TtT6W/images/Users.png?w=840\u0026fit=max\u0026auto=format\u0026n=hTm20ddSCP9TtT6W\u0026q=85\u0026s=d4a3ca08873601986d8a385a4574c01c 840w, https://mintcdn.com/netra/hTm20ddSCP9TtT6W/images/Users.png?w=1100\u0026fit=max\u0026auto=format\u0026n=hTm20ddSCP9TtT6W\u0026q=85\u0026s=3609d9a9b26fd79f94b60801cb344070 1100w, https://mintcdn.com/netra/hTm20ddSCP9TtT6W/images/Users.png?w=1650\u0026fit=max\u0026auto=format\u0026n=hTm20ddSCP9TtT6W\u0026q=85\u0026s=06429ff989f70e7b5be3a6bc805966b8 1650w, https://mintcdn.com/netra/hTm20ddSCP9TtT6W/images/Users.png?w=2500\u0026fit=max\u0026auto=format\u0026n=hTm20ddSCP9TtT6W\u0026q=85\u0026s=80bd16cd44b802499f0871169f35c06d 2500w`}),`\n`,_jsx(_components.p,{children:`For each user, Netra displays:`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Field`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`User ID`})}),_jsxs(_components.td,{children:[`The identifier you assigned via `,_jsx(_components.code,{children:`setUserId()`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Tenant`})}),_jsx(_components.td,{children:`The tenant this user belongs to (if configured)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`First Interaction`})}),_jsx(_components.td,{children:`When the user first interacted with the system`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Last Interaction`})}),_jsx(_components.td,{children:`When the user was most recently active`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Sessions`})}),_jsx(_components.td,{children:`Number of sessions generated by this user`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Traces`})}),_jsx(_components.td,{children:`Total number of traces from this user`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Total Cost`})}),_jsx(_components.td,{children:`Estimated cost incurred by this user’s activity`})]})]})]}),`\n`,_jsx(Heading,{level:`3`,id:`user-actions`,children:`User Actions`}),`\n`,_jsx(_components.p,{children:`Each user entry provides:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`View Traces`}),` - Opens the Traces view filtered to this user, showing all their requests and executions`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`configuring-user-tracking`,children:`Configuring User Tracking`}),`\n`,_jsxs(_components.p,{children:[`User tracking is configured by calling `,_jsx(_components.code,{children:`setUserId()`}),` in your application code. Once set, all subsequent traces will be associated with that user.`]}),`\n`,_jsx(Heading,{level:`3`,id:`setting-the-user-id`,children:`Setting the User ID`}),`\n`,_jsxs(_components.p,{children:[`Call `,_jsx(_components.code,{children:`setUserId()`}),` after initializing Netra and when you know the user’s identity (e.g., after authentication):`]}),`\n`,_jsxs(_components.p,{children:[`Set your Netra endpoint and API key before you call `,_jsx(_components.code,{children:`Netra.init()`}),`. Without `,_jsx(_components.code,{children:`NETRA_OTLP_ENDPOINT`}),`, the SDK prints spans to the console instead of sending them to Netra, and your dashboard stays empty.`]}),`\n`,_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`US Region`,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` NETRA_OTLP_ENDPOINT=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"https://api.getnetra.ai/telemetry\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` NETRA_API_KEY=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"your-api-key-here\"`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`EU Region`,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` NETRA_OTLP_ENDPOINT=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"https://api.eu.getnetra.ai/telemetry\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` NETRA_API_KEY=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"your-api-key-here\"`})]}),`\n`]})})})]}),`\n`,_jsx(_components.p,{children:`Set these wherever your app runs, including Docker containers and CI jobs.`}),`\n`,_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Python`,numberOfLines:`17`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`17`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` netra `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Netra`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Initialize Netra`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`Netra.init(`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` app_name=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"my-ai-app\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` environment=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"production\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# After user authentication`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`def`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` on_user_login(user):`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Netra.set_user_id(user.id)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# All subsequent traces will be associated with this user`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`response = openai.chat.completions.create(`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` model=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"gpt-4\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` messages=[{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: query}],`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`]})})}),_jsx(CodeBlock,{filename:`TypeScript`,numberOfLines:`18`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`18`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { Netra } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"netra-sdk\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Initialize Netra`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Netra.init({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` appName: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"my-ai-app\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` environment: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"production\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// After user authentication`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`function`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` onUserLogin(user: User) {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Netra.setUserId(user.id);`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// All subsequent traces will be associated with this user`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` response = `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` openai.chat.completions.create({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` model: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"gpt-4\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` messages: [{ role: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, content: query }],`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`]})})})]}),`\n`,_jsx(Heading,{level:`3`,id:`user-id-in-web-frameworks`,children:`User ID in Web Frameworks`}),`\n`,_jsx(_components.p,{children:`For web applications, set the user ID in your request middleware:`}),`\n`,_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Python (FastAPI)`,numberOfLines:`14`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`14`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` netra `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Netra`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` fastapi `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` FastAPI, Depends, Request`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`app = FastAPI()`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` def`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` set_user_context(request: Request):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` hasattr(request.state, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`and`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` request.state.user:`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Netra.set_user_id(request.state.user.id)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`@app.post(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"/api/chat\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` def`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` chat(message: str, _=Depends(set_user_context)):`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # This trace will be associated with the authenticated user`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` response = `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` process_chat(message)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` response`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`TypeScript (Express)`,numberOfLines:`18`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`18`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { Netra } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"netra-sdk\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` express `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"express\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` app = express();`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Middleware to set user context`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`app.use((req, res, next) => {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (req.user?.id) {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Netra.setUserId(req.user.id);`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` next();`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`app.post(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"/api/chat\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`async`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (req, res) => {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // This trace will be associated with the authenticated user`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` response = `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` processChat(req.body.message);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` res.json(response);`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`]})})})]}),`\n`,_jsx(Heading,{level:`3`,id:`combining-with-tenant-and-session`,children:`Combining with Tenant and Session`}),`\n`,_jsx(_components.p,{children:`For multi-tenant applications, combine user tracking with tenant and session IDs:`}),`\n`,_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Python`,numberOfLines:`13`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`13`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` netra `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Netra`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`def`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` initialize_user_context(user, tenant, session_id: str):`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # Set all context attributes`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Netra.set_user_id(user.id)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Netra.set_tenant_id(tenant.id)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Netra.set_session_id(session_id)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # Optionally add custom attributes`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Netra.set_custom_attributes(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user.plan\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, user.plan)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Netra.set_custom_attributes(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user.region\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, user.region)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# All traces will now include user, tenant, and session context`})}),`\n`]})})}),_jsx(CodeBlock,{filename:`TypeScript`,numberOfLines:`14`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`14`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { Netra } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"netra-sdk\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`function`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` initializeUserContext(user: User, tenant: Tenant, sessionId: string) {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Set all context attributes`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Netra.setUserId(user.id);`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Netra.setTenantId(tenant.id);`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Netra.setSessionId(sessionId);`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Optionally add custom attributes`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Netra.setCustomAttributes(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user.plan\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, user.plan);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Netra.setCustomAttributes(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user.region\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, user.region);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// All traces will now include user, tenant, and session context`})}),`\n`]})})})]}),`\n`,_jsx(Heading,{level:`2`,id:`user-context-methods`,children:`User Context Methods`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Method`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`setUserId(userId)`})}),_jsx(_components.td,{children:`Associate traces with a user identifier`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`setTenantId(tenantId)`})}),_jsx(_components.td,{children:`Associate traces with a tenant (for multi-tenant apps)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`setSessionId(sessionId)`})}),_jsx(_components.td,{children:`Group traces into a session`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`setCustomAttributes(key, value)`})}),_jsx(_components.td,{children:`Add custom metadata to traces`})]})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`use-cases`,children:`Use Cases`}),`\n`,_jsx(Heading,{level:`3`,id:`per-user-cost-analysis`,children:`Per-User Cost Analysis`}),`\n`,_jsx(_components.p,{children:`Track costs incurred by each user to understand usage patterns and implement usage-based billing:`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Navigate to `,_jsx(_components.strong,{children:`Observability → Users`})]}),`\n`,_jsxs(_components.li,{children:[`Sort by `,_jsx(_components.strong,{children:`Total Cost`}),` to find highest-cost users`]}),`\n`,_jsxs(_components.li,{children:[`Click `,_jsx(_components.strong,{children:`View Traces`}),` to understand their usage patterns`]}),`\n`]}),`\n`,_jsx(Heading,{level:`3`,id:`debugging-user-specific-issues`,children:`Debugging User-Specific Issues`}),`\n`,_jsx(_components.p,{children:`When a user reports an issue:`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsx(_components.li,{children:`Search for the user by their ID`}),`\n`,_jsxs(_components.li,{children:[`Click `,_jsx(_components.strong,{children:`View Traces`}),` to see their recent activity`]}),`\n`,_jsx(_components.li,{children:`Identify failed or slow traces`}),`\n`,_jsx(_components.li,{children:`Drill into specific traces to debug`}),`\n`]}),`\n`,_jsx(Heading,{level:`3`,id:`user-activity-monitoring`,children:`User Activity Monitoring`}),`\n`,_jsx(_components.p,{children:`Track user engagement with your AI features:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Sessions count`}),` - How often users return`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Traces count`}),` - How much they use AI features`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Last interaction`}),` - When they were last active`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`best-practices`,children:`Best Practices`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Use stable user IDs`}),` - Use your application’s user ID, not ephemeral session tokens`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Set user ID early`}),` - Call `,_jsx(_components.code,{children:`setUserId()`}),` as soon as authentication completes`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Handle anonymous users`}),` - For unauthenticated users, consider using a consistent anonymous ID or skip user tracking`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Combine with sessions`}),` - Use session IDs to group related traces within a user’s activity`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Add relevant attributes`}),` - Include user plan, region, or other attributes useful for analysis`]}),`\n`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`privacy-considerations`,children:`Privacy Considerations`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`User IDs are stored in Netra and appear in the dashboard`}),`\n`,_jsx(_components.li,{children:`Avoid using PII (email, name) as user IDs—use opaque identifiers instead`}),`\n`,_jsxs(_components.li,{children:[`In the Python SDK, user IDs are not sent to third-party hosts in the `,_jsx(_components.code,{children:`baggage`}),` header of outbound `,_jsx(_components.code,{children:`httpx`}),` and `,_jsx(_components.code,{children:`requests`}),` calls. Only hosts listed in `,_jsx(_components.a,{href:`/Observability/Traces/configuration/environment-variables#context-propagation`,children:_jsx(_components.code,{children:`NETRA_PROPAGATE_BAGGAGE_HOSTS`})}),` receive it`]}),`\n`,_jsx(_components.li,{children:`Consider your data retention requirements when storing user activity`}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`next-steps`,children:`Next Steps`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/Observability/Session`,children:`Sessions`}),` - Group user interactions into sessions`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/Observability/Tenants`,children:`Tenants`}),` - Multi-tenant user organization`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/Observability/Traces/overview`,children:`Traces Overview`}),` - Understanding trace data`]}),`\n`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Users","description":"Track individual end users interacting with your AI app in Netra. Associate traces with user IDs to analyze behavior, costs, and quality.","og:description":"Track individual end users interacting with your AI app in Netra. Associate traces with user IDs to analyze behavior, costs, and quality.","icon":"user","href":"/Observability/Users"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Viewing Users","slug":"viewing-users","depth":2,"children":[{"title":"User Actions","slug":"user-actions","depth":3,"children":[]}]},{"title":"Configuring User Tracking","slug":"configuring-user-tracking","depth":2,"children":[{"title":"Setting the User ID","slug":"setting-the-user-id","depth":3,"children":[]},{"title":"User ID in Web Frameworks","slug":"user-id-in-web-frameworks","depth":3,"children":[]},{"title":"Combining with Tenant and Session","slug":"combining-with-tenant-and-session","depth":3,"children":[]}]},{"title":"User Context Methods","slug":"user-context-methods","depth":2,"children":[]},{"title":"Use Cases","slug":"use-cases","depth":2,"children":[{"title":"Per-User Cost Analysis","slug":"per-user-cost-analysis","depth":3,"children":[]},{"title":"Debugging User-Specific Issues","slug":"debugging-user-specific-issues","depth":3,"children":[]},{"title":"User Activity Monitoring","slug":"user-activity-monitoring","depth":3,"children":[]}]},{"title":"Best Practices","slug":"best-practices","depth":2,"children":[]},{"title":"Privacy Considerations","slug":"privacy-considerations","depth":2,"children":[]},{"title":"Next Steps","slug":"next-steps","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"netra","siteName":"Netra Docs","title":"Users - Netra Docs","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-11-11T06:14:42.228Z","gitLastModified":"2026-11-05T12:15:03.000Z","originalFileLocation":"Observability/Users.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Track individual end users interacting with your AI app in Netra. Associate traces with user IDs to analyze behavior, costs, and quality.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Netra Docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/netra/HA-8nRDCuOtEnrbQ/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/netra/HA-8nRDCuOtEnrbQ/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/netra/HA-8nRDCuOtEnrbQ/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/netra/HA-8nRDCuOtEnrbQ/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/netra/HA-8nRDCuOtEnrbQ/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/netra/HA-8nRDCuOtEnrbQ/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/netra/HA-8nRDCuOtEnrbQ/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/netra/HA-8nRDCuOtEnrbQ/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/netra/HA-8nRDCuOtEnrbQ/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Users - Netra Docs\">\u003cmeta data-mint-head property=\"og:description\" content=\"Track individual end users interacting with your AI app in Netra. Associate traces with user IDs to analyze behavior, costs, and quality.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Netra Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.getnetra.ai/Observability/Users\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://netra.mintlify.site/_mintlify/api/og/v2?division=Observability\u0026amp;title=Users\u0026amp;description=Track+individual+end+users+interacting+with+your+AI+app+in+Netra.+Associate+traces+with+user+IDs+to+analyze+behavior%2C+costs%2C+and+quality.\u0026amp;theme=3527def2702c0f8ab3a454ec\u0026amp;signature=da6648c88a7e48a1971d918a852b28bb5e6e7ae06b672cadc8c7ddfd1cf098b9\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Users - Netra Docs\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Track individual end users interacting with your AI app in Netra. Associate traces with user IDs to analyze behavior, costs, and quality.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://netra.mintlify.site/_mintlify/api/og/v2?division=Observability\u0026amp;title=Users\u0026amp;description=Track+individual+end+users+interacting+with+your+AI+app+in+Netra.+Associate+traces+with+user+IDs+to+analyze+behavior%2C+costs%2C+and+quality.\u0026amp;theme=3527def2702c0f8ab3a454ec\u0026amp;signature=da6648c88a7e48a1971d918a852b28bb5e6e7ae06b672cadc8c7ddfd1cf098b9\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/netra/HA-8nRDCuOtEnrbQ/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Netra Docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#de8900\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.getnetra.ai/Observability/Users\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/Observability/Users.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.getnetra.ai/#organization\",\"name\":\"Netra Docs\",\"url\":\"https://docs.getnetra.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/netra/1ia3d6PyPeHWosXy/images/logo.webp?fit=max\u0026auto=format\u0026n=1ia3d6PyPeHWosXy\u0026q=85\u0026s=e02f03f860c5d038c9e54a14d75f3bdc\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.getnetra.ai#website\",\"name\":\"Netra Docs\",\"url\":\"https://docs.getnetra.ai\",\"publisher\":{\"@id\":\"https://docs.getnetra.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.getnetra.ai/Observability/Users#webpage\",\"url\":\"https://docs.getnetra.ai/Observability/Users\",\"name\":\"Users\",\"description\":\"Track individual end users interacting with your AI app in Netra. Associate traces with user IDs to analyze behavior, costs, and quality.\",\"dateModified\":\"2026-11-05T12:15:03.000Z\",\"isPartOf\":{\"@id\":\"https://docs.getnetra.ai#website\"},\"breadcrumb\":{\"@id\":\"https://docs.getnetra.ai/Observability/Users#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.getnetra.ai/Observability/Users#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Observability\",\"item\":\"https://docs.getnetra.ai/Observability/Traces/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Users\",\"item\":\"https://docs.getnetra.ai/Observability/Users\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.getnetra.ai/Observability/Users#article\",\"headline\":\"Users\",\"name\":\"Users\",\"description\":\"Track individual end users interacting with your AI app in Netra. Associate traces with user IDs to analyze behavior, costs, and quality.\",\"url\":\"https://docs.getnetra.ai/Observability/Users\",\"mainEntityOfPage\":{\"@id\":\"https://docs.getnetra.ai/Observability/Users#webpage\"},\"dateModified\":\"2026-11-05T12:15:03.000Z\",\"publisher\":{\"@id\":\"https://docs.getnetra.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.getnetra.ai#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Netra Docs\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Netra Docs\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/Observability/Users.md","siteName":"Netra Docs","nav":{"global":{"anchors":[{"anchor":"Github","icon":"github","href":"https://github.com/KeyValueSoftwareSystems/netra-sdk-py"},{"anchor":"Python SDK","icon":"python","href":"https://docs.getnetra.ai/sdk-reference/sdk/python"},{"anchor":"TypeScript SDK","icon":"js","href":"https://docs.getnetra.ai/sdk-reference/sdk/typescript"}]},"tabs":[{"tab":"Documentation","icon":"book","groups":[{"group":" ","pages":[{"title":"Netra","icon":"house","href":"/netra"},{"title":"Netra FAQs","icon":"circle-question","href":"/FAQs/FAQs"}]},{"group":"Get Started","icon":"rocket","pages":[{"title":"Overview","icon":"flag-checkered","href":"/quick-start/Overview"},{"group":"Quick Start","icon":"play","pages":[{"title":"Quick Start: Tracing","icon":"route","href":"/quick-start/QuickStart_Tracing"},{"title":"Quick Start: Evaluation","icon":"clipboard-check","href":"/quick-start/QuickStart_Evals"},{"title":"Quick Start: Simulation","icon":"flask","href":"/quick-start/QuickStart_Simulation"},{"title":"Quick Start: Alerts","icon":"bell","href":"/quick-start/QuickStart_Alerts"}]},{"title":"Integration Best Practices","sidebarTitle":"Best Practices","icon":"shield-check","href":"/Best-Practices/Integration-Best-Practices"}]},{"group":"Observability","icon":"eye","pages":[{"group":"Traces","icon":"route","pages":[{"title":"Traces Overview","icon":"binoculars","href":"/Observability/Traces/overview"},{"title":"Spans","icon":"diagram-project","href":"/Observability/Traces/spans"},{"title":"Auto Instrumentation","icon":"wand-magic-sparkles","href":"/Observability/Traces/auto-instrumentation"},{"title":"Decorators","icon":"at","href":"/Observability/Traces/decorators"},{"title":"Manual Tracing","icon":"hand","href":"/Observability/Traces/manual-tracing"},{"group":"Configuration","icon":"gear","pages":[{"title":"Initialization","icon":"power-off","href":"/Observability/Traces/configuration/initialization"},{"title":"Environment Variables","icon":"leaf","href":"/Observability/Traces/configuration/environment-variables"},{"title":"Instrumentation Selection","icon":"list-check","href":"/Observability/Traces/configuration/instrumentation-selection"},{"title":"Custom Exporters","icon":"upload","href":"/Observability/Traces/configuration/custom-exporters"}]}]},{"title":"Tenants","icon":"building","href":"/Observability/Tenants"},{"title":"Agents","description":"Track AI agents in Netra. Associate traces with agent IDs to analyze per-agent cost, latency, and decision-making across your application.","icon":"robot","href":"/Observability/Agents"},{"title":"Users","icon":"user","href":"/Observability/Users"},{"title":"Sessions","description":"Group and analyze related AI interactions with Netra session tracking. Monitor multi-turn conversations, costs, and user behavior.","icon":"clock-rotate-left","href":"/Observability/Session"}]},{"group":"Insights","icon":"chart-line","pages":[{"title":"Insights Overview","icon":"chart-line","href":"/Insights/Insights-overview"},{"title":"Intents","icon":"list-check","href":"/Insights/Intents"},{"title":"Drifts","icon":"arrow-trend-up","href":"/Insights/Drifts"}]},{"group":"Evaluations","icon":"clipboard-check","pages":[{"title":"Evaluation Overview","icon":"gauge-high","href":"/Evaluations/evaluation-overview"},{"title":"Test Runs","icon":"flask-vial","href":"/Evaluations/TestRuns"},{"title":"Analytics","icon":"chart-line","href":"/Evaluations/Analytics"},{"group":"Text Evaluations","icon":"font","pages":[{"title":"Evaluations","icon":"table","href":"/Evaluations/text-evaluations/evaluations"},{"title":"Agents","icon":"robot","href":"/Evaluations/text-evaluations/agents"},{"title":"Online Evaluations","icon":"signal-bars-good","href":"/Evaluations/text-evaluations/online-evaluation"}]},{"group":"Image Evaluations","icon":"image","pages":[{"title":"Evaluations","icon":"table","href":"/Evaluations/image-evaluations/evaluations"},{"title":"Online Evaluations","icon":"signal-bars-good","href":"/Evaluations/image-evaluations/online-evaluation"}]}]},{"group":"Simulations","icon":"flask","pages":[{"title":"Simulation Overview","icon":"vial-circle-check","href":"/Simulations/Simulation-overview"},{"title":"Test Runs","icon":"flask-vial","href":"/Simulations/TestRuns"},{"title":"Analytics","icon":"chart-line","href":"/Simulations/Analytics"},{"group":"Text Simulations","icon":"font","pages":[{"title":"Simulations","icon":"table","href":"/Simulations/text-simulations/Simulations"},{"title":"Agents","icon":"robot","href":"/Simulations/text-simulations/agents"}]},{"group":"Voice Simulations","icon":"microphone","pages":[{"title":"Agents","icon":"robot","href":"/Simulations/voice-simulations/agents"},{"title":"Simulations","icon":"table","href":"/Simulations/voice-simulations/Simulations"},{"title":"Personas","icon":"user-group","href":"/Simulations/voice-simulations/Personas"}]}]},{"group":"Evaluators","icon":"scale-balanced","pages":[{"title":"Overview","icon":"scale-balanced","href":"/Evaluators/overview"},{"title":"Text Evaluators","icon":"font","href":"/Evaluators/text-evaluators"},{"title":"Voice Evaluators","icon":"microphone","href":"/Evaluators/voice-evaluators"},{"title":"Image Evaluators","icon":"image","href":"/Evaluators/image-evaluators"}]},{"group":"Red Teaming","icon":"shield-halved","pages":[{"title":"Overview","icon":"shield-halved","href":"/Redteaming/Redteaming-overview"},{"title":"Suites \u0026 Evaluators","icon":"shield-check","href":"/Redteaming/Suites-and-Evaluators"},{"title":"Setup","icon":"gear","href":"/Redteaming/Configs"},{"title":"Runs \u0026 Results","icon":"play","href":"/Redteaming/Runs"},{"title":"Risk Scores \u0026 Progress","icon":"chart-line","href":"/Redteaming/Risk-Scores"}]},{"group":"Prompt Management","icon":"square-code","pages":[{"title":"Prompt Studio","icon":"message-pen","href":"/prompt-management/prompt-studio"},{"title":"Stress Testing","icon":"gauge-high","iconType":"solid","href":"/prompt-management/stress-testing"}]},{"group":"Monitoring \u0026 Dashboard","icon":"chart-line","pages":[{"title":"Custom Dashboard","icon":"chart-mixed","href":"/Dashboard/Custom-dashboard"},{"title":"Alert Rules","icon":"bell","href":"/Alert-rules/Alert-rules"}]},{"group":"Automations","icon":"bolt","pages":[{"title":"Automations Overview","icon":"bolt","href":"/Automations/overview"},{"title":"Creating Automations","icon":"bolt","href":"/Automations/creating-automations"},{"title":"Destinations","icon":"paper-plane","href":"/Automations/destinations"}]},{"group":"Account settings","icon":"wrench","pages":[{"title":"Organization Settings","icon":"users-gear","href":"/Account-settings/Organisation"},{"title":"Project Settings","icon":"folder-gear","href":"/Account-settings/project"}]},{"group":"Migrations","icon":"truck","pages":[{"title":"Helicone to Netra","icon":"cube","href":"/Migrations/Helicone"},{"title":"Portkey to Netra","icon":"hexagon","href":"/Migrations/Portkey"}]},{"group":"Security","icon":"shield-keyhole","pages":[{"title":"LLM Security \u0026 Guardrails","icon":"shield-check","href":"/llm-security-and-guardrails"}]}]},{"tab":"Integrations","icon":"plug","pages":[{"title":"Integrations","href":"/Integrations/overview"}]},{"tab":"SDK","icon":"code","pages":[{"title":"SDK","href":"/sdk-reference/sdk/overview"}]},{"tab":"MCP","icon":"server","pages":[{"title":"MCP","href":"/mcp/overview"}]},{"tab":"Cookbooks","icon":"graduation-cap","pages":[{"title":"Cookbooks","href":"/Cookbooks/observability/tracing-rag-pipeline"}]},{"tab":"Changelog","icon":"clock-rotate-left","pages":[{"title":"Changelog","href":"/changelog"}]}]},"basePath":"","title":"Users - Netra Docs","deploymentId":"dpl_HhUetB7eHHDAmK9T1Teip38TgFx9","buildId":"dpl_HhUetB7eHHDAmK9T1Teip38TgFx9","dynamics":["a74be98ba7"],"chunks":["zoom-image-lightbox-DQG3o8Eu.js","lightbox-handle-r17bVUz3.js"]}