analytics — Tracking-Log Analytics

The analytics code location aggregates tracking-log objects from S3-compatible storage into tenant-scoped PostgreSQL and Redis source metrics. It is consumed by the identity-resolution and reporting flows; it does not yet materialize the broader Polars/Parquet customer-feature pipeline described in the root backend architecture document.

Dagster interface

  • Job: analytics_job
  • Schedule: analytics_hourly_schedule
  • Current schedule: every three minutes (*/3 * * * *, UTC)
  • Implementation: source_analytics.tracking_log_aggregation.process_tracking_logs

The job uses bounded source/object batches, Redis leases, and persistent per-source checkpoints so retries do not double-count processed objects.

Package layout

PathResponsibility
dagster_defs.pyJob, op, schedule, and active-run guard
source_analytics/config.pyImmutable database, Redis, S3, and batching settings
source_analytics/tracking_log_aggregation.pyTracking-object processing and source totals
source_analytics/object_store.pyS3/MinIO object access
source_analytics/repositories.pyPostgreSQL source-state persistence
tests/Aggregation and component tests

Configuration

The service reads .env and environment variables including DB_*, REDIS_*, S3_*, ANALYTICS_S3_ENDPOINT_URL, ANALYTICS_DATA_SOURCE_LIMIT, ANALYTICS_MAX_WORKERS, ANALYTICS_SOURCE_BATCH_SIZE, ANALYTICS_OBJECT_BATCH_SIZE, and ANALYTICS_EVENT_RAW_PREFIX.

Testing

Run from the repository root:

python -m pytest customer360-backend/analytics/tests -q