Skip to content

Conversation

@polmiro
Copy link
Member

@polmiro polmiro commented Oct 30, 2025

Summary

Integrate non-subscription events tracking into EventsManager with storage, network requests, and comprehensive test coverage. I will do a more advanced flushing as a separate improvement, possibly taking into account the age of the events, when the last flushed happned and/or the number of events stored. For now just following the same pattern used for FeatureEvent.

Changes

  • Storage: Add AdEventStore for persisting ad events to disk
  • Networking: Add PostAdEventsOperation and AdEventsRequest for backend communication
  • Integration: Wire ad events into EventsManager with flushing logic
  • API Fix: Rename adInstanceId to impressionId to match backend schema (fixes 400 errors)
  • Testing: Add 37 unit tests and backend integration tests

Test Coverage

  • AdEventStoreTests: Storage/serialization (12 tests)
  • AdEventsRequestTests: Network request formatting (6 tests)
  • EventsManagerAdEventsTests: Manager integration (15 tests)
  • PurchasesAdEventsTests: Public API (4 tests)
  • AdEventsIntegrationTests: Backend integration (4 tests)
  • Tested manually tracking events against a production application with success.
@polmiro polmiro changed the title Rc ads events manager Oct 30, 2025
@polmiro polmiro changed the title Non Subscription Events manager Oct 30, 2025
@polmiro polmiro force-pushed the rc-ads-events-manager branch 5 times, most recently from e63905e to 93994b1 Compare October 30, 2025 15:11
@emerge-tools
Copy link

emerge-tools bot commented Oct 30, 2025

📸 Snapshot Test

7 modified, 872 unchanged

Name Added Removed Modified Renamed Unchanged Errored Approval
RevenueCat
com.revenuecat.PaywallsTester.mac-native
0 0 7 0 161 0 ⏳ Needs approval
RevenueCat
com.revenuecat.PaywallsTester.mac-catalyst-optimized-for-mac
0 0 0 0 237 0 N/A
RevenueCat
com.revenuecat.PaywallsTester.mac-catalyst-scaled-to-match-ipad
0 0 0 0 237 0 N/A
RevenueCat
com.revenuecat.PaywallsTester
0 0 0 0 237 0 N/A

🛸 Powered by Emerge Tools

@polmiro polmiro force-pushed the rc-ads-events-manager branch 3 times, most recently from f728371 to fa592ed Compare October 31, 2025 09:49
Separates feature event flushing into its own method:
- Add flushFeatureEvents to EventsManagerType protocol
- Implement flushFeatureEvents with existing flush logic
- Update flushEvents to delegate to flushFeatureEvents
- Update Purchases.flushPaywallEvents to call flushFeatureEvents
- Add flushFeatureEvents to MockEventsManager

This prepares EventsManager for supporting multiple event types.
Adds core infrastructure for storing and serializing ad events:
- StoredAdEvent: Model for ad events with user context
- StoredAdEventSerializer: JSON serialization/deserialization
- AdEventStore: File-based persistent storage with fetch/clear operations
- AdEventStoreTests: Comprehensive test coverage

Clean implementation without legacy migration code since feature is behind compiler flag.
@polmiro polmiro force-pushed the rc-ads-events-manager branch 3 times, most recently from 2dbdbb2 to dc07272 Compare October 31, 2025 10:25
Implements complete ad events lifecycle in EventsManager:
- Add flushAdEvents to EventsManagerType protocol
- AdEventStore integration with new initialization parameter
- Implement track(adEvent:) with proper serialization and storage
- Update flushEvents to flush both feature and ad events
- Network request handling via InternalAPI.postAdEvents
- Comprehensive error handling and logging (EventsManagerStrings)
- Full test coverage (EventsManagerAdEventsTests)
- Mock support for ad events in test infrastructure

Network layer additions:
- AdEventsRequest: HTTP request body for ad events endpoint
- PostAdEventsOperation: Network operation for posting ad events
- InternalAPI.postAdEvents: Async method for posting ad events
@polmiro polmiro force-pushed the rc-ads-events-manager branch from dc07272 to 8c25b9d Compare October 31, 2025 10:51
polmiro and others added 2 commits October 31, 2025 12:13
The backend expects `impression_id` but we were sending `ad_instance_id`.
This renames the field throughout the codebase:
- AdEvent.swift: Update AdEventData protocol and all event classes
- AdEventsRequest.swift: Update serialization field name
- All test files: Update to use impressionId parameter
- Objective-C API: Update parameter names

The field will be serialized as `impression_id` via snake_case conversion.
- Add AdEventsIntegrationTests.swift following BaseBackendIntegrationTests pattern
- Add internal flushAdEvents() method in Purchases for test access
- Add 4 test cases: tracking/flushing, empty flush, clearing after flush, persistence

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@polmiro polmiro force-pushed the rc-ads-events-manager branch from ffaf024 to 396e62c Compare October 31, 2025 13:46
@polmiro
Copy link
Member Author

polmiro commented Oct 31, 2025

@RCGitBot please test

@polmiro polmiro marked this pull request as ready for review October 31, 2025 13:51
@polmiro polmiro requested a review from a team as a code owner October 31, 2025 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2 participants