Skip to content

feat: add cross-channel analytics system for amoCRM#630

Open
acc2git wants to merge 2 commits into
amocrm:masterfrom
acc2git:feature/001-cross-channel-analytics
Open

feat: add cross-channel analytics system for amoCRM#630
acc2git wants to merge 2 commits into
amocrm:masterfrom
acc2git:feature/001-cross-channel-analytics

Conversation

@acc2git

@acc2git acc2git commented Jun 13, 2026

Copy link
Copy Markdown

Overview

New analytics service (analytics/) with Fusio integration for end-to-end customer journey tracking.

Components

Models (8 files)

  • LeadSnapshot, Transaction, SourceAttribution, CustomerLTV
  • FunnelStage, BaseModel
  • Full toArray/fromArray/getId interface

Repositories (9 files)

  • ConnectionFactory with DBAL
  • LeadSnapshotRepo, TransactionRepo, WebhookLogRepo
  • PipelineStagesRepo, SourceAttributionRepo, CustomerLTVRepo
  • AnalyticsEventRepo, ContactsCacheRepo

Services (3 files)

  • FunnelService: pipeline stage metrics, conversion rates
  • AttributionService: first/last touch attribution
  • LTVService: customer lifetime value, cohort analysis

Webhook Processing (9 files)

  • Handler with idempotency via WebhookLog
  • Verifier: HMAC signature verification
  • PayloadValidator: event type & field validation
  • 6 event processors for lead/customer/unsorted events

ETL Exporters (5 files)

  • BaseExporter with pagination & rate limiting
  • LeadsExporter, EventsExporter, UnsortedExporter
  • ContactsExporter, CustomersExporter with CustomFieldExtractor

Fusio API Actions (6 files)

  • WebhookAction: POST /webhook/amocrm
  • FunnelAction: GET /api/analytics/funnel
  • AttributionAction: GET /api/analytics/attribution
  • LTVAction: GET /api/analytics/ltv
  • OverviewAction: GET /api/analytics/overview

CLI Commands (6 files)

  • etl:full, etl:incremental, etl:leads, etl:events
  • sync:pipelines
  • webhook:subscribe, webhook:status

Database Schema

  • 8 tables: lead_snapshots, transactions, webhook_logs, analytics_events, source_attribution, customer_ltv, contacts_cache, pipeline_stages
  • Complete indexes for query performance

Tests (5 files)

  • Unit tests for LeadSnapshot, FunnelStage, CustomerLTV
  • IdempotencyChecker, Verifier tests

## Overview
New analytics service (analytics/) with Fusio integration for
end-to-end customer journey tracking.

## Components

### Models (8 files)
- LeadSnapshot, Transaction, SourceAttribution, CustomerLTV
- FunnelStage, BaseModel
- Full toArray/fromArray/getId interface

### Repositories (9 files)
- ConnectionFactory with DBAL
- LeadSnapshotRepo, TransactionRepo, WebhookLogRepo
- PipelineStagesRepo, SourceAttributionRepo, CustomerLTVRepo
- AnalyticsEventRepo, ContactsCacheRepo

### Services (3 files)
- FunnelService: pipeline stage metrics, conversion rates
- AttributionService: first/last touch attribution
- LTVService: customer lifetime value, cohort analysis

### Webhook Processing (9 files)
- Handler with idempotency via WebhookLog
- Verifier: HMAC signature verification
- PayloadValidator: event type & field validation
- 6 event processors for lead/customer/unsorted events

### ETL Exporters (5 files)
- BaseExporter with pagination & rate limiting
- LeadsExporter, EventsExporter, UnsortedExporter
- ContactsExporter, CustomersExporter with CustomFieldExtractor

### Fusio API Actions (6 files)
- WebhookAction: POST /webhook/amocrm
- FunnelAction: GET /api/analytics/funnel
- AttributionAction: GET /api/analytics/attribution
- LTVAction: GET /api/analytics/ltv
- OverviewAction: GET /api/analytics/overview

### CLI Commands (6 files)
- etl:full, etl:incremental, etl:leads, etl:events
- sync:pipelines
- webhook:subscribe, webhook:status

### Database Schema
- 8 tables: lead_snapshots, transactions, webhook_logs,
  analytics_events, source_attribution, customer_ltv,
  contacts_cache, pipeline_stages
- Complete indexes for query performance

### Tests (5 files)
- Unit tests for LeadSnapshot, FunnelStage, CustomerLTV
- IdempotencyChecker, Verifier tests

Co-authored-by: openhands <openhands@all-hands.dev>
### Bug Fixes
- BaseExporter: Fix pagination method from nextPage() to getNextPage()
- LeadSnapshotRepo: Optimize insertBatch() to use single INSERT statement

### Improvements
- Verifier: Add comprehensive PHPDoc documentation
- README: Complete rewrite with full documentation

### Documentation
- Added webhook event handlers table
- Added API query parameter examples
- Added database schema documentation
- Added security section (HMAC verification, timing-safe comparison)
- Added performance optimization notes

Co-authored-by: openhands <openhands@all-hands.dev>
@acc2git

acc2git commented Jun 13, 2026

Copy link
Copy Markdown
Author

kk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants