{"_id":"@bernierllc/chat-analytics","_rev":"7-f4ce24b2e6bf639771a9ce9f05b1aa04","name":"@bernierllc/chat-analytics","dist-tags":{"latest":"1.6.0"},"versions":{"1.0.0":{"name":"@bernierllc/chat-analytics","version":"1.0.0","keywords":["chat","analytics","ml","insights","performance","metrics"],"author":{"name":"Bernier LLC"},"license":"UNLICENSED","_id":"@bernierllc/chat-analytics@1.0.0","maintainers":[{"name":"alikhan410","email":"mczeyo@gmail.com"},{"name":"mkbernier","email":"mkbernier@gmail.com"}],"dist":{"shasum":"05217de347f5ce635f9ee283ecf646ac245951a1","tarball":"https://registry.npmjs.org/@bernierllc/chat-analytics/-/chat-analytics-1.0.0.tgz","fileCount":95,"integrity":"sha512-B1/BGK5kE8Pt1F0ckSoiHZoVhJ8rt19mkc8j6C/n2Sqi3mJi3xmbCILgrGaYhi1WjONZHBR8Cv/Q10XVLSEu/Q==","signatures":[{"sig":"MEUCIQD2aWqgARNxl044Dbldr54oqUGQkpHcMckAsVDmnwBMmgIgOLE7y6mTOoxaT8PKUzlJ0GK4W1t9Kdeq9qwOSr5ckHY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":286947},"main":"dist/index.js","_from":"file:bernierllc-chat-analytics-1.0.0.tgz","types":"dist/index.d.ts","scripts":{"lint":"eslint src --ext .ts","test":"jest --watch","build":"tsc","clean":"rm -rf dist","test:run":"jest","test:coverage":"jest --coverage"},"_npmUser":{"name":"mkbernier","email":"mkbernier@gmail.com"},"_resolved":"/tmp/bc40253a07aa41a878d44672e1825240/bernierllc-chat-analytics-1.0.0.tgz","_integrity":"sha512-B1/BGK5kE8Pt1F0ckSoiHZoVhJ8rt19mkc8j6C/n2Sqi3mJi3xmbCILgrGaYhi1WjONZHBR8Cv/Q10XVLSEu/Q==","bernierllc":{"integration":{"neverhub":"optional"}},"_npmVersion":"11.7.0","description":"ML-powered chat analytics and insights for performance optimization","directories":{},"_nodeVersion":"20.19.6","dependencies":{"zod":"^3.22.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.5.0","eslint":"^8.0.0","ts-jest":"^29.1.0","typescript":"^5.0.0","@types/jest":"^29.5.0","@types/node":"^20.0.0","@typescript-eslint/parser":"^6.0.0","@typescript-eslint/eslint-plugin":"^6.0.0"},"_npmOperationalInternal":{"tmp":"tmp/chat-analytics_1.0.0_1766087433143_0.7345008031573541","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@bernierllc/chat-analytics","version":"1.2.0","keywords":["chat","analytics","ml","insights","performance","metrics"],"author":{"name":"Bernier LLC"},"license":"UNLICENSED","_id":"@bernierllc/chat-analytics@1.2.0","maintainers":[{"name":"alikhan410","email":"mczeyo@gmail.com"},{"name":"mkbernier","email":"mkbernier@gmail.com"}],"dist":{"shasum":"24f18af5aee43f5fd6adeda59ef4d12f1e791f33","tarball":"https://registry.npmjs.org/@bernierllc/chat-analytics/-/chat-analytics-1.2.0.tgz","fileCount":96,"integrity":"sha512-moq1JIrEJqhZg6SpcOlH2xNzl7lKsmF4Dy4SVVNUaxC3F41Lf1D1ipN4ZfxhxOk3KP0A9h9JhEqzHaBi5CmnkQ==","signatures":[{"sig":"MEYCIQDUY/g7L1bqKvLt4JgOFwdyIkocjX8LKN7AKk0RvY5w/AIhANZEXO5FtZ2DH2NuyLTsA8NuG63uRLa5q4bPEpaxwAOd","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":288660},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"af7e74b3715d56d3a193e1bb6743b337c2b0df6d","scripts":{"lint":"eslint src --ext .ts","test":"jest --watch","build":"tsc","clean":"rm -rf dist","test:run":"jest","test:coverage":"jest --coverage"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:f832e75b-bafc-463f-9cda-a89ce1c1dddf"}},"bernierllc":{"integration":{"neverhub":"optional"}},"_npmVersion":"lerna/9.0.3/node@v20.19.6+x64 (linux)","description":"ML-powered chat analytics and insights for performance optimization","directories":{},"_nodeVersion":"20.19.6","dependencies":{"zod":"^3.22.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.5.0","eslint":"^8.0.0","ts-jest":"^29.1.0","typescript":"^5.0.0","@types/jest":"^29.5.0","@types/node":"^20.0.0","@typescript-eslint/parser":"^6.0.0","@typescript-eslint/eslint-plugin":"^6.0.0"},"_npmOperationalInternal":{"tmp":"tmp/chat-analytics_1.2.0_1767642286554_0.9370488024843941","host":"s3://npm-registry-packages-npm-production"}},"1.2.1":{"name":"@bernierllc/chat-analytics","version":"1.2.1","keywords":["chat","analytics","ml","insights","performance","metrics"],"author":{"name":"Bernier LLC"},"license":"UNLICENSED","_id":"@bernierllc/chat-analytics@1.2.1","maintainers":[{"name":"alikhan410","email":"mczeyo@gmail.com"},{"name":"mkbernier","email":"mkbernier@gmail.com"}],"dist":{"shasum":"a3be6ba9afb94472c00e680375658fca155a5ab7","tarball":"https://registry.npmjs.org/@bernierllc/chat-analytics/-/chat-analytics-1.2.1.tgz","fileCount":96,"integrity":"sha512-MamhZfIs9dgn0kb7BHrkOdLrAFjT9D9Xbtw5uj1yX5ZLn/YDiIw4n8wNUqw4hppzLfWXFyFuu0MPEK+LG7H7Fg==","signatures":[{"sig":"MEUCIGB/Ge3tcY5ai8FYyjSV70G8UFJJY2tJOEc+9lxgClbHAiEAqMlact5iHJOMxJCxxVqFMPeykXayHcEx4LZt1pmBBrM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":288812},"main":"dist/index.js","_from":"file:bernierllc-chat-analytics-1.2.1.tgz","types":"dist/index.d.ts","scripts":{"lint":"eslint src --ext .ts","test":"jest --watch","build":"tsc","clean":"rm -rf dist","test:run":"jest","test:coverage":"jest --coverage"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:f832e75b-bafc-463f-9cda-a89ce1c1dddf"}},"_resolved":"/tmp/b4757c78a577f9fe0316edaf189c2c9c/bernierllc-chat-analytics-1.2.1.tgz","_integrity":"sha512-MamhZfIs9dgn0kb7BHrkOdLrAFjT9D9Xbtw5uj1yX5ZLn/YDiIw4n8wNUqw4hppzLfWXFyFuu0MPEK+LG7H7Fg==","bernierllc":{"integration":{"neverhub":"optional"}},"_npmVersion":"11.11.0","description":"ML-powered chat analytics and insights for performance optimization","directories":{},"_nodeVersion":"20.20.0","dependencies":{"zod":"^3.22.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.5.0","eslint":"^8.0.0","ts-jest":"^29.1.0","typescript":"^5.0.0","@types/jest":"^29.5.0","@types/node":"^20.0.0","@typescript-eslint/parser":"^6.0.0","@typescript-eslint/eslint-plugin":"^6.0.0"},"_npmOperationalInternal":{"tmp":"tmp/chat-analytics_1.2.1_1773077972662_0.4686078978329187","host":"s3://npm-registry-packages-npm-production"}},"1.2.2":{"name":"@bernierllc/chat-analytics","version":"1.2.2","keywords":["chat","analytics","ml","insights","performance","metrics"],"author":{"name":"Bernier LLC"},"license":"UNLICENSED","_id":"@bernierllc/chat-analytics@1.2.2","maintainers":[{"name":"alikhan410","email":"mczeyo@gmail.com"},{"name":"mkbernier","email":"mkbernier@gmail.com"}],"dist":{"shasum":"a0aef6dcafe9c91f89abdbdbea5d651cfa716594","tarball":"https://registry.npmjs.org/@bernierllc/chat-analytics/-/chat-analytics-1.2.2.tgz","fileCount":96,"integrity":"sha512-No5jAkcHZBpNqcfcedC9jxH0SD5tT29880NJiR6FIB88WTtoUKkxTxSK9mYebL3F+l07Bg+jGjSV72MBJaLJ+w==","signatures":[{"sig":"MEYCIQCsDKFOTFM5xjFDKH7ZSjxhtYgwkWSxae2+nh8QNjok6QIhAJ8Tf1p/q9OhJU5NhVxIKoeBTioNDG3IGP2hVr1PTZLI","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":289022},"main":"dist/index.js","_from":"file:bernierllc-chat-analytics-1.2.2.tgz","types":"dist/index.d.ts","scripts":{"lint":"eslint src --ext .ts","test":"jest --watch","build":"tsc","clean":"rm -rf dist","test:run":"jest","test:coverage":"jest --coverage"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:f832e75b-bafc-463f-9cda-a89ce1c1dddf"}},"_resolved":"/tmp/c9d2d97a08e3fe0fb4cee4efd9a5c92a/bernierllc-chat-analytics-1.2.2.tgz","_integrity":"sha512-No5jAkcHZBpNqcfcedC9jxH0SD5tT29880NJiR6FIB88WTtoUKkxTxSK9mYebL3F+l07Bg+jGjSV72MBJaLJ+w==","bernierllc":{"integration":{"neverhub":"optional"}},"_npmVersion":"11.11.0","description":"ML-powered chat analytics and insights for performance optimization","directories":{},"_nodeVersion":"20.20.0","dependencies":{"zod":"^3.22.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.5.0","eslint":"^8.0.0","ts-jest":"^29.1.0","typescript":"^5.0.0","@types/jest":"^29.5.0","@types/node":"^20.0.0","@typescript-eslint/parser":"^6.0.0","@typescript-eslint/eslint-plugin":"^6.0.0"},"_npmOperationalInternal":{"tmp":"tmp/chat-analytics_1.2.2_1773081126408_0.25055537515270276","host":"s3://npm-registry-packages-npm-production"}},"1.4.0":{"name":"@bernierllc/chat-analytics","version":"1.4.0","keywords":["chat","analytics","ml","insights","performance","metrics"],"author":{"name":"Bernier LLC"},"license":"UNLICENSED","_id":"@bernierllc/chat-analytics@1.4.0","maintainers":[{"name":"alikhan410","email":"mczeyo@gmail.com"},{"name":"mkbernier","email":"mkbernier@gmail.com"}],"dist":{"shasum":"331cf44172a4031b6086b9e510b15c076efe5d57","tarball":"https://registry.npmjs.org/@bernierllc/chat-analytics/-/chat-analytics-1.4.0.tgz","fileCount":60,"integrity":"sha512-wU1EoI6CmBxrRJ+4RGnFrvqlmDqR35dBYP7gkRSvSjrctPTwHLPANadgGhFI1NUVuZhjiUTOAjC3vwXGbNhi8w==","signatures":[{"sig":"MEYCIQCfgWEWYeDpzgz7lBfFeEir32aL/yl2WezIIr9bhJCVeQIhANmC649ELoA+64lAOHsof5jnoHHqCeMIzGYrDVOdc65P","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":151730},"main":"dist/index.js","_from":"file:bernierllc-chat-analytics-1.4.0.tgz","types":"dist/index.d.ts","scripts":{"lint":"eslint src --ext .ts","test":"jest --watch","build":"tsc","clean":"rm -rf dist","test:run":"jest","test:coverage":"jest --coverage"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:f832e75b-bafc-463f-9cda-a89ce1c1dddf"}},"_resolved":"/home/runner/work/tools/tools/packages/core/chat-analytics/bernierllc-chat-analytics-1.4.0.tgz","_integrity":"sha512-wU1EoI6CmBxrRJ+4RGnFrvqlmDqR35dBYP7gkRSvSjrctPTwHLPANadgGhFI1NUVuZhjiUTOAjC3vwXGbNhi8w==","bernierllc":{"integration":{"neverhub":"optional"}},"_npmVersion":"11.14.1","description":"ML-powered chat analytics and insights for performance optimization","directories":{},"_nodeVersion":"20.20.2","dependencies":{"zod":"^3.22.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.5.0","eslint":"^8.0.0","ts-jest":"^29.1.0","typescript":"^5.0.0","@types/jest":"^29.5.0","@types/node":"^20.0.0","@typescript-eslint/parser":"^6.0.0","@typescript-eslint/eslint-plugin":"^6.0.0"},"_npmOperationalInternal":{"tmp":"tmp/chat-analytics_1.4.0_1779233839300_0.35094282295165047","host":"s3://npm-registry-packages-npm-production"}},"1.5.0":{"name":"@bernierllc/chat-analytics","version":"1.5.0","keywords":["chat","analytics","ml","insights","performance","metrics"],"author":{"name":"Bernier LLC"},"license":"UNLICENSED","_id":"@bernierllc/chat-analytics@1.5.0","maintainers":[{"name":"alikhan410","email":"mczeyo@gmail.com"},{"name":"mkbernier","email":"mkbernier@gmail.com"}],"dist":{"shasum":"0d9f8bdfc3968d1957b7004141f16a2261c35a4d","tarball":"https://registry.npmjs.org/@bernierllc/chat-analytics/-/chat-analytics-1.5.0.tgz","fileCount":60,"integrity":"sha512-TsPbD6HObZBR2ccdRZwGDLUlDpALjcfr0P9BJ8RBh6aouF60xJsP//8Xm6TVlyezhN+Y54rJugZDhCo4x9FPow==","signatures":[{"sig":"MEQCIAOCajLkl/u0w7wLDQbOVw4qifyb2S5GwKiizEDvTi9NAiAfmXLEKV1gpwhIWJ6rd6fdb2p4WFdyHI2kjKpI6cuPSA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":151730},"main":"dist/index.js","_from":"file:bernierllc-chat-analytics-1.5.0.tgz","types":"dist/index.d.ts","scripts":{"lint":"eslint src --ext .ts","test":"jest --watch","build":"tsc","clean":"rm -rf dist","test:run":"jest","test:coverage":"jest --coverage"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:f832e75b-bafc-463f-9cda-a89ce1c1dddf"}},"_resolved":"/home/runner/work/tools/tools/packages/core/chat-analytics/bernierllc-chat-analytics-1.5.0.tgz","_integrity":"sha512-TsPbD6HObZBR2ccdRZwGDLUlDpALjcfr0P9BJ8RBh6aouF60xJsP//8Xm6TVlyezhN+Y54rJugZDhCo4x9FPow==","bernierllc":{"integration":{"neverhub":"optional"}},"_npmVersion":"11.14.1","description":"ML-powered chat analytics and insights for performance optimization","directories":{},"_nodeVersion":"20.20.2","dependencies":{"zod":"^3.22.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.5.0","eslint":"^8.0.0","ts-jest":"^29.1.0","typescript":"^5.0.0","@types/jest":"^29.5.0","@types/node":"^20.0.0","@typescript-eslint/parser":"^6.0.0","@typescript-eslint/eslint-plugin":"^6.0.0"},"_npmOperationalInternal":{"tmp":"tmp/chat-analytics_1.5.0_1779240948189_0.11420809500527818","host":"s3://npm-registry-packages-npm-production"}},"1.6.0":{"name":"@bernierllc/chat-analytics","version":"1.6.0","description":"ML-powered chat analytics and insights for performance optimization","main":"dist/index.js","types":"dist/index.d.ts","keywords":["chat","analytics","ml","insights","performance","metrics"],"author":{"name":"Bernier LLC"},"license":"UNLICENSED","dependencies":{"zod":"^3.22.0"},"devDependencies":{"@types/jest":"^29.5.0","@types/node":"^20.0.0","@typescript-eslint/eslint-plugin":"^6.0.0","@typescript-eslint/parser":"^6.0.0","eslint":"^8.0.0","jest":"^29.5.0","ts-jest":"^29.1.0","typescript":"^5.0.0"},"bernierllc":{"integration":{"neverhub":"optional"}},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"scripts":{"build":"tsc","test":"jest --watch","test:run":"jest","test:coverage":"jest --coverage","lint":"eslint src --ext .ts","clean":"rm -rf dist"},"_id":"@bernierllc/chat-analytics@1.6.0","_integrity":"sha512-zPZw+4DTLpvRKCXt73ZCkkf/EUC6jh1mLR4jr4HgErYv7NQEpH5I3BWkIdmdICm0Ao492gGClOeOUVl9+2tmxQ==","_resolved":"/home/runner/work/tools/tools/packages/core/chat-analytics/bernierllc-chat-analytics-1.6.0.tgz","_from":"file:bernierllc-chat-analytics-1.6.0.tgz","_nodeVersion":"20.20.2","_npmVersion":"11.14.1","dist":{"integrity":"sha512-zPZw+4DTLpvRKCXt73ZCkkf/EUC6jh1mLR4jr4HgErYv7NQEpH5I3BWkIdmdICm0Ao492gGClOeOUVl9+2tmxQ==","shasum":"e671412190b4311475dfc9d4e86fefb0939d4299","tarball":"https://registry.npmjs.org/@bernierllc/chat-analytics/-/chat-analytics-1.6.0.tgz","fileCount":60,"unpackedSize":151730,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIDH3DgRsDlCUhQjAYUCUFXqBVwQyBaUp1eYBMMluxKHQAiEAgBPPKCM586Prvl/skTUjcGWRsvblm7RZJFnu7yN+YHE="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:f832e75b-bafc-463f-9cda-a89ce1c1dddf"}},"directories":{},"maintainers":[{"name":"alikhan410","email":"mczeyo@gmail.com"},{"name":"mkbernier","email":"mkbernier@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/chat-analytics_1.6.0_1779249682880_0.6539071710773272"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-18T19:50:33.040Z","modified":"2026-05-20T04:01:23.215Z","1.0.0":"2025-12-18T19:50:33.299Z","1.2.0":"2026-01-05T19:44:46.707Z","1.2.1":"2026-03-09T17:39:32.803Z","1.2.2":"2026-03-09T18:32:06.549Z","1.4.0":"2026-05-19T23:37:19.438Z","1.5.0":"2026-05-20T01:35:48.328Z","1.6.0":"2026-05-20T04:01:23.037Z"},"author":{"name":"Bernier LLC"},"license":"UNLICENSED","keywords":["chat","analytics","ml","insights","performance","metrics"],"description":"ML-powered chat analytics and insights for performance optimization","maintainers":[{"name":"alikhan410","email":"mczeyo@gmail.com"},{"name":"mkbernier","email":"mkbernier@gmail.com"}],"readme":"# @bernierllc/chat-analytics\n\nML-powered chat analytics and insights for performance optimization and user behavior analysis.\n\n## Installation\n\n```bash\nnpm install @bernierllc/chat-analytics\n```\n\n## Features\n\n- **Metrics Collection** - Message, user, performance, intent, and provider metrics\n- **ML-Powered Analysis** - User behavior, performance optimization, sentiment analysis\n- **Insight Generation** - Automated actionable insights with confidence scoring\n- **Alert Management** - Smart alerting based on thresholds and trends\n- **Report Generation** - Comprehensive reports in JSON, CSV, HTML, and PDF formats\n- **NeverHub Integration** - Optional service discovery and event integration\n- **Real-time Analytics** - Live metrics collection and processing\n- **Trend Analysis** - Time-series analysis and forecasting\n- **Data Aggregation** - Multi-level aggregation (minute, hour, day, week, month)\n\n## Quick Start\n\n```typescript\nimport { ChatAnalytics } from '@bernierllc/chat-analytics';\n\n// Initialize analytics\nconst analytics = new ChatAnalytics({\n  enabled: true,\n  metrics: {\n    collectionInterval: 60000, // 1 minute\n    retentionPeriod: 90 // 90 days\n  }\n});\n\nawait analytics.initialize();\n\n// Collect metrics\nanalytics.collectMessageMetric({\n  timestamp: new Date(),\n  messageId: 'msg-001',\n  userId: 'user-123',\n  volume: 1,\n  responseTime: 150,\n  success: true\n});\n\n// Generate insights\nconst insights = analytics.generateInsights();\nconsole.log('Generated insights:', insights.data);\n\n// Create report\nconst report = analytics.generateReport({ format: 'json' });\nconsole.log('Report:', report.data);\n\n// Cleanup\nawait analytics.shutdown();\n```\n\n## Usage Examples\n\n### Collecting Different Metric Types\n\n```typescript\n// Message metrics\nanalytics.collectMessageMetric({\n  timestamp: new Date(),\n  messageId: 'msg-001',\n  userId: 'user-123',\n  volume: 1,\n  responseTime: 150,\n  success: true,\n  metadata: { provider: 'openai', model: 'gpt-4' }\n});\n\n// User metrics\nanalytics.collectUserMetric({\n  timestamp: new Date(),\n  userId: 'user-123',\n  sessionId: 'session-001',\n  activity: 'chat',\n  duration: 5000,\n  engagementScore: 0.85\n});\n\n// Performance metrics\nanalytics.collectPerformanceMetric({\n  timestamp: new Date(),\n  operation: 'chat-completion',\n  duration: 250,\n  success: true,\n  resourceUsage: {\n    cpu: 45.2,\n    memory: 128\n  }\n});\n\n// Intent metrics\nanalytics.collectIntentMetric({\n  timestamp: new Date(),\n  messageId: 'msg-001',\n  intent: 'task-creation',\n  confidence: 0.92,\n  routedTo: 'task-handler',\n  success: true\n});\n\n// Provider metrics\nanalytics.collectProviderMetric({\n  timestamp: new Date(),\n  provider: 'openai',\n  operation: 'chat-completion',\n  duration: 180,\n  success: true\n});\n```\n\n### Analyzing User Behavior\n\n```typescript\nconst userAnalysis = analytics.analyzeUserBehavior('user-123', {\n  start: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000), // Last 7 days\n  end: new Date()\n});\n\nif (userAnalysis.success) {\n  const analysis = userAnalysis.data;\n  console.log('Peak usage times:', analysis.patterns.peakUsageTimes);\n  console.log('Preferred features:', analysis.patterns.preferredFeatures);\n  console.log('Engagement level:', analysis.patterns.engagementLevel);\n  console.log('Satisfaction score:', analysis.patterns.satisfactionScore);\n  console.log('Insights:', analysis.insights);\n  console.log('Recommendations:', analysis.recommendations);\n}\n```\n\n### Performance Analysis\n\n```typescript\nconst perfAnalysis = analytics.analyzePerformance({\n  start: new Date(Date.now() - 24 * 60 * 60 * 1000), // Last 24 hours\n  end: new Date()\n});\n\nif (perfAnalysis.success) {\n  const { analysis } = perfAnalysis.data;\n  console.log('Avg Response Time:', analysis.responseTime.avg, 'ms');\n  console.log('Response Time Trend:', analysis.responseTime.trend);\n  console.log('Error Rate:', (analysis.errorRate.current * 100).toFixed(2), '%');\n  console.log('Bottlenecks:', analysis.bottlenecks);\n  console.log('Recommendations:', perfAnalysis.data.recommendations);\n}\n```\n\n### Intent Analysis\n\n```typescript\nconst intentAnalysis = analytics.analyzeIntents();\n\nif (intentAnalysis.success) {\n  const { distribution, accuracy, topIntents } = intentAnalysis.data;\n  console.log('Intent Distribution:', distribution);\n  console.log('Overall Accuracy:', (accuracy * 100).toFixed(2), '%');\n  console.log('Top Intents:', topIntents);\n}\n```\n\n### Trend Analysis and Forecasting\n\n```typescript\nconst trendAnalysis = analytics.analyzeTrends(7); // Predict next 7 periods\n\nif (trendAnalysis.success) {\n  const { trends, predictions, insights } = trendAnalysis.data;\n  console.log('Trends:', trends);\n  console.log('Predictions:', predictions);\n  console.log('Insights:', insights);\n}\n```\n\n### Working with Insights and Alerts\n\n```typescript\n// Generate insights\nconst insights = analytics.generateInsights();\n\nif (insights.success) {\n  for (const insight of insights.data) {\n    console.log(`[${insight.priority}] ${insight.title}`);\n    console.log(`  ${insight.description}`);\n    console.log(`  Confidence: ${(insight.confidence * 100).toFixed(0)}%`);\n\n    if (insight.recommendations) {\n      console.log('  Recommendations:');\n      insight.recommendations.forEach(rec => console.log(`    - ${rec}`));\n    }\n  }\n}\n\n// Check active alerts\nconst alerts = analytics.getActiveAlerts();\nconsole.log(`Active alerts: ${alerts.length}`);\n\nfor (const alert of alerts) {\n  console.log(`Alert: ${alert.insight.title}`);\n\n  // Acknowledge alert\n  analytics.acknowledgeAlert(alert.id);\n}\n```\n\n### Generating Reports\n\n```typescript\n// JSON report\nconst jsonReport = analytics.generateReport({\n  format: 'json',\n  includeCharts: false,\n  maxInsights: 10\n});\n\n// CSV report\nconst csvReport = analytics.generateReport({\n  format: 'csv'\n});\n\n// Export report\nif (jsonReport.success && jsonReport.data) {\n  const exported = analytics.exportReport(jsonReport.data);\n  console.log('Exported report:', exported.data);\n}\n```\n\n## Configuration\n\n### Basic Configuration\n\n```typescript\nconst analytics = new ChatAnalytics({\n  enabled: true,\n\n  metrics: {\n    collectionInterval: 60000, // 1 minute\n    retentionPeriod: 90, // 90 days\n    aggregationLevels: ['minute', 'hour', 'day', 'week', 'month'],\n    metrics: {\n      messageVolume: { enabled: true, priority: 'high' },\n      responseTime: { enabled: true, priority: 'high' },\n      userEngagement: { enabled: true, priority: 'medium' },\n      errorRate: { enabled: true, priority: 'high' },\n      intentAccuracy: { enabled: true, priority: 'medium' }\n    }\n  },\n\n  insights: {\n    enabled: true,\n    generationInterval: 300000, // 5 minutes\n    alertThresholds: {\n      errorRate: 0.05,      // 5%\n      responseTime: 2000,   // 2 seconds\n      userSatisfaction: 0.7 // 70%\n    }\n  }\n});\n```\n\n### ML Configuration\n\n```typescript\nconst analytics = new ChatAnalytics({\n  ml: {\n    enabled: true,\n    models: {\n      userBehavior: { enabled: true, retrainInterval: 86400000 }, // 24 hours\n      performance: { enabled: true, retrainInterval: 3600000 },   // 1 hour\n      sentiment: { enabled: true, retrainInterval: 43200000 },    // 12 hours\n      trends: { enabled: true, retrainInterval: 86400000 }        // 24 hours\n    },\n    features: [\n      'message_length',\n      'response_time',\n      'user_activity',\n      'time_of_day',\n      'day_of_week',\n      'intent_confidence',\n      'provider_performance'\n    ],\n    predictionHorizon: 7,\n    confidenceThreshold: 0.8\n  }\n});\n```\n\n### Reporting Configuration\n\n```typescript\nconst analytics = new ChatAnalytics({\n  reporting: {\n    enabled: true,\n    formats: ['json', 'csv', 'pdf'],\n    schedules: {\n      daily: { enabled: true, time: '09:00' },\n      weekly: { enabled: true, day: 'monday', time: '09:00' },\n      monthly: { enabled: true, day: 1, time: '09:00' }\n    },\n    recipients: ['admin@company.com', 'analytics@company.com']\n  }\n});\n```\n\n## NeverHub Integration\n\nThe package supports optional NeverHub integration for service discovery and event-based communication:\n\n```typescript\nconst analytics = new ChatAnalytics({\n  neverhub: {\n    enabled: true,\n    serviceName: 'chat-analytics',\n    capabilities: [\n      { type: 'analytics', name: 'chat-metrics', version: '1.0.0' },\n      { type: 'ml', name: 'behavior-analysis', version: '1.0.0' },\n      { type: 'insights', name: 'performance-insights', version: '1.0.0' }\n    ],\n    dependencies: ['chat-provider-*', 'chat-ai-router']\n  }\n});\n\nawait analytics.initialize();\n\n// Check NeverHub status\nconst status = analytics.getNeverHubStatus();\nconsole.log('NeverHub enabled:', status.enabled);\nconsole.log('NeverHub registered:', status.registered);\n```\n\n**Note**: The package works perfectly without NeverHub - it will gracefully degrade if NeverHub is not available.\n\n## API Reference\n\n### ChatAnalytics\n\nMain class for analytics operations.\n\n#### Methods\n\n- `initialize(): Promise<AnalyticsResult<void>>` - Initialize analytics system\n- `shutdown(): Promise<AnalyticsResult<void>>` - Shutdown analytics system\n- `collectEvent(event: AnalyticsEvent): AnalyticsResult<void>` - Collect generic event\n- `collectMessageMetric(data): AnalyticsResult<void>` - Collect message metric\n- `collectUserMetric(data): AnalyticsResult<void>` - Collect user metric\n- `collectPerformanceMetric(data): AnalyticsResult<void>` - Collect performance metric\n- `collectIntentMetric(data): AnalyticsResult<void>` - Collect intent metric\n- `collectProviderMetric(data): AnalyticsResult<void>` - Collect provider metric\n- `generateInsights(): AnalyticsResult<Insight[]>` - Generate insights from metrics\n- `getInsights(): InsightCollection` - Get all insights\n- `getActiveAlerts(): Alert[]` - Get active alerts\n- `acknowledgeAlert(alertId: string): AnalyticsResult<void>` - Acknowledge alert\n- `generateReport(options?): AnalyticsResult<Report>` - Generate report\n- `exportReport(report: Report): AnalyticsResult<string>` - Export report\n- `analyzeUserBehavior(userId, timeRange): AnalyticsResult` - Analyze user behavior\n- `analyzePerformance(timeRange): AnalyticsResult` - Analyze performance\n- `analyzeIntents(): AnalyticsResult` - Analyze intents\n- `analyzeTrends(periods?): AnalyticsResult` - Analyze trends\n- `getMetrics(type?): Metric[]` - Get metrics\n- `getConfig(): AnalyticsConfig` - Get configuration\n- `getNeverHubStatus()` - Get NeverHub integration status\n\n## Integration Status\n\n- **Logger**: Optional - Can be integrated for analytics logging\n- **Docs-Suite**: Ready - Full API documentation via TypeDoc\n- **NeverHub**: Optional - Graceful degradation when unavailable\n\n## Testing\n\n```bash\n# Run tests\nnpm test\n\n# Run tests with coverage\nnpm run test:coverage\n\n# Run linting\nnpm run lint\n\n# Build package\nnpm run build\n```\n\n## Dependencies\n\n- `@bernierllc/neverhub-adapter` - NeverHub integration (optional)\n- `@bernierllc/retry-policy` - Retry logic\n- `@bernierllc/rate-limiter` - Rate limiting\n- `@bernierllc/logger` - Logging (optional)\n- `@bernierllc/config-manager` - Configuration management\n- `zod` - Schema validation\n\n## License\n\nCopyright (c) 2025 Bernier LLC. All rights reserved.\n\nThis file is licensed to the client under a limited-use license.\nThe client may use and modify this code *only within the scope of the project it was delivered for*.\nRedistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.\n","readmeFilename":"README.md"}