Skip to content

Implement Churn risk scoring analytics provider #521

Description

@phertyameen

Description

Add a provider that computes churn risk scoring: flag users whose activity frequency has dropped sharply vs. their historical baseline. Accept a DateRangeDto and optional granularity query, and return a typed AnalyticsMetricResult. Query against pre-aggregated tables where one exists rather than scanning raw AnalyticsEvent rows.

Why this matters

Churn risk scoring is one of the core metrics product/growth needs surfaced on the analytics dashboard; without a dedicated provider it can't be exposed via an API endpoint.

Files to touch

  • backend/src/analytics/providers/get-churn-risk.provider.ts
  • backend/src/analytics/providers/get-churn-risk.provider.spec.ts

Acceptance Criteria

  • Provider returns correct results against seeded test data
  • Handles empty-range/no-data case without throwing
  • Query is index-backed (no full table scan on AnalyticsEvent)
  • Unit tests cover at least 3 scenarios (empty, single day, multi-day range)

Notes

This issue is part of the new analytics module effort (tracking, aggregation,
and reporting on player/game activity). Please keep new code inside
backend/src/analytics/ following the same module/controller/service/provider
layout used by existing modules (e.g. progress, streak, quests).

Activity

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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions