Skip to content

## Issue #93: Build Daily Revenue Email/Webhook Report #598

Description

@orunganiekan

Category: Backend / Scripts
Complexity: High
Points: 200
Branch: feat/daily-revenue-webhook

Background

daily-revenue-summary.ts computes revenue but only outputs to console. Merchant operators want daily revenue reports delivered automatically to their preferred notification channel (email, Slack, Discord, or generic webhook).

Problem

Daily revenue reports are only available by manually running a script. There is no automated delivery mechanism to push reports to merchant notification channels.

Acceptance Criteria

  • scripts/daily-revenue-summary.ts is extended to support --webhook <url> flag
  • Webhook payload: { date, total_volume_xlm, total_charges, unique_merchants, new_subscribers, cancellations, fee_collected_xlm }
  • Slack formatting: payload is formatted as a Slack Block Kit message when SLACK_WEBHOOK_URL is set
  • Report caching: if a report for today's date already exists in data/reports/, skip re-computation and re-delivery (unless --force)
  • Error handling: failed webhook delivery is logged with full response body; script exits 0 (report computed successfully even if delivery failed)

Implementation Guidelines

Key files: scripts/daily-revenue-summary.ts
Approach: After computing the report, check if a cached file exists for today. If not, compute, cache to data/reports/YYYY-MM-DD.json. Format for Slack or generic JSON. POST to webhook URL.
Edge cases: Webhook URL not set (skip delivery, still output to console); partial day run (report for today may be incomplete — note in payload as partial: true); date in different timezone (use UTC consistently).
Validation: Run script with a test Slack webhook, verify message format and delivery

PR Requirements

  • TypeScript with strict types
  • Error handling and graceful failure
  • README or inline JSDoc for usage
  • Configuration via environment variables

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions