When to Use Manual Tracking
Custom Frameworks
Building with a custom agent framework, not LangChain.
Raw OpenAI/Anthropic
Using the OpenAI or Anthropic SDKs directly.
Specific Events
Only want to track certain events, not everything.
Non-Python
Using JavaScript/TypeScript or another language.
Basic Pattern
The simple begin/finish pattern works for most use cases:Full Control Pattern
For more granular tracking, use theSentrialClient directly:
Tracking Tool Calls
Wrap your tool functions to automatically track them:TypeScript Example
Best Practices
Always complete sessions
Always complete sessions
Call
complete_session() or finish() even on errors to ensure data is recorded.Track meaningful events
Track meaningful events
Focus on tool calls and decisions, not every line of code.
Include failure reasons
Include failure reasons
When
success=False, always include failure_reason for better diagnosis.Use consistent agent names
Use consistent agent names
Same
agent_name groups sessions together in the dashboard.Track costs accurately
Track costs accurately
Use the cost calculation helpers or track real token usage.

