Feature: Contact Segmentation (#310)

BE
9d ago
+1273-58

Added availability to create segments on contacts lists and make campaigns over it

Closes #310


Summary by cubic

Adds contact segmentation so teams can target subsets of a contact book and see exact audience counts in campaigns.

  • New Features

    • Manage segments per contact book: create, edit, delete with rules (equals, contains, is set, is not set) and live contact counts.
    • Filter contact lists and exports by segment; invalid segment URLs auto-reset.
    • Campaign editor: pick a segment (resets on contact book change) and see a live audience badge; campaign details show segment and recipient count; getCampaign now includes contactSegment.
    • Backend: listSegments, createSegment, updateSegment, deleteSegment, getCampaignAudience; contacts APIs accept segmentId; campaign updates accept contactSegmentId with contact book validation; send/schedule/batching compute audience and totals using segment filters.
  • Migration

    • Adds ContactSegment table and Campaign.contactSegmentId. Run Prisma migrations to apply the new schema and indexes.

Summary by CodeRabbit

  • New Features
    • Create, edit, and delete custom contact segments using contact-property rules.
    • Filter contact lists and exports by segment.
    • Target campaigns to selected segments or all contacts.
    • View campaign audience counts and selected segment names.
    • Segment targeting is preserved when campaigns are duplicated.