Skip to content

Add stats UTM endpoint#1253

Open
adalpari wants to merge 1 commit intotrunkfrom
adalpari/add-utm-endpoint
Open

Add stats UTM endpoint#1253
adalpari wants to merge 1 commit intotrunkfrom
adalpari/add-utm-endpoint

Conversation

@adalpari
Copy link
Copy Markdown
Contributor

Description

Add a new WP.com REST API endpoint for UTM stats at /sites/{site_id}/stats/utm/{utm_keys}. This follows the existing stats endpoint patterns in the codebase.

Changes

  • Add StatsUtmKey enum supporting utm_source, utm_medium, and utm_campaign
  • Add StatsUtmKeys newtype for comma-separated UTM keys used as a URL path segment
  • Add StatsUtmParams with support for max, date, days, start_date, post_id, and query_top_posts query parameters
  • Add StatsUtmResponse, StatsUtmPost response types with top_utm_values and top_posts fields
  • Handle empty array/object responses via deserialize_empty_array_or_hashmap
  • Register the endpoint in client.rs, endpoint.rs, and mod.rs

Test plan

  • Unit tests for UTM key serialization (single, multiple, all keys)
  • Unit tests for query parameter serialization (full, minimal, query_top_posts=false)
  • Deserialization tests for single-key, multiple-keys, triple-keys, empty, and empty-arrays JSON fixtures

🤖 Generated with Claude Code

@wpmobilebot
Copy link
Copy Markdown
Collaborator

wpmobilebot commented Mar 26, 2026

XCFramework Build

This PR's XCFramework is available for testing. Add to your Package.swift:

.package(url: "https://github.com/automattic/wordpress-rs", branch: "pr-build/1253")

Built from 49d3a78

Implement a new WP.com REST API endpoint for UTM stats at
/sites/{site_id}/stats/utm/{utm_keys}. Supports querying by
single or comma-separated UTM keys (source, medium, campaign)
with date range filtering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@adalpari adalpari force-pushed the adalpari/add-utm-endpoint branch from 2747442 to 49d3a78 Compare March 26, 2026 12:51
@adalpari adalpari requested a review from jkmassel March 27, 2026 09:34
@adalpari adalpari marked this pull request as ready for review March 27, 2026 09:34
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.

2 participants