Skip to content

feat(event): accept member_id in event ingestion API #9227

@psincraian

Description

@psincraian

Summary

Update the event ingestion API to accept member fields, as part of Phase 6: Event Ingestion (parent issue #7899).

Context

From Slack discussion with Pieter:

  • Events should support member_id / external_member_id to track "who did this" on top of "who pays for this"
  • B2C (seat_based disabled): Can auto-map customer to owner member (future enhancement)
  • B2B: Optionally pass [external_]member_id for member-specific attribution
  • Billing queries remain unchanged (still use [external_]customer_id)

Changes

Schema Changes (server/polar/event/schemas.py)

  • Add member_id: UUID | None to EventCreateCustomer schema
  • Add external_member_id: str | None to EventCreateExternalCustomer schema

Service Changes (server/polar/event/service.py)

  • Update ingest() method to accept and validate member fields
  • Store member_id and external_member_id in Event record
  • Copy member fields to MeterEvent records in _create_meter_events()

Endpoint Changes (server/polar/event/endpoints.py)

  • No changes needed - schemas drive the API contract

Files to Modify

  • server/polar/event/schemas.py
  • server/polar/event/service.py

Deployment

Safe to deploy - optional parameters maintain backward compatibility.

Parent Issue

Part of #7899

Dependencies

Requires #9224 and #9226 (database migrations) to be completed first

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat/businessesTasks related to the feature of adding business/teams <> customer relationship support.polar-teamIssues that will be handled by the core Polar team

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions