Skip to content

Conversation

@kean
Copy link
Contributor

@kean kean commented Jan 20, 2026

This PR is the first part of CMM-1132: Add WordAds revenue stats to Jetpack app.

Changes

  • Add /wordads/stats endpoint and the related types to parse it (WordPressKit) and to map for the Stats screen (WordAdsMetric)
  • Introduce MetricType protocol to generalize that code that previous supported only StatsMetric (views, visitors, etc)
  • Update some unit tests that were failing due to the year change

Testing Instructions

n/a (the relevant parts are covered by unit tests)

@kean kean marked this pull request as draft January 20, 2026 22:36
@dangermattic
Copy link
Collaborator

1 Warning
⚠️ This PR is larger than 500 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jan 20, 2026

App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number30590
VersionPR #25152
Bundle IDcom.jetpack.alpha
Commit223d195
Installation URL69scb91t3pho8
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jan 20, 2026

App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number30590
VersionPR #25152
Bundle IDorg.wordpress.alpha
Commit223d195
Installation URL5s8s7quugbnn0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jan 20, 2026

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

@kean kean force-pushed the task/add-chart-view branch 2 times, most recently from 95beb65 to 246d20b Compare January 22, 2026 20:42
@kean kean force-pushed the task/add-chart-view branch from 246d20b to 223d195 Compare January 23, 2026 18:43
@kean kean changed the title Add Ads main chart Add WordAdsMetric and related APIs Jan 23, 2026
@sonarqubecloud
Copy link


/// A legacy variant of `WordPressKit.StatsTimeIntervalData` API that supports
/// only support setting the target date and the quantity of periods to return.
func getData<TimeStatsType: WordPressKit.StatsTimeIntervalData>(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most of this code was simply moved from the bottom of StatsService.swift. The only addition is the method:

/// A legacy variant of `WordPressKit.StatsTimeIntervalData` API that supports
    /// only support setting the target date and the quantity of periods to return.
    func getData<TimeStatsType: WordPressKit.StatsTimeIntervalData>(
        date: Date,
        unit: WordPressKit.StatsPeriodUnit,
        quantity: Int
     ) async throws -> TimeStatsType where TimeStatsType: Sendable {


func getWordAdsStats(date: Date, granularity: DateRangeGranularity) async throws -> WordAdsMetricsResponse {
// Check cache first
let cacheKey = WordAdsStatsCacheKey(date: date, granularity: granularity)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a little bit of duplication, but it's still easy to read and understand, and I wanted to limit the impact on the existing code.

@kean kean added the Stats label Jan 23, 2026
@kean kean added this to the 26.7 milestone Jan 23, 2026
@kean kean requested a review from crazytonyli January 23, 2026 18:49
@kean kean marked this pull request as ready for review January 23, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants