Define active users before the agent writes SQL

Vibe codingMedium25 min

Your task

Your CEO wants monthly active users, MAU, in the board deck. Product and marketing already report MAU, and their numbers differ by 18%. Nobody ever wrote down what "active" means. An agent will write the Postgres query that becomes the official number.

Write the spec you would hand the agent.

What you know:

  • events(user_id, event_type, occurred_at) has about 900 million rows, with occurred_at a timestamptz and indexed
  • users(user_id, email, is_internal, deleted_at)
  • event types include login, page_view, message_sent, report_exported and email_opened
  • leadership agreed that active means doing something on purpose in the product, that the company reports in America/New_York, and that staff accounts do not count

Then, in a few sentences: why do vague analytics prompts give numbers that look right?