Skip to content

bug: GET /api/analytics/overviewtotalFollows counts follows *performed by* the user, not follows *received* by the user #435

@Srejoye

Description

@Srejoye

Description:

The /api/analytics/overview endpoint exposes a totalFollows field that is presented to users alongside their profile views and unique viewer counts in the analytics dashboard. The field is computed as:

app.prisma.followLog.count({
  where: {
    followerId: userId,
    status: 'success',
  },
})

This query counts all FollowLog records where followerId === userId — i.e., follows that this user has performed on other people. The correct semantic for a profile analytics dashboard is the number of times other users followed this user — which would require filtering on targetUsername === currentUser.username (or an equivalent join).

The field name totalFollows combined with its placement next to totalViews and uniqueViewers creates a consistent "how many people engaged with me" narrative that this metric actively breaks. A user who has followed many other developers will see a high totalFollows count that is entirely about their own outbound activity, not their inbound audience.

Affected file: apps/backend/src/routes/analytics.ts (lines 41–45)

Steps to reproduce:

  1. User A follows users B and C via the DevCard follow API.
  2. No one follows User A.
  3. User A opens the analytics dashboard — totalFollows reads 2, incorrectly implying two people followed them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions