All notable changes to the Bilan SDK will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- FIXED: Server mode now actually sends HTTP requests to analytics server (was completely broken in v0.4.1)
- BREAKING: Added required
apiKeyparameter for server mode authentication
apiKeyfield toInitConfiginterface for server mode authentication- HTTP request functionality with Bearer token authentication
- Proper error handling and validation for server mode configuration
- Clear error messages when
apiKeyis missing in server mode
- Bundle Size: Increased from <5KB to 5.26KB gzipped (+268 bytes) to accommodate essential HTTP functionality
- Performance Budget: Raised bundle size limit to 5.5KB for production analytics capability
- Documentation: Comprehensive update across all integration guides and examples
// v0.4.1 (broken - no events sent)
await init({
mode: 'server',
endpoint: 'https://api.com',
userId: 'user-123'
})
// v0.4.2 (working)
await init({
mode: 'server',
endpoint: 'https://api.com',
apiKey: 'your-api-key', // NEW: Required
userId: 'user-123'
})- Replaced no-op
onFlushcallbacks with actualfetch()calls to/api/events - Added private
sendEventsToServer()method to eliminate code duplication - Enhanced validation to require both
endpointandapiKeyfor server mode - Implemented proper HTTP error handling with debug logging
Bilan v0.4.1 eliminates the confusing dual-ID system (turn_id + prompt_id) in favor of clean, industry-standard event correlation that follows proven patterns from Amplitude, Mixpanel, and other major analytics platforms.
trackTurn()Enhancement: Now returns{ result, turnId }instead of just the AI responsevote()Simplification: TakesturnIdparameter instead of manualpromptIdcreation- Automatic Correlation: System handles turn-to-vote relationships without developer intervention
- Industry Alignment: Follows Amplitude/Mixpanel shared identifier patterns
// ❌ BEFORE (v0.4.0) - Confusing dual-ID system
const response = await bilan.trackTurn(prompt, aiCall) // Creates internal turn_id
await bilan.vote(createPromptId('manual'), 1, 'Good') // Developer creates separate prompt_id
// ✅ AFTER (v0.4.1) - Industry-standard event linking
const { result, turnId } = await bilan.trackTurn(prompt, aiCall) // Returns both result + turn_id
await bilan.vote(turnId, 1, 'Good') // Use same turn_id for correlation- Flexible Relationships: Optional context fields for advanced analytics
- Journey Tracking:
journey_idparameter for workflow analysis - Conversation Context:
conversation_idandturn_sequencefor multi-turn analysis - Custom Properties: Extensible context system for application-specific data
// Rich context tracking (all optional)
const { result, turnId } = await bilan.trackTurn(
'Review this code',
() => callAI(prompt),
{
journey_id: 'code-review-workflow',
conversation_id: 'conv_123',
turn_sequence: 2,
customData: { prId: 456, reviewer: 'alice' }
}
)- Analytics Authentication: All
/api/analytics/*endpoints now require Bearer token authentication - Consistent Security Model: Event ingestion and analytics access both secured
- OpenAPI Compliance: Updated specification reflects security requirements
- Enterprise Ready: Meets security standards for production deployments
// trackTurn() return type change
- async trackTurn<T>(prompt: string, aiCall: () => Promise<T>): Promise<T>
+ async trackTurn<T>(prompt: string, aiCall: () => Promise<T>): Promise<{ result: T, turnId: string }>
// vote() parameter change
- async vote(promptId: PromptId, value: 1 | -1, comment?: string): Promise<void>
+ async vote(turnId: string, value: 1 | -1, comment?: string): Promise<void>createPromptId()function - UseturnIdfromtrackTurn()insteadPromptIdtype - UsestringturnId values instead
- New Relationship Fields: Optional
journey_id,conversation_id,turn_sequencecolumns - Vote Event Migration: Existing vote events automatically migrated from
promptIdtoturn_id - Optimized Indexes: Enhanced indexing for relationship queries
// OLD v0.4.0 pattern:
const response = await trackTurn('Help with email', aiCall)
await vote(createPromptId('email-help'), 1, 'Helpful!')
// NEW v0.4.1 pattern:
const { result: response, turnId } = await trackTurn('Help with email', aiCall)
await vote(turnId, 1, 'Helpful!')- Zero-downtime migration of existing vote events
- Automatic
promptId→turn_idfield mapping - Comprehensive validation and rollback support
- No manual intervention required
- Direct linkage between AI interactions and user feedback
- Automatic relationship tracking in database
- Enhanced dashboard insights showing response quality correlation
- Performance analytics linked to user satisfaction metrics
- Journey completion funnel analysis
- Multi-turn conversation success tracking
- Cross-context performance insights
- User behavior pattern analysis with contextual data
GET /api/events- Now requires Bearer tokenGET /api/analytics/overview- Authentication requiredGET /api/analytics/votes- Secured analytics endpointGET /api/analytics/turns- Protected AI performance data
- Security schemas added to all analytics endpoints
- Consistent authentication documentation
- Updated integration examples with API key usage
- 5 minutes faster setup (no manual ID coordination)
- Zero correlation overhead (system handles relationships automatically)
- Industry familiarity (matches Amplitude/Mixpanel patterns)
- Better TypeScript support with cleaner type definitions
// Correlated error tracking with turnId
let turnId: string
try {
const { result, turnId: id } = await trackTurn('Process data', aiCall)
turnId = id
await vote(turnId, 1, 'Success!')
} catch (error) {
if (turnId) {
await vote(turnId, -1, `Failed: ${error.message}`)
}
}- MIGRATION-v0.4.2.md - Critical v0.4.1 → v0.4.2 server mode fix guide
- MIGRATION-v0.4.1.md - Comprehensive v0.4.0 → v0.4.1 upgrade guide
- Step-by-step code transformation examples
- Common migration patterns and solutions
- Validation checklist and troubleshooting
- All AI framework examples updated for turnId system
- Enhanced context tracking examples
- Security integration examples with authentication
- Performance best practices with new correlation features
- Updated OpenAPI specification with security requirements
- New relationship field documentation
- Enhanced analytics endpoint examples
- Migration validation tool documentation
- Optimized Correlation Queries: Direct turn-vote relationships eliminate complex JOINs
- Enhanced Indexing: New indexes for relationship field queries
- Batch Processing: Improved event ingestion with context data
- Cache Optimization: Smart caching for correlated analytics data
- Maintained <5.5KB: Bundle size optimized for essential features
- Type Safety: Enhanced TypeScript definitions
- Backward Compatibility: Graceful migration path preserves existing functionality
- Zero Dependencies: Continued native API approach
- Flexible schema supporting advanced analytics patterns
- Optional relationship fields enable sophisticated queries
- Backward compatible migration preserving all existing data
- Performance optimizations for correlation analysis
- Turn-vote correlation endpoints
- Enhanced security middleware
- Relationship data capture and validation
- Improved error handling and response formats
- Turn-vote correlation visualization (basic implementation)
- Context field display in event tables
- Authentication integration for secure access
- Enhanced filtering with relationship data
The v0.4.1 architecture establishes the foundation for advanced AI analytics features:
- Frustration Detection: Multi-turn conversation analysis capability
- Journey Optimization: Workflow completion analysis infrastructure
- Cross-Context Insights: Relationship data enables sophisticated user behavior analysis
- Advanced Correlation: Schema supports complex event relationship queries
Bilan v0.4.0 completely transforms the AI analytics experience with a flexible, event-driven architecture that captures comprehensive AI interaction data with minimal integration effort. This release focuses on making AI analytics as effortless as adding Google Analytics to a website.
trackTurn()Wrapper: One-line integration that automatically captures success/failure metrics- Automatic Failure Detection: Built-in timeout, rate limit, and error classification (30s threshold)
- Performance Tracking: Response times, token usage, and model performance metrics
- Privacy Controls: Configurable prompt/response capture with
capturePromptsandcaptureResponsesoptions - Content Hashing: PII sanitization and privacy-protected analytics
- Unified Events Table: Single JSONB-based table supporting all event types with flexible properties
- Custom Event Tracking:
track()method for any AI-related event beyond built-in patterns - Schema Evolution: Add new event types without breaking existing analytics
- Database Performance: 10,000x query improvement with proper event filtering and indexing
- Convenience Methods:
startConversation(),vote(),trackJourneyStep(),recordFeedback(),endConversation() - Turn Aggregation: Automatic conversation and journey grouping from individual turn events
- System Prompt Tracking:
systemPromptVersionsupport for A/B testing prompt changes - Type Safety: Enhanced branded types (
TurnId,ConversationId,EventId) for better developer experience
- Real-Time Dashboard: 5 comprehensive analytics pages with live event data
- Enhanced APIs: 8 new analytics endpoints including turn performance and vote correlation
- Turn Analytics: Dedicated AI interaction performance dashboard with error analysis
- Vote Correlation: Link user feedback directly to specific AI interactions
- API Transformation: Conversation-centric API → Event-based API with turn wrapper
- Database Schema: Complete migration to unified events table with JSONB properties
- SDK Interface: New
trackTurn()primary method replaces manual conversation lifecycle
// OLD (v0.3.x) - Manual conversation management
const conversationId = await conversation.start(userId)
await conversation.addMessage(conversationId)
await conversation.recordFeedback(conversationId, 1, 'Good')
// NEW (v0.4.0) - Automatic turn tracking
const response = await trackTurn(
prompt,
() => callAI(prompt),
{ conversationId: 'optional-grouping' }
)
await vote(promptId, 1, 'Good') // Enhanced feedback- Complete Migration Toolkit: Automated v0.3.x → v0.4.0 data transformation
- Zero Data Loss: Preserve all existing conversations, journeys, and votes
- Validation Scripts: Ensure data integrity throughout migration process
- New Endpoints: 8 comprehensive analytics endpoints with batch processing support
- Performance: <20ms P99 response times (tested under load)
- Security: Enhanced API key middleware and rate limiting (100 req/min)
- Error Handling: Structured error responses with actionable error codes
- Complete Rebuild: Event-based dashboard with real-time analytics
- 5 Analytics Pages: Overview, Votes, Conversations, Journeys, and new Turns analytics
- Enhanced Visualizations: Daily/hourly trends, sentiment analysis, user behavior indicators
- Turn Performance: Dedicated AI interaction analysis with error categorization
- Unified Schema: Single events table replacing separate conversations/votes/journeys tables
- JSONB Properties: Flexible event properties without schema changes
- Optimized Queries: Proper indexing and filtering for production performance
- Migration Scripts: Complete database transformation with rollback capability
- 219 Total Tests: SDK (156), Server (7), Integration (52), E2E (4)
- 100% Pass Rate: All tests passing with comprehensive coverage
- Integration Testing: Complete SDK → API → Database flow validation
- Performance Testing: Load testing with production-realistic scenarios
- Bundle Size: Maintained <5.5KB gzipped for SDK
- TypeScript: Full strict mode compliance with comprehensive type coverage
- Error Handling: Graceful degradation and comprehensive error recovery
- Documentation: Complete API documentation and integration guides
- 5-Minute Integration: From npm install to first analytics data
- One-Line Tracking: Wrap any AI call with
trackTurn()for instant insights - Zero Configuration: Sensible defaults with progressive enhancement
- Privacy-First: Default privacy controls with opt-in data capture
- Complete Visibility: Success rates, failure modes, performance metrics, user behavior
- Automatic Correlation: Link turns, votes, conversations, and journeys seamlessly
- Custom Events: Track any AI-related interaction beyond built-in patterns
- Real-Time Insights: Live dashboard with comprehensive trend analysis
- Performance: <20ms API response times, <3s dashboard loads
- Reliability: Comprehensive error handling and graceful degradation
- Security: Enterprise-grade input validation and rate limiting
- Observability: Complete monitoring and alerting capabilities
- Updated README: Showcases v0.4.0 event-based architecture and trackTurn patterns
- Migration Guide: Comprehensive v0.3.x → v0.4.0 transition documentation
- API Documentation: Updated OpenAPI spec with all 8 new analytics endpoints
- Integration Guides: Updated all 6 AI framework integrations (OpenAI, Anthropic, LangChain, etc.)
This release establishes Bilan as a comprehensive AI analytics platform following industry best practices while maintaining the simplicity and privacy focus that makes it unique. v0.4.0 provides the foundation for advanced features like real-time routing, enterprise integrations, and advanced AI optimization tools.
- Conversation Tracking SDK: Complete conversation lifecycle management
conversation.start()- Start new conversation sessionsconversation.addMessage()- Track messages in conversationsconversation.recordFrustration()- Record user frustration eventsconversation.recordRegeneration()- Track AI response regenerationsconversation.recordFeedback()- Capture explicit user feedbackconversation.end()- End conversations with success/failure outcomes- ConversationId branded type for type safety
- Journey Analytics SDK: User workflow completion tracking
journey.trackStep()- Record progress through predefined journey stepsjourney.complete()- Mark journey completion- Journey funnel analysis with step-by-step completion rates
- Drop-off point identification for workflow optimization
- Enhanced Analytics API: Comprehensive metrics beyond simple votes
getStats()returns conversation success rates, journey completion rates, and quality signalsgetConversationStats()for detailed conversation analyticsgetJourneyStats()for journey-specific metrics- Trust score calculation incorporating conversation and journey data
- Database Schema Extensions: Support for conversation and journey tracking
conversationstable with session management and outcome trackingfeedback_eventstable for quality signals and user feedbackjourney_stepstable for workflow step tracking- Optimized indexes for analytics queries
- API Endpoints: Server-side conversation and journey tracking
POST /api/conversations- Start conversation sessionsPUT /api/conversations/:id/end- End conversations with outcomesPOST /api/conversations/:id/feedback- Record feedback eventsPOST /api/journeys/step- Track journey step completionGET /api/dashboard- Comprehensive analytics data endpoint
- Analytics Dashboard: Visualize conversation and journey analytics
- Conversation success rate tracking with trend analysis
- Journey completion funnel visualization
- Quality signals monitoring (frustration, regeneration, feedback)
- Recent activity feed with conversation details
- Time-series trust score visualization
- Docker Deployment Support: Production-ready containerization
- Multi-stage Dockerfile with production optimizations
- Docker Compose configuration with PostgreSQL support
- Health check endpoints for container orchestration
- Environment configuration with secure defaults
- Database migration scripts for PostgreSQL and SQLite
- Comprehensive Test Suite: End-to-end testing and performance benchmarks
- E2E tests covering complete conversation and journey workflows
- Performance benchmarks for SDK, API, and dashboard components
- Deployment verification tests for production readiness
- Load testing with concurrent user simulation
- Script Robustness: Improved deployment and validation scripts
- Fixed check_command return codes for proper dependency detection
- Enhanced Docker Compose fallback logic
- Added defensive parameter expansion for unset variables
- Improved PostgreSQL configuration flexibility
- Better error aggregation and reporting
- Environment Validation: Enhanced configuration validation
- Added missing validate_database_connection function
- Fixed environment variable inconsistencies
- Removed directory creation side effects from validation
- Better error messages for missing dependencies
- Database Schema: Optimized schema for analytics workloads
- Improved indexing for time-series queries
- Enhanced conversation tracking with journey support
- Better data retention and archival policies
- API Performance: Optimized API response times
- Caching layer for frequently accessed data
- Database query optimization
- Reduced payload sizes for dashboard data
- Security Enhancements: Strengthened security posture
- Input validation and sanitization
- Secure headers configuration
- Authentication token validation
- Rate limiting implementation
- Enhanced Telemetry System: Optional telemetry for SDK improvement with privacy-first design
- User IDs and prompt IDs are hashed before transmission
- Automatic disable in development mode
- Configurable endpoints for self-hosted analytics
- Queue management with size limits (max 100 events)
- Offline/online event handling for reliable data transmission
- Comprehensive Error Handling: Structured error system with developer-friendly messages
BilanInitializationErrorfor SDK setup issuesBilanVoteErrorfor vote recording problemsBilanStatsErrorfor analytics retrieval issuesBilanNetworkErrorfor network connectivity problemsBilanStorageErrorfor storage operation failures- Graceful degradation in production mode
- Debug mode with detailed error reporting
- Full JSDoc Documentation: Complete API documentation with examples
- Testing Improvements: Enhanced test coverage with proper encapsulation
- 100% coverage for error handling module
- Meaningful test assertions for queue limits and hash consistency
- Proper mocking and state management utilities
- Improved Bundle Size: Optimized to 1.7KB gzipped (was 2.1KB)
- Better Type Safety: Enhanced TypeScript definitions with branded types
- Performance Optimizations: Reduced memory usage and improved initialization time
- Memory Management: Fixed potential memory leaks in event queuing
- Race Conditions: Resolved timing issues in telemetry initialization
- Error Handling: Improved error recovery and fallback mechanisms
- Hash-based Privacy: All user identifiers are hashed before any transmission
- No Sensitive Data: Vote content and personal information never leave the client
- Secure Defaults: Telemetry disabled by default in local mode
- Fixed bundle size calculation in CI
- Improved error messages for common setup issues
- Fixed TypeScript definitions for better IDE support
- Branded Types: Added
UserIdandPromptIdbranded types for better type safety - Helper Functions: Added
createUserId()andcreatePromptId()utilities - Advanced Trend Analysis: Time-weighted trend detection with configurable parameters
- Custom Storage Adapters: Support for custom storage implementations
- Server Mode: Support for self-hosted Bilan API servers
- Breaking:
init()now requires branded types (backward compatibility maintained) - Improved Analytics: More sophisticated trend calculation algorithm
- Better Performance: Reduced initialization time by 40%
- String-based user IDs and prompt IDs (still supported but deprecated)
- Initial Release: Core SDK functionality
- Local Storage Mode: Browser-based analytics storage
- Basic Analytics: Vote tracking and positive rate calculation
- TypeScript Support: Full TypeScript definitions
- Zero Dependencies: Lightweight implementation using native APIs
- Vote recording with thumbs up/down
- Basic statistics (total votes, positive rate)
- Simple trend detection
- Local storage persistence
- Error handling with graceful degradation
No breaking changes. New conversation and journey tracking features are opt-in:
// Before (0.2.x) - Simple vote tracking
await init({ mode: 'local', userId: createUserId('user-123') })
await vote(createPromptId('prompt-abc'), 1, 'Helpful!')
const stats = await getStats()
console.log(`Trust score: ${stats.positiveRate}`)
// After (0.3.1) - Full conversation and journey tracking
await init({ mode: 'local', userId: createUserId('user-123') })
// Track complete conversations
const conversationId = await conversation.start(createUserId('user-123'))
await conversation.addMessage(conversationId)
await conversation.recordFeedback(conversationId, 1, 'Great response!')
await conversation.end(conversationId, 'completed')
// Track user journeys
await journey.trackStep('email-workflow', 'draft-created', createUserId('user-123'))
await journey.complete('email-workflow', createUserId('user-123'))
// Get comprehensive analytics
const stats = await getStats()
console.log(`Conversation success rate: ${stats.conversationSuccessRate}`)
console.log(`Journey completion rate: ${stats.journeyCompletionRate}`)
console.log(`Trust score: ${stats.trustScore}`)
// Original vote methods still work
await vote(createPromptId('prompt-abc'), 1, 'Helpful!')Recommended to use branded types:
// Before (0.1.x)
await init({ mode: 'local', userId: 'user-123' })
await vote('prompt-abc', 1)
// After (0.2.0) - recommended
await init({ mode: 'local', userId: createUserId('user-123') })
await vote(createPromptId('prompt-abc'), 1)
// Backward compatibility maintained
await vote('prompt-abc', 1) // Still works!- Real-time Analytics: WebSocket support for live updates
- Advanced Filtering: Filter analytics by time range, user segments
- Export Functionality: Export analytics data in various formats
- Webhooks: Real-time notifications for significant events
- Machine Learning: Sentiment analysis for comment feedback
- A/B Testing: Built-in A/B testing framework for AI suggestions
- Multi-language Support: Internationalization for error messages
- Plugin System: Extensible plugin architecture