| title |
ConversationAnalytics |
| description |
ConversationAnalytics Schema Reference |
| category |
ai |
| zodFile |
conversation |
**Source:** `packages/spec/src/ai/conversation.zod.ts`
| Property |
Type |
Required |
Description |
| sessionId |
string |
✅ |
|
| totalMessages |
integer |
✅ |
|
| userMessages |
integer |
✅ |
|
| assistantMessages |
integer |
✅ |
|
| systemMessages |
integer |
✅ |
|
| totalTokens |
integer |
✅ |
|
| averageTokensPerMessage |
number |
✅ |
|
| peakTokenUsage |
integer |
✅ |
|
| pruningEvents |
integer |
optional |
|
| summarizationEvents |
integer |
optional |
|
| tokensSavedByPruning |
integer |
optional |
|
| tokensSavedBySummarization |
integer |
optional |
|
| duration |
number |
optional |
Session duration in seconds |
| firstMessageAt |
string |
optional |
ISO 8601 timestamp |
| lastMessageAt |
string |
optional |
ISO 8601 timestamp |
import { ConversationAnalyticsSchema } from '@objectstack/spec/ai';
import type { ConversationAnalytics } from '@objectstack/spec/ai';
// Validate data
const result = ConversationAnalyticsSchema.parse(data);
// Type-safe usage
const myConversationAnalytics: ConversationAnalytics = {
sessionId: 'example',
totalMessages: null,
userMessages: null,
// ... other required fields
};