Skip to content

Add track_delivery_metric for /api/v1/metrics endpoint#139

Merged
hownowstephen merged 4 commits into
mainfrom
add-track-delivery-metric
May 8, 2026
Merged

Add track_delivery_metric for /api/v1/metrics endpoint#139
hownowstephen merged 4 commits into
mainfrom
add-track-delivery-metric

Conversation

@hownowstephen
Copy link
Copy Markdown
Contributor

@hownowstephen hownowstephen commented May 7, 2026

Summary

  • Adds track_delivery_metric method to Client for reporting delivery metrics via the /api/v1/metrics endpoint, replacing the deprecated /push/events endpoint
  • Supports 8 metric types: opened, clicked, converted, delivered, bounced, deferred, dropped, spammed
  • Adds DELIVERY_* constants and VALID_DELIVERY_METRICS to Customerio::Client
  • PUSH_OPENED, PUSH_CONVERTED, PUSH_DELIVERED preserved as deprecated aliases pointing to DELIVERY_* equivalents

Based on #112 by @eserra, reimplemented with fixes for:

  • valid_url? bug (passed boolean instead of URL string)
  • .present? usage (Rails-only, unavailable in plain Ruby)
  • Inconsistent attribute handling (now uses existing symbolize_keys/slice pattern)

Test plan

  • CI passes (rspec + rubocop)
  • Verify track_delivery_metric sends correct POST to /api/v1/metrics
  • Verify validation: invalid metric names, missing delivery_id, whitespace delivery_id
  • Verify optional attributes (timestamp, recipient, reason, href) included only when present
  • Verify unknown attributes are filtered out

Note

Low Risk
Mostly additive client API and tests; existing push-event constants are preserved as deprecated aliases and still map to the same metric strings, keeping compatibility risk low.

Overview
Adds Client#track_delivery_metric to report delivery metrics to the new /api/v1/metrics endpoint, including input validation, attribute filtering, and support for optional fields (timestamp, recipient, reason, href).

Introduces DELIVERY_* constants plus VALID_DELIVERY_METRICS, deprecates the old PUSH_* constants as aliases, and updates docs/changelog plus a comprehensive RSpec suite for the new endpoint. Also loosens RuboCop Metrics/ClassLength to accommodate the added client code.

Reviewed by Cursor Bugbot for commit a1aecda. Bugbot is set up for automated code reviews on this repo. Configure here.

Adds support for reporting delivery metrics (opened, clicked,
converted, delivered, bounced, deferred, dropped, spammed) via the
new /api/v1/metrics endpoint, replacing the deprecated /push/events
endpoint.

Based on community PR #112 by @eserra with fixes for:
- valid_url? bug that passed boolean instead of URL string
- .present? usage (Rails-only, unavailable in plain Ruby)
- Breaking constant renames (PUSH_* constants preserved)
- Inconsistent attribute handling (now uses symbolize_keys/slice)
PUSH_OPENED/PUSH_CONVERTED/PUSH_DELIVERED were duplicates of
DELIVERY_OPENED/DELIVERY_CONVERTED/DELIVERY_DELIVERED. Consolidate
to a single set of constants.
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2fd7095. Configure here.

Comment thread lib/customerio/client.rb
Preserves backwards compatibility for anyone referencing
PUSH_OPENED, PUSH_CONVERTED, or PUSH_DELIVERED directly.
@hownowstephen hownowstephen merged commit 507f6c0 into main May 8, 2026
9 checks passed
@hownowstephen hownowstephen deleted the add-track-delivery-metric branch May 8, 2026 21:12
@eserra
Copy link
Copy Markdown

eserra commented May 9, 2026

yeah!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants