feat(analytics): M2 self-improving chatbot analytics

Daily LLM classification of every chat (topics + product tags + deal
won/lost/undecided) aggregated into immutable daily metrics, with a
filterable admin report dashboard, product-catalog import (text/CSV/XLSX),
weekly persona summary, and an approval flow (LINE -> Telegram -> webhook)
for applying persona recommendations.

- Llm::AnalyticsClassifier: per-account openai -> Captain fallback cascade
- AccountDailyProcessor + Conversation/CustomerDailyMetric aggregation
- ReportService + DrilldownService (summary + deep filterable drilldown)
- AnalyticsReports.vue + productCatalog import UI (admin-only)
- WeeklyPersonaEvaluator + PersonaApprovalService (LINE/Telegram/webhook)
- Weekly cron (Mon 10:00) + daily cron (02:30)
This commit is contained in:
Moreminimore
2026-08-25 15:56:11 +07:00
parent 02ae690a87
commit b86b0c59f6
22 changed files with 2095 additions and 0 deletions

View File

@@ -74,3 +74,20 @@ remove_orphan_conversations_job:
cron: '0 */12 * * *'
class: 'Internal::RemoveOrphanConversationsJob'
queue: housekeeping
# M2 analytics: runs once daily at 02:30 in the installation (super admin) timezone.
# Single TZ, no hourly-check — single pass over all accounts' closed days.
# Note: cron is interpreted in the given timezone (sidekiq-cron `timezone`).
analytics_daily_metrics_job:
cron: '30 2 * * *'
timezone: 'Asia/Bangkok'
class: 'Analytics::DailyMetricsJob'
queue: scheduled_jobs
# M2 analytics: weekly persona evaluation every Monday 10:00 (Asia/Bangkok).
# Evaluates the last 7 days and delivers the recommendation via Analytics::PersonaApprovalService.
analytics_weekly_persona_evaluation_job:
cron: '0 10 * * 1'
timezone: 'Asia/Bangkok'
class: 'Analytics::WeeklyPersonaEvaluationJob'
queue: scheduled_jobs