Skip to main content
Manual event tracking gives you complete control over what interactions are monitored and how they’re recorded. Use this approach when you need custom tracking logic, are integrating with non-supported LLM providers, or want granular control over the monitoring process.

When to Use Manual Tracking

Choose manual tracking when you need to:
  • Custom Integration: Work with LLM providers not yet supported by automatic wrappers
  • Granular Control: Track specific events or add custom metadata
  • Complex Workflows: Monitor multi-step processes with custom logic
  • Legacy Systems: Integrate with existing agent implementations
  • Custom Events: Track domain-specific events beyond standard LLM interactions

Core Tracking Methods

Conversation Lifecycle

Track the complete lifecycle of agent conversations:

Tool and Function Calls

Track when your agent uses tools or external functions:

Error Tracking

Comprehensive error tracking with context:

Advanced Tracking Patterns

Banking Workflow Example

Here’s a comprehensive example tracking a complete banking interaction:

Custom Event Types

Track domain-specific events using the generic track method:

Metadata and Context

Enhance your tracking with rich metadata:

Performance Metrics

Business Context

Batch Operations and Performance

Efficient Batch Tracking

For high-volume applications, use efficient batching:

Conditional Tracking

Track selectively based on business logic:

Integration Patterns

Express.js Middleware

Create middleware for automatic tracking in web applications:

Custom Agent Wrapper

Create a custom wrapper for your agent class:

Compliance Integration

Manual tracking allows for sophisticated compliance monitoring:

Real-time Compliance Checks

Custom Compliance Rules

Analytics and Reporting

Track custom metrics for business intelligence:

Custom Analytics Events

Session Analytics

Error Handling and Resilience

Implement robust error handling for tracking operations:

Resilient Tracking Wrapper

Performance Optimization

Optimize tracking for high-throughput scenarios:

Debounced Tracking

Best Practices

Troubleshooting

Check that you’re calling monitor.flush() or waiting for the automatic flush interval. Verify your API key and organization ID are correct.
Reduce batch size and flush interval. Implement event sampling for high-volume scenarios. Check for event accumulation without proper flushing.
Ensure you’re passing metadata objects correctly. Check that metadata keys match expected field names. Verify data types are serializable.
Confirm that enableComplianceChecks: true is set. Verify that compliance checks are running on the correct event types (typically agent responses).
Use consistent session IDs across related events. Ensure session IDs are unique per conversation. Check that conversation start events are tracked.

Next Steps

Compliance Engine

Learn about built-in compliance monitoring

Configuration

Advanced configuration options

API Reference

Complete method documentation

LLM Integrations

Automatic monitoring alternatives