Skip to content

refactor(orpc): unify campaign "counters" naming with project "stats" #8

Description

@ciokan

Moved out of studio/TODO.md (see #6).

contract renamed from counters to stats (campaign)

Problem

counters and stats are used inconsistently across the contract schemas.

packages/orpc/src/schema/projects.ts has both, and the split there is meaningful:

stats: z.object({    // engagement metrics
    sent, bounced, opened, replied
}).optional(),

counters: z.object({ // entity counts
    campaigns, leads, leadsLists
}).optional(),

packages/orpc/src/schema/campaigns.ts has a single counters object that mixes both concerns:

counters: z.object({
    sent, opened, clicked, replied, bounced, unsubscribed, delivered, // metrics
    leads, sequences,                                                 // entity counts
})

Proposal

Adopt the projects convention everywhere: stats = engagement metrics, counters = entity counts. On campaigns, split the current counters object into stats (sent/opened/clicked/replied/bounced/unsubscribed/delivered) and counters (leads/sequences).

Open question worth settling in this issue: campaigns_counters (contract + schema + API module, mounted at prefix /campaigns/counters) returns per-day engagement metrics — under the convention above it should be renamed to campaigns_stats / /campaigns/stats.

Scope

  • packages/orpc/src/schema/campaigns.ts, schema/campaigns_counters.ts
  • packages/orpc/src/contract/campaigns_counters.ts + its registration in contract/index.ts
  • apps/api/src/modules/campaigns/controller.ts, modules/campaigns/counters/*, modules/projects/controller.ts
  • apps/dashboard/src/enhancers/campaign.ts, components/campaigns/list/list.tsx, components/projects/list.tsx
  • Rebuild packages/orpc (+ dbschema if touched) afterwards.

Breaking change to the public route path if /campaigns/counters is renamed — fine while the API is still faker-backed and unreleased.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions