Skip to content

feat(ads/admob): add impression_id to SSV customRewardText payload#6841

Merged
polmiro merged 2 commits into
mainfrom
pol/ads-admob-ssv-impression-id
May 27, 2026
Merged

feat(ads/admob): add impression_id to SSV customRewardText payload#6841
polmiro merged 2 commits into
mainfrom
pol/ads-admob-ssv-impression-id

Conversation

@polmiro

@polmiro polmiro commented May 26, 2026

Copy link
Copy Markdown
Member

Checklist

  • Unit tests (SetupTests covers the new JSON field)
  • Cross-platform follow-up — no API impact; backend ingestion already keys on impression_id

Motivation

The AdMob SSV customRewardText payload (currently {api_key, client_transaction_id}) carries no link back to the originating impression. SDK impression events (Ad Loaded / Displayed / Opened / Revenue) already include impression_id (from responseInfo.responseIdentifier), but the SSV webhook event ingested on the backend has no field to join against them. Adding impression_id to the SSV payload lets backend webhook events anchor to the same impression as the SDK events for one ad load.

Description

  • Tracking.Adapter.impressionID(from:) is promoted from private to internal so the reward-verification flow can reuse the same ?? "" fallback policy as the existing event-tracking flow. Single source of truth.
  • RewardVerification.CapableAd protocol gains responseInfo: GoogleMobileAds.ResponseInfo? { get }. Both GADRewardedAd and GADRewardedInterstitialAd already expose it.
  • RewardVerification.Setup.install reads impressionId = Tracking.Adapter.impressionID(from: loadedAd.responseInfo) and threads it through to makeCustomRewardText.
  • RewardVerification.Setup.makeCustomRewardText takes an impressionId: String parameter and includes it in the JSON. The payload stays [String: String] with sorted keys, so existing snapshot/log shapes are preserved.

No public API change. Pure additive payload field.

Test plan

  • swift build (adapter) + swiftlint clean.
  • SetupTests::testMakeCustomRewardText... updated to pass impressionId: and assert the field appears in both the parsed payload and the deterministic sorted-key string output.
  • FakeRewardedAd / FakeCapableAd test doubles updated to satisfy the new responseInfo protocol requirement.

Note

Low Risk
Additive internal payload field and shared helper exposure; no auth or public API changes, with unit test coverage.

Overview
Adds impression_id to the AdMob server-side verification customRewardText JSON so SSV webhook events can be correlated with SDK ad events that already carry the same identifier.

RewardVerification.Setup.install now reads impressionId from the loaded ad’s responseInfo via Tracking.Adapter.impressionID, which is shared with the existing tracking path (promoted from private with an overload for non-optional ResponseInfo). CapableAd requires responseInfo so rewarded ads supply it at SSV install time. makeCustomRewardText accepts impressionId and serializes it alongside api_key and client_transaction_id with sorted keys unchanged.

Tests and fakes were updated for the new field and protocol requirement; no public API change.

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

Extends the SSV customRewardText payload with an impression_id field
sourced from AdMob's responseInfo.responseIdentifier at install time,
so backend webhook events can be anchored to the same impression as
the SDK impression events that already carry impression_id.

- CapableAd protocol gains a responseInfo getter so Setup.install can
  read the response identifier from any rewarded ad type. Both
  GADRewardedAd and GADRewardedInterstitialAd already expose it.
- Tracking.Adapter.impressionID(from:) is hoisted from private to
  internal — single source of truth for the empty-string fallback
  policy shared with the existing event-tracking flow.
- Setup.makeCustomRewardText takes an impressionId parameter and
  includes the field in the JSON unconditionally. Payload stays
  [String: String].

Tests updated: SetupTests covers the new field in the JSON; CapableAd
test doubles add responseInfo to satisfy the protocol.
@polmiro polmiro requested a review from ajpallares May 26, 2026 16:11
@polmiro polmiro marked this pull request as ready for review May 26, 2026 16:11
@polmiro polmiro requested a review from a team as a code owner May 26, 2026 16:11
@ajpallares

Copy link
Copy Markdown
Member

The CI is failing because

Type 'RewardedAd' does not conform to protocol 'RewardVerification.CapableAd'
Type 'RewardedInterstitialAd' does not conform to protocol 'RewardVerification.CapableAd'

These types also need to implement the new property

…type

GoogleMobileAds.RewardedAd.responseInfo is non-optional, so declaring the
protocol requirement as Optional broke conformance. Drop the `?` and add a
non-optional `impressionID(from:)` overload for the full-screen call sites.
@polmiro polmiro enabled auto-merge (squash) May 27, 2026 07:52
@polmiro polmiro merged commit d1b4366 into main May 27, 2026
20 of 42 checks passed
@polmiro polmiro deleted the pol/ads-admob-ssv-impression-id branch May 27, 2026 08:01
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.

2 participants