mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-09 22:35:56 +05:45
7d7d584634877a3f49ff4e28a6680edb7be70088
29
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
7d7d584634 |
Rename internal SSV symbols, URL and metric to RewardVerification (#6667)
* Rename internal AdMobSSV symbols, URL and metric to RewardVerification Renames the internal AdMobSSV* types and SPI introduced in #6641 to RewardVerification* so the wording stays adapter-agnostic. Also renames the backend URL path and the client-side metric to match, so the SPI is provider-agnostic end to end. Renames: - Sources/Ads/AdMobSSV/ -> Sources/Ads/RewardVerification/ - AdMobSSVPollStatus -> RewardVerificationPollStatus - RewardVerificationPollStatus.validated -> .verified - AdMobSSVStatusResponse -> RewardVerificationStatusResponse - RewardVerificationStatusResponse.Status.validated -> .verified (the decoder still accepts the legacy "validated" wire value during the rollout window; covered by a new decoder unit test) - AdMobSSVStatusCallback -> RewardVerificationStatusCallback - GetAdMobSSVStatusOperation -> GetRewardVerificationStatusOperation - AdsAPI.getAdMobSSVStatus -> getRewardVerificationStatus - Purchases.pollAdMobSSVStatus -> pollRewardVerificationStatus - HTTPRequest.Path.adMobSSVStatus -> .rewardVerificationStatus - URL path: /ads/admob/ssv/{tx} -> /ads/reward_verifications/{tx} - Metric name: get_admob_ssv_status -> get_reward_verification_status - BackendErrorStrings.unknown_admob_ssv_status -> .unknown_reward_verification_status - Test files, test methods and snapshot artifacts renamed to match. - Xcode project file references updated in lockstep. * Drop legacy `validated` wire-value compat in RewardVerification decoder The `RewardVerificationStatusResponse` decoder was accepting both `"verified"` and the legacy `"validated"` status from the backend as a backwards-compat hedge during rollout. The endpoint has not been shipped and the SDK has no public entry point that polls it yet, so there is no compatibility window to preserve — the decoder can require `"verified"` outright. While here, simplify the decoder to look up known cases via `Status(rawValue:)` instead of a string-literal switch, so adding a future case can't silently drift from the enum. Removes the corresponding `testDecodesLegacyValidatedWireValueAsVerified` test. Existing coverage for `verified`, `pending`, `failed`, and the `unknown` fallback (with the `Logger.warn` assertion) is unchanged. * Update Sources/Purchasing/Purchases/Purchases.swift Co-authored-by: Antonio Pallares <ajpallares@users.noreply.github.com> * test: assert warning is logged when decoding literal "unknown" status Address review feedback: cover the case where the backend sends the literal "unknown" wire value, which still falls through the unmapped-status branch and should emit a warning. --------- Co-authored-by: Antonio Pallares <ajpallares@users.noreply.github.com> |
||
|
|
23d012abe2 |
Add workflow-based paywall resolution (#6675)
* Add workflows network layer for multipage paywalls - Add `getWorkflows` and `getWorkflow` endpoint paths - Add `WorkflowsListResponse` and `PublishedWorkflow` response models - Add `WorkflowDetailProcessor` to handle `inline`/`use_cdn` response actions - Add `WorkflowCdnFetcher` protocol and `DirectWorkflowCdnFetcher` implementation - Add `GetWorkflowsOperation` and `GetWorkflowOperation` cacheable network operations - Add `WorkflowsAPI` facade and wire into `Backend` - Add unit tests for all new components iOS equivalent of https://github.com/RevenueCat/purchases-android/pull/3300 Made-with: Cursor * fix xcodeproj * reset Package.resolved * Update WorkflowStep models to match actual backend response - Add WorkflowTrigger struct (name, type, action_id, component_id) - Add triggers, outputs, and metadata fields to WorkflowStep - Add metadata field to PublishedWorkflow - Remove value field from WorkflowTriggerAction (backend uses step_id only) Made-with: Cursor * Update WorkflowResponseTests to match updated models - Replace value/resolvedTargetStepId assertions with stepId - Remove testDecodeWorkflowTriggerActionValueTakesPrecedence (value field removed) - Add testDecodeWorkflowTrigger for new WorkflowTrigger struct - Add testDecodePublishedWorkflowWithMetadata - Update testDecodeWorkflowStepDefaults to cover triggers, outputs, metadata - Add testDecodeWorkflowStepMatchingActualBackendResponse with real backend payload Made-with: Cursor * Disable file_length lint rule in HTTPRequestPath.swift Made-with: Cursor * Fix GetWorkflowOperation to compute result once before distributing to callbacks CDN fetch and JSON decoding were running once per deduplicated callback. Compute the Result<WorkflowFetchResult, BackendError> once outside the performOnAllItemsAndRemoveFromCache loop, matching the pattern used by GetOfferingsOperation and other operations in the codebase. Made-with: Cursor * Fix CDN fetcher: use URLSession instead of Data(contentsOf:), classify errors correctly - Replace Data(contentsOf:) with URLSession.shared.dataTask + DispatchSemaphore in DirectWorkflowCdnFetcher; gets URLSession timeout, HTTP status validation, and proper network stack semantics - Add WorkflowDetailProcessingError.cdnFetchFailed typed error so CDN I/O failures are distinguishable from envelope parsing failures - Catch cdnFetchFailed in GetWorkflowOperation and map to NetworkError.networkError instead of NetworkError.decoding, fixing misleading error classification - Update WorkflowDetailProcessorTests to assert the typed error is thrown Made-with: Cursor * Replace semaphore CDN fetch with async/await using withCheckedThrowingContinuation - Make WorkflowCdnFetcher.fetchCompiledWorkflowData async throws; use withCheckedThrowingContinuation to bridge URLSession.dataTask into async, avoiding any thread-blocking - Make WorkflowDetailProcessor.process async throws to propagate async - Bridge into async in GetWorkflowOperation via Task {}; completion() is called inside the Task after CDN fetch and decoding complete - Update WorkflowDetailProcessorTests to async throws with await Made-with: Cursor * Make CDN fetcher and processor completion-handler based for consistency Avoids Task{} in GetWorkflowOperation and keeps all operations calling completion() synchronously from within the HTTP callback, matching every other operation in the codebase. - WorkflowCdnFetcher.fetchCompiledWorkflowData now takes a completion handler; DirectWorkflowCdnFetcher uses URLSession.dataTask (non-blocking, no semaphore) - WorkflowDetailProcessor.process now takes a completion handler; inline action completes synchronously, use_cdn fans out to the fetcher callback - GetWorkflowOperation splits into getWorkflow/handleResponse/backendResult/ distribute helpers to stay within line-length limits - WorkflowDetailProcessorTests updated to use waitUntilValue pattern Made-with: Cursor * Fix ambiguous cache key delimiter in GetWorkflowOperation Space-separated appUserID+workflowId could collide (e.g. user 'a b' + workflow 'c' == user 'a' + workflow 'b c'). Use newline as delimiter, matching the precedent set by GetWebBillingProductsOperation. Made-with: Cursor * PR comments * remove cdn fetcher * fix response in BackendGetWorkflowsTests.swift * fix WorkflowResponseTests * fix error * [skip ci] Generating new test snapshots (#6584) * [skip ci] Generating new test snapshots (#6585) * [skip ci] Generating new test snapshots (#6586) * [skip ci] Generating new test snapshots (#6587) * [skip ci] Generating new test snapshots (#6588) * [skip ci] Generating new test snapshots (#6589) * [skip ci] Generating new test snapshots (#6590) * Test CDN mock is not re-assignable per test * [skip ci] Generating new test snapshots (#6597) * [skip ci] Generating new test snapshots (#6598) * [skip ci] Generating new test snapshots (#6599) * [skip ci] Generating new test snapshots (#6600) * [skip ci] Generating new test snapshots (#6601) * [skip ci] Generating new test snapshots (#6602) * [skip ci] Generating new test snapshots (#6603) * getWorkflow is signed * add type parameter * add response verification for CDN response * remove workflows list * add value to WorkflowTriggerAction * step id * hash and filerepo * missingCdnHash * linter and project * fix project * revert Package.resolved * @unchecked Sendable * use hash in generateOrGetCachedFileURL * fix compilation * skip responseVerificationMode in cdn * change basePath of caches * Add workflow-based paywall resolution (iOS parity with Android #3350) Implements the workflows endpoint so paywalls can be resolved from a workflow document rather than the offerings cache, gated behind the ENABLE_WORKFLOWS_ENDPOINT compile flag. Validates the step→screen→ offeringId chain and maps the workflow screen into Offering.PaywallComponents using the existing V2 rendering path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Add tests for workflow networking layer and WorkflowScreenMapper BackendGetWorkflowTests covers HTTP call, request caching, per-user and per-workflow-ID deduplication, error propagation, empty appUserID, and full response decoding. WorkflowScreenMapperTests verifies all PaywallComponentsData fields and the UIConfig are mapped correctly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * remove reserialization * Use explicit type in GetWorkflowOperation.createFactory for greppability Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Use explicit type in GetWorkflowOperation.createFactory for greppability Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix lint errors and refactor workflow offering resolution into PaywallViewConfiguration - Add swiftlint:disable comments for _revision identifier name in WorkflowsResponse.swift - Add missing_docs disable in WorkflowsResponse.swift (all @_spi(Internal) types) - Add file_length disable in Offering.swift - Fix identifier name 'd' → 'doubleValue' in WorkflowDetailProcessorTests.swift - Move workflow offering resolution from PaywallView into PaywallViewConfiguration.resolveOfferingOrThrow() - Add cachedInitialOffering() to PaywallViewConfiguration.Content - Add PaywallViewConfigurationTests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix swiftlint identifier_name violation in WorkflowDetailProcessorTests Rename short variable `d` to `doubleValue` in two `if case .double(let d)` patterns to satisfy the identifier_name rule requiring names >= 3 characters. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Inject PaywallPurchasesType into offering resolution; remove dead code - Add offerings(), cachedOfferings, and workflow() to PaywallPurchasesType so PaywallViewConfiguration.Content no longer calls Purchases.shared directly - Thread purchases through cachedInitialOffering/resolveOffering/resolveOfferingOrThrow and all private helpers; callers pass purchaseHandler.purchasesInstance - Expose purchasesInstance on PurchaseHandler for call sites - Add stubs to NotConfiguredPurchases, LoadingPaywallPurchases, and MockPurchases (MockPurchases gets offeringsBlock/workflowBlock for test injection) - Remove dead WorkflowDetailProcessingError.missingInlineData case - Replace manual JSONSerialization parseEnvelope with Data.asJSONDictionary() - Collapse double #if nesting into single compound condition - Remove WHAT doc comment from WorkflowDetailProcessor - Refactor resolveOffering() to delegate to resolveOfferingOrThrow() - Parallelize workflow + offerings fetches with async let Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Move offering resolution from Content to PurchaseHandler Resolving an offering requires a purchases instance, so it belongs on PurchaseHandler rather than as a method on the Content enum that takes purchases as a parameter. purchasesInstance accessor removed. Also fix MockPurchases.map() to forward offeringsBlock, workflowBlock, and cachedOfferings to the mapped instance, and simplify PaywallViewConfigurationTests to use MockPurchases directly instead of configuring a real Purchases singleton. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Add clarifying comment to workflow(forOfferingIdentifier:) explaining parameter naming Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix CI failures: remove duplicate switch cases and add @_spi(Internal) to test imports - Remove duplicate .getWorkflow cases in HTTPRequestPath.swift switches (auto-merge artifact that caused duplicate_conditions lint violations) - Add @_spi(Internal) to @testable imports in three unit test files so they can access WorkflowFetchResult, PublishedWorkflow, and WorkflowStep which are now @_spi(Internal) public Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix @_spi access in WorkflowDetailProcessorTests WorkflowResponseTests already had @_spi(Internal) @testable import RevenueCat; WorkflowDetailProcessorTests was missing the @_spi annotation, causing 'id', 'steps', and 'initialStepId' to be inaccessible on PublishedWorkflow. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix MockWorkflowsAPI.swift missing from StoreKitUnitTests and UnitTests targets The PBXBuildFile entries for DB7EA77F2F9764F700BCC082 and DB7EA7802F9764F700BCC082 were referenced in the StoreKitUnitTests and UnitTests source phases but never defined, causing MockWorkflowsAPI to be missing at compile time and MockBackend.swift to fail with 'cannot find MockWorkflowsAPI in scope'. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Add offering_identifier field to WorkflowScreen for parity with Android Android PR #3350 split offering_id (internal ID) from offering_identifier (human-readable identifier used for lookup). iOS was only decoding offering_id and using it for the offering lookup, which would fail if the workflow response sends the public identifier in offering_identifier. - Add offeringIdentifier (from offering_identifier) to WorkflowScreen - Update PurchaseHandler to prefer offeringIdentifier, falling back to offeringId - Fix typo: workflow.screelns -> workflow.screens - Add decode tests for both offering fields Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix WorkflowResponseTests: add missing padding field to stack component fixtures Stack component decoding requires a padding field; test JSON fixtures were missing it causing keyNotFound decode errors. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix WorkflowResponseTests: add missing margin field to stack component fixtures Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Replace ENABLE_WORKFLOWS_ENDPOINT compile flag with runtime argument check The -EnableWorkflowsEndpoint launch argument replaces the compile-time flag, allowing workflow resolution to be toggled without rebuilding. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Add Workflow presentation mode to PaywallsTester Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Remove offeringId shim, allow no-paywall offerings to open as workflows - Drop WorkflowScreen.offeringId / offering_id CodingKey (Android already uses offering_identifier exclusively — aligns both platforms) - Simplify PurchaseHandler to use screen.offeringIdentifier directly - No-paywall offerings in PaywallsTester now render as tappable rows (workflow mode) instead of plain read-only text, with a context menu restricted to the Workflow option Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Rename WorkflowFetchResult to WorkflowDataResult, extract ProcessInfo extension Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix project --------- Co-authored-by: Cesar de la Vega <664544+vegaro@users.noreply.github.com> Co-authored-by: RevenueCat Git Bot <72824662+RCGitBot@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> |
||
|
|
abad547968 |
AdMob SSV: add @_spi(Internal) poll endpoint on Purchases (#6641)
* Add AdMob SSV poll endpoint and `pollAdMobSSVStatus` SPI * Trim verbose AdMob SSV transport comments. Align AdsAPI and cache-key inline documentation with existing repository comment density while preserving behavior. * Trim pollAdMobSSVStatus SPI documentation. Reduce prescriptive guidance in the internal API comment while keeping the key cancellation behavior note. * [skip ci] Generating new test snapshots (#6648) * [skip ci] Generating new test snapshots (#6647) * [skip ci] Generating new test snapshots (#6646) * [skip ci] Generating new test snapshots (#6645) * [skip ci] Generating new test snapshots (#6644) * [skip ci] Generating new test snapshots (#6642) * [skip ci] Generating new test snapshots (#6643) * Trigger CI for PR 6641 checks. Add a non-skip commit so required CircleCI statuses are reported on the current head. * Validate non-empty client transaction ID for AdMob SSV polling. Guard against empty client transaction IDs in the SPI and backend operation and add focused backend tests for the new error path. * [skip ci] Generating new test snapshots (#6652) * [skip ci] Generating new test snapshots (#6653) * Trigger CI for PR 6641 checks. Add a non-skip commit so required CircleCI statuses are reported on the current head. * Enable signature verification for AdMob SSV status path. Update HTTP request path tests to cover AdMob SSV signature and nonce behavior. * fix: address review — move AdMob SPI extension to dedicated file * fix: address review — fail fast when AdMob status mock is unstubbed * fix: address review — dedupe client transaction validation in backend operation * fix: address review — use enum for AdMob SSV poll status * fix: address review — allow extracted Purchases extensions to access backend * fix: address review — log unknown AdMob SSV statuses * fix: address review — add Purchases AdMob SSV mapping tests * fix: address review — map missing client transaction ID to configuration error * fix: address review — keep backend private by co-locating AdMob extension * fix: address review — remove unused raw-value conformance * fix: address review — assert warning log for unknown AdMob status * fix: address review — surface unknown AdMob SSV status to adapters * fix: address review — enable eTag support for AdMob SSV status path --------- Co-authored-by: RevenueCat Git Bot <72824662+RCGitBot@users.noreply.github.com> |
||
|
|
0b65086ec2 |
Add workflows network layer for multipage paywalls (#6557)
* Add workflows network layer for multipage paywalls - Add `getWorkflows` and `getWorkflow` endpoint paths - Add `WorkflowsListResponse` and `PublishedWorkflow` response models - Add `WorkflowDetailProcessor` to handle `inline`/`use_cdn` response actions - Add `WorkflowCdnFetcher` protocol and `DirectWorkflowCdnFetcher` implementation - Add `GetWorkflowsOperation` and `GetWorkflowOperation` cacheable network operations - Add `WorkflowsAPI` facade and wire into `Backend` - Add unit tests for all new components iOS equivalent of https://github.com/RevenueCat/purchases-android/pull/3300 Made-with: Cursor * fix xcodeproj * reset Package.resolved * Update WorkflowStep models to match actual backend response - Add WorkflowTrigger struct (name, type, action_id, component_id) - Add triggers, outputs, and metadata fields to WorkflowStep - Add metadata field to PublishedWorkflow - Remove value field from WorkflowTriggerAction (backend uses step_id only) Made-with: Cursor * Update WorkflowResponseTests to match updated models - Replace value/resolvedTargetStepId assertions with stepId - Remove testDecodeWorkflowTriggerActionValueTakesPrecedence (value field removed) - Add testDecodeWorkflowTrigger for new WorkflowTrigger struct - Add testDecodePublishedWorkflowWithMetadata - Update testDecodeWorkflowStepDefaults to cover triggers, outputs, metadata - Add testDecodeWorkflowStepMatchingActualBackendResponse with real backend payload Made-with: Cursor * Disable file_length lint rule in HTTPRequestPath.swift Made-with: Cursor * Fix GetWorkflowOperation to compute result once before distributing to callbacks CDN fetch and JSON decoding were running once per deduplicated callback. Compute the Result<WorkflowFetchResult, BackendError> once outside the performOnAllItemsAndRemoveFromCache loop, matching the pattern used by GetOfferingsOperation and other operations in the codebase. Made-with: Cursor * Fix CDN fetcher: use URLSession instead of Data(contentsOf:), classify errors correctly - Replace Data(contentsOf:) with URLSession.shared.dataTask + DispatchSemaphore in DirectWorkflowCdnFetcher; gets URLSession timeout, HTTP status validation, and proper network stack semantics - Add WorkflowDetailProcessingError.cdnFetchFailed typed error so CDN I/O failures are distinguishable from envelope parsing failures - Catch cdnFetchFailed in GetWorkflowOperation and map to NetworkError.networkError instead of NetworkError.decoding, fixing misleading error classification - Update WorkflowDetailProcessorTests to assert the typed error is thrown Made-with: Cursor * Replace semaphore CDN fetch with async/await using withCheckedThrowingContinuation - Make WorkflowCdnFetcher.fetchCompiledWorkflowData async throws; use withCheckedThrowingContinuation to bridge URLSession.dataTask into async, avoiding any thread-blocking - Make WorkflowDetailProcessor.process async throws to propagate async - Bridge into async in GetWorkflowOperation via Task {}; completion() is called inside the Task after CDN fetch and decoding complete - Update WorkflowDetailProcessorTests to async throws with await Made-with: Cursor * Make CDN fetcher and processor completion-handler based for consistency Avoids Task{} in GetWorkflowOperation and keeps all operations calling completion() synchronously from within the HTTP callback, matching every other operation in the codebase. - WorkflowCdnFetcher.fetchCompiledWorkflowData now takes a completion handler; DirectWorkflowCdnFetcher uses URLSession.dataTask (non-blocking, no semaphore) - WorkflowDetailProcessor.process now takes a completion handler; inline action completes synchronously, use_cdn fans out to the fetcher callback - GetWorkflowOperation splits into getWorkflow/handleResponse/backendResult/ distribute helpers to stay within line-length limits - WorkflowDetailProcessorTests updated to use waitUntilValue pattern Made-with: Cursor * Fix ambiguous cache key delimiter in GetWorkflowOperation Space-separated appUserID+workflowId could collide (e.g. user 'a b' + workflow 'c' == user 'a' + workflow 'b c'). Use newline as delimiter, matching the precedent set by GetWebBillingProductsOperation. Made-with: Cursor * PR comments * remove cdn fetcher * fix response in BackendGetWorkflowsTests.swift * fix WorkflowResponseTests * fix error * [skip ci] Generating new test snapshots (#6584) * [skip ci] Generating new test snapshots (#6585) * [skip ci] Generating new test snapshots (#6586) * [skip ci] Generating new test snapshots (#6587) * [skip ci] Generating new test snapshots (#6588) * [skip ci] Generating new test snapshots (#6589) * [skip ci] Generating new test snapshots (#6590) * Test CDN mock is not re-assignable per test * [skip ci] Generating new test snapshots (#6597) * [skip ci] Generating new test snapshots (#6598) * [skip ci] Generating new test snapshots (#6599) * [skip ci] Generating new test snapshots (#6600) * [skip ci] Generating new test snapshots (#6601) * [skip ci] Generating new test snapshots (#6602) * [skip ci] Generating new test snapshots (#6603) * getWorkflow is signed * add type parameter * add response verification for CDN response * remove workflows list * add value to WorkflowTriggerAction * step id * hash and filerepo * missingCdnHash * linter and project * fix project * revert Package.resolved * @unchecked Sendable * use hash in generateOrGetCachedFileURL * fix compilation * skip responseVerificationMode in cdn * change basePath of caches * remove reserialization * Use explicit type in GetWorkflowOperation.createFactory for greppability Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix swiftlint identifier_name violation in WorkflowDetailProcessorTests Rename short variable `d` to `doubleValue` in two `if case .double(let d)` patterns to satisfy the identifier_name rule requiring names >= 3 characters. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * remove default FileRepositoryType * fix project * fix test * test preserves camel case * Generating new test snapshots for `feat/workflows-network-layer` - ios-15 (#6654) * Generating new test snapshots for `feat/workflows-network-layer` - ios-14 (#6656) --------- Co-authored-by: RevenueCat Git Bot <72824662+RCGitBot@users.noreply.github.com> Co-authored-by: Facundo Menzella <facumenzella@gmail.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Facundo Menzella <facumenzella@users.noreply.github.com> |
||
|
|
9356db1d42 | [CEC Mode]: introduce isPurchaseAllowedByRestoreBehavior() (#6192) | ||
|
|
b49a054843 |
Add client side timeout logic for endpoints that support fallback URLs (#5760)
* Implemented initial HTTPRequestTimeoutManager + added first couple of tests * Cleaned up the code and added a bunch more unit tests based on the Android test suite * Updated doc format * Add new files to workspace * Added HTTPClient tests testing interaction with timeout manager * Swiftlint fixes * Updated comment * Add missing file to workspace * Fix after rebase * Added extra HTTPClient <-> HTTPRequestTimeoutManager tests asserting on the recorded events * Implemented PR feedback * Fixed compile issue * Fix compile issue * Implemented PR feedback * Removed deleted file reference from workspace * Fixed test after changing reset timeout * Make sure the default HTTPRequistTimeoutManager is using the default value from the HTTPClient * Add a sophisticated test testing the full timeout flow against an unroutable IP for a real world scenario * Updated timeout case name * Fixed case where .timeoutOnMainBackendForFallbackSupportedEndpoint was also recorded for non timeouts and added tests to prevent regression * Fixed only stubbing the HTTP response based on path, since that could be the same across hosts, resulting in flaky tests |
||
|
|
8b229a2adc |
CC-582 | Allow for support ticket creation (#5779)
* feat: add contact support button and new sheet for ticket creation * chore: use localisation * feat: send support ticket details to backend * feat: only show the support ticket creation button when config is set up * feat: only show to correct customer type * test: add base tests * chore: remove unrequired var * chore: use translations * docs: update link to tuist * refactor: move to cc api * refactor: api calls * test: update setup * chore: better email validation * chore: improved focus state * chore: add dismiss * chore: hide keyboard on dismiss * chore: fix indentation * feat: add charcter count * chore: add rest of cc config * test: clean up unit tests * refactor: pull email validation out into struct * chore: refine email checks * refactor: pull out max characters into own var |
||
|
|
eaee0c3592 |
Fix signature verification fallback urls (#5756)
* Fix signature verification for fallback URLs * Add tests for signing with fallback path * Lint * Add log |
||
|
|
72cf38a0fe |
Added an internal API for overriding the API base URL (#5739)
* Added an internal API for overriding the API base URL * Updated and added tests for API baseURL configuration option * Revert change that removed serverHostURL from HTTPRequestPath since it broke other types implementing this protocol * swiftlint * Removed the apiBaseURL property from Purchases since it's only used for internal testing anyways * Remove unused @_spi(Internal) * Updated comment on api base URL vs proxy URL * Fixed linting issue |
||
|
|
2658f2b8fa |
Refactor: Rename PaywallEventsManager to EventsManager and separate ad events (#5718)
* Rename paywallsEventsManager to eventsManager * Rename PaywallEventsManagerType to EventsManagerType * Rename PaywallEventsManager to EventsManager * Rename PaywallEventStore to FeatureEventStore * Rename InternalAPI.postPaywallEvents to postFeatureEvents * Rename StoredEventSerializer to StoredFeatureEventSerializer * Rename createStoredEvent to createFeatureStoredEvent * Rename StoredEvent to StoredFeatureEvent * Rename HTTPRequest.PaywallPath to HTTPRequest.FeatureEventsPath * Rearrange events files * Rename event related files * Extract shared events endpoint configuration to EventsHTTPRequestPath Both FeatureEventsPath and AdPath share the same /v1/events endpoint configuration, differing only in domain (api-paywalls.revenuecat.com vs a.revenue.cat) and name. Extract common logic to EventsHTTPRequestPath protocol in Sources/Events/Networking. * Move Sources/FeatureEvents to Sources/Events/FeatureEvents * Rename EventsRequest to FeatureEventsRequest - Rename EventsRequest.swift to FeatureEventsRequest.swift - Move file to Sources/Events/FeatureEvents/Networking/ - Update all references in source and test files - Update Xcode project file references This makes it clear that this request type is specifically for the feature events endpoint, not a generic events request. * Remove ad events from feature events system Ad events should not be sent through the feature events system as they require their own separate infrastructure with a different API endpoint. Changes: - Remove FeatureEvent conformance from AdEvent - Remove .ads case from Feature enum - Remove ad events handling from FeatureEventsRequest - Add no-op track(adEvent:) method to EventsManager with comment - Update AdTracker to call the new track(adEvent:) method Ad events tracking now becomes a no-op until proper implementation with: - StoredAdEvent structure - AdEventStore for persistence - InternalAPI.postAdEvents() using HTTPRequest.AdPath.postEvents * Rename PostEventsOperation to PostFeatureEventsOperation - Rename PostEventsOperation.swift to PostFeatureEventsOperation.swift - Move file to Sources/Events/FeatureEvents/Networking/ - Update class name and remove misleading "generic" comment - Update references in InternalAPI.swift - Update Xcode project file references This makes it clear that this operation is specifically for posting feature events, not a generic operation for various event types. |
||
|
|
3ace587482 |
[SDK-4153] Use static fallback urls (#5709)
* change fallback URL logic to support a different path from the main server * Adapt unit tests to changes in fallback urls logic * lint * Add unit test for fallback urls * fix switched logic |
||
|
|
470ce93f4f |
Add non paid revenue reporting infra (#5640)
* Add RC Ads event tracking infrastructure Implements event tracking for RevenueCat Ads following the Paywalls Events pattern. - Adds three event types: ad displayed, ad opened, and ad revenue - Uses actor-based concurrency with file-based event storage - Posts events to e.revenue.cat/v1/events endpoint - Marks track(adEvent:) method as @_spi(Internal) for internal use - Includes comprehensive unit tests with snapshot testing - Available on iOS 15.0+, tvOS 15.0+, macOS 12.0+, watchOS 8.0+ Event schema follows khepri RC Ads input events specification with app_session_id field matching backend expectations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Avoid mapping in EventsRequest+Ad * Consolidate ad events into PaywallEventsManager Eliminates duplication between AdEventsManager and PaywallEventsManager by: - Making PaywallEventsManager handle all event types (ads, paywalls, customerCenter) - Adding feature-aware routing in flushEvents() to send events to correct domains - Ad events → https://e.revenue.cat/v1/events - Other events → https://api-paywalls.revenuecat.com/v1/events - Removing AdEventsManager, AdEventStore, and their tests (~500 lines) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Remove AdsStrings and use PaywallsStrings instead AdsStrings only had 2 strings in use, both of which already exist in PaywallsStrings. Consolidates logging strings to eliminate duplication. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Namespace Precision enum inside AdEvent.RevenueData Moves Precision from a top-level public enum to AdEvent.RevenueData.Precision to avoid polluting the global namespace and reduce autocomplete noise. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Move Precision conformances to end of file Follows the pattern of other types by declaring protocol conformances at the end of the file rather than inline with the type definition. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Remove redundant sessionIdentifier from AdImpressionData The sessionIdentifier field in AdImpressionData was redundant since StoredEvent already tracks appSessionID. This change: - Removes sessionIdentifier from AdImpressionData struct - Uses storedEvent.appSessionID directly when building requests - Renames sessionId to appSessionId to match backend field app_session_id - Updates documentation examples to remove sessionIdentifier parameter - Adds guard statement for optional appSessionID - Updates all test fixtures and regenerates snapshots - Removes iOS26 snapshot references from project 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Remove unneeded SessionId * Add proper assertions to PurchasesAdEventsTests Enhanced test coverage for public ad tracking APIs: - Verify events are tracked via mockPaywallEventsManager - Assert correct event types (displayed, opened, revenue) - Validate all impression data fields - Verify revenue-specific fields (revenueMicros, currency, precision) All 3 tests now pass with proper verification. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Add ENABLE_AD_EVENTS_TRACKING compiler flag * Simplify track ad events APIs * Fix ENABLE_AD_EVENTS_TRACKING scope and refactor Precision to struct Compiler flag fixes: - Move ENABLE_AD_EVENTS_TRACKING #endif to wrap all ad event code including internal enum - Add compiler flag guards to all three test files Precision API refactor: - Change AdRevenue.Precision from enum to struct following Apple's API patterns (like Message.Reason) - Use internal init(rawValue:) to prevent custom precision values - Convert enum cases to static properties maintaining same public API 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Refactor mediatorName from String to MediatorName struct Replace string-based mediator names with a type-safe struct following Apple's API patterns: - Add MediatorName struct with public init(rawValue:) to support custom values - Include predefined static properties for .adMob and .appLovin - Update AdEventData protocol to require MediatorName type - Update all event types (AdDisplayed, AdOpened, AdRevenue) to use MediatorName - Use .rawValue when serializing to network requests - Update all tests and documentation examples to use .appLovin 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Remove RawRepresentable conformance from Precision and update test snapshots - Remove RawRepresentable conformance from AdRevenue.Precision to allow internal init - Update test assertions to use .appLovin instead of string comparison - Update all snapshot test files to use "AppLovin" instead of "MAX" - All ad event tests now passing (11/11) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix PaywallDataDecodingTests locale check for region overrides The test was failing when the system locale included region overrides (e.g., "en_US@rg=eszzzz" instead of just "en_US"). Changes: - Use beginWith("en_US") instead of exact equality check - Compare against enConfig directly instead of fetching via Locale.current This makes the test more robust while maintaining the same behavior validation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Rename timestampMs to timestamp but keep serialized timestamp_ms * Use different serverHostURL * Simplify and paralelize postEvents * Adjust usage of ENABLE_AD_EVENTS_TRACKING flag * Move track ad event methods to AdTracker * Remove PaywallEventsManager implementation * Improving naming overlapping naming AdEvent->AdEventRequest * Simplify compiler flag usage * Use Experimental * Remove duplicate with PostPaywallEventsOperation and PostAdEventsOperation * Remove postAdEvents methods assuming reuse of event storage * Make Precision rawValue internal * Remove runtime checks * Trigger build * Move Public Types MARK comment after internal protocol * Add documentation for AdDisplayed, AdOpened, and AdRevenue properties * Remove redundant smoke tests The "DoesNotCrash" tests were completely redundant with the comprehensive "StoresEvent" tests. The comprehensive tests already: 1. Verify methods don't crash (implicitly) 2. Verify events are stored 3. Verify event data is correct Removed 3 redundant tests, keeping only the 3 comprehensive tests. * Fix bug not tracking initialized events --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
2bd289a993 |
Add GetWebBillingProductsOperation (#5419)
* Add validation logic for Test Store API keys under the TEST_STORE compiler flag * add unit test for test store api key validation * Move API key validation to `configure` and store validation result in `SystemInfo` * start new flow for purchase of `TestStoreProduct`s * WIP: implement alert for purchase of a Test Store product * Add file to Xcode workspace * WIP: implement fake purchase alert in all platforms and OSs * Enforce only one test purchases at once. Use constants for test purchase alert strings * Place new test store purchase APIs under the TEST_STORE compiler flag * fix lint * fix unit tests after change of internal APIs * PR comments * temporarily return hardcoded `CustomerInfo` on confirmed test purchase * tests: adapt unit tests to new `TestStorePurchaseHandler` dependency of `PurchasesOrchestrator` * fix lint * Fix backend integration tests compilation * Remove deprecation warning * remove unnecessary OSs checks Since the minimum supported versions of the SDK are iOS 13 and tvOS 13 * add `GetWebProductsOperation` * avoid duplicating decoding objects from WebOfferingProductsResponse and WebProductsResponse * add missing tests snapshots * Add `WebProductsResponse.ProductType` enum * Fix tests * add web products decoding tests * Rename WebProducts to WebBillingProducts * (more) rename WebProducts to WebBillingProducts * (even more) rename WebProducts to WebBillingProducts * Move `getWebBillingProducts` outside of `OfferingsAPI` into a new `WebBillingAPI` object * improve test * remove unnecessary `sorted()` of `Set` * fix lint * fix tests Since the GetWebBilling request path contains an unordered set of productIds, which the tests do not support, we're only doing snapshot tests with 1 product ID * fix more tests |
||
|
|
b7c98a0783 |
Rename internal WebProducts APIs to WebOfferingProducts (#5416)
* Rename existing WebProducts to WebOfferingProducts * fix lint * fix wrong file reference |
||
|
|
01a352d9e9 | Virtual Currency Support (#5108) | ||
|
|
39ad5519fd |
[DX-457] Re-apply Health SDK logging on app launch (#5360)
* Revert "Temporary revert of automatic health reporting in the SDK (#5353)"
This reverts commit
|
||
|
|
dd7086fd98 |
Temporary revert of automatic health reporting in the SDK (#5353)
* Revert "fix `Purchases` temporary leak when running SDK health check (#5350)" This reverts commit |
||
|
|
21f226de00 |
[DX-457] Log the SDK configuration report on every #DEBUG run (#5317)
* Creates a brand new SDK Manager to reuse logic across different classes * Updates to use the new manager * Adds a new method to log the health report to the console only for debug builds * Run health check for debug builds * Fixes sendable warnings that got introduced with new manager * Fixes swiftlint violations * Adds unit tests for the new SDK Health manager * Creates a new authorization provider * Injects the new authorization provider * Tidies and cleans up unit tests * Adds a new configuration value * Updates configuration unit tests * Makes sure that values are only set on DEBUG configuration * Reverts state of default value * Updates wording of output message * Fixes the wrong wording of error message * Logs the word RevenueCat along with report title * Fixes wording issues in error messages * Addresses PR comments * Adds extra checks * Renames configuration value * Removes unnecessary `Task` * Renames parameter * Calls the new endpoint in the BE to check if the app is available or not * Do not log or perform the report operations if it is not available * Missing xcodeproj changes * Adds unit test coverage * Turns validation on by default * Creates a new path for the report availability endpoint * We need to bypass auth but make sure that requests are still signed * Updates the name of the response field * Updates unit tests target with new response structure * Handles no credentials case more gracefully * Adds new unit tests for the new No ASC credentials warning * Updates the file's header comment * Adds documentation * Wraps calls in necessary compiler directives * Hide all report-related content behind compiler directives * Makes more health-related functionality DEBUG only * Addresses PR comments * Updates all unit test build failures * Gets it back to compile on `CUSTOM_ENTITLEMENT_COMPUTATION` * Removes configuration value * Updates logging to only include issues * Adds a mock method for the health report availability request |
||
|
|
46f2cd8c29 |
Change to use new endpoint to fetch web product info (#5135)
* Change to use new endpoint to fetch web product info * [skip ci] Generating new test snapshots (#5142) * [skip ci] Generating new test snapshots (#5141) * [skip ci] Generating new test snapshots (#5140) * [skip ci] Generating new test snapshots (#5139) * [skip ci] Generating new test snapshots (#5138) * [skip ci] Generating new test snapshots (#5137) * [skip ci] Generating new test snapshots (#5136) * Add small utility function to know if offerings has any web biling offering available --------- Co-authored-by: RevenueCat Git Bot <72824662+RCGitBot@users.noreply.github.com> |
||
|
|
c7edb46f31 |
Add endpoint for fetching web billing products (#5055)
* Add support for fetching web billing products * Some fixes * Escape product ids * Fixes from review * Support etags * Change to Int64 * Add method to MockOfferingsAPI |
||
|
|
e991e0708a |
Use fallback API hosts when receiving server down response (#4970)
* feat: implement fallback host in all URL requests * cleanup fallback host API implementation * Adapt existing tests to changes in `HTTPRequestPath` * fix implementation * add unit tests for fallback API host * add extra unit test * fix tests * fix lint * change the logic from fallback hosts to fallback paths * fix test * fix fallback endpoint for get product entitlement mapping * fix backend integration tests not building after changes * rewrite fallback host functionality knowing that only some specific requests support a fallback host For those requests that support a fallback host, the path, headers and response structure remain the same * fix text name |
||
|
|
47f40f5abe |
[DX-345] Update the testSDKHealth to use the new /health_report endpoint (#4979)
* Initial app creation * Initial screen * Installs and configures the SDK * Creates a full Swift 6 compliant ViewModel * Adds a demo customer center button * Fixes icon name * Updates a bit of the logic to fetch offerings * Updates initial layout by showing offerings * Makes more progress with a VERY DRAFT and VERY WIP screen * Creates a new network path and requests * Creates a new health API and adds it to the BE class * Creates a `checkOfferings` method * Pushes local changes * Moved viewmodels to separate files * Prepared some basic UI structure * Initial shell of the new method for testing * Initial implementation of `HealthReportOperation` from the SDK * Passes `appUserId` through to the internal API * Adds a new path called `appUserID` * Removes 'old' `appHealth` endpoint * Creates a new model for the network response * Report should be the response type * Updates backend request * Updates types and documentation for the new internal request * Moves validation into its own file * Replaces method for DebugViewModel * Updates error messages * Updates the `Status` section * Adds logic to show failure reason * Removes Sample App from PR * Resets `Package.resolved` * Availability checks * Check if device is authorized to make payments * Fixes all SwiftLint errors * Updates `ProductStatus` to not have a raw value of String * Minor style fixes * Removes warning * Adds more availability checks * Fixes comments Co-authored-by: Antonio Pallares <ajpallares@users.noreply.github.com> * Simplifies logic * Updates comment * Updates the comments to denote that this method is not intended for production use * Removes android-only invalid SDK version error * Adds an action button that the user can use to open the dashboard * Updates copy about non-actionable item * Prefers `Your RevenueCat Configuration` to `The Dashboard` * Removes `Sendable`-related warnings * Fixes unit tests on CI/CD * Fixes tests * Adds unit test for offering configuration error * Adds unit test for no packages in default offering * Adds unit test for generic offering configuration * Removes periods from the end of the error messages * Adds unit tests for all new errors * Fixes linter errors * Wrap in a `DEBUG` compiler directive * Includes all products in the healthy check status to be used in the Sample App * Updates report to include product and offering information * Moves logic over to the report rather than being exclusive to the Debug View * Fixes CI/CD failures * Updates the asset for the health check status --------- Co-authored-by: Hidde van der Ploeg <hiddevanderploeg@me.com> Co-authored-by: Antonio Pallares <ajpallares@users.noreply.github.com> |
||
|
|
6b5c430082 |
chore: Enable force_unwrapping for SwiftLint (#4820)
* enable force_unwrapping * avoid force unwrap * fixed all errors * remove extra disable |
||
|
|
98e4a33225 |
Support anonymous web purchase redemptions (#4439)
Co-authored-by: RevenueCat Git Bot <72824662+RCGitBot@users.noreply.github.com> Co-authored-by: andy boedo <andresboedo@gmail.com> Co-authored-by: Cesar de la Vega <cesarvegaro@gmail.com> |
||
|
|
dd0ee262ea |
[Customer Center] Initial implementation (#3967)
Alpha of the Customer Center. In this branch, it's been disabled behind a compilation flag. --------- Co-authored-by: Will Taylor <wtaylor151@gmail.com> Co-authored-by: James Borthwick <109382862+jamesrb1@users.noreply.github.com> Co-authored-by: RevenueCat Git Bot <72824662+RCGitBot@users.noreply.github.com> Co-authored-by: JayShortway <29483617+JayShortway@users.noreply.github.com> Co-authored-by: Toni Rico <toni.rico.diez@revenuecat.com> Co-authored-by: Toni Rico <antonio.rico.diez@revenuecat.com> Co-authored-by: Cody Kerns <44073103+codykerns@users.noreply.github.com> Co-authored-by: Andy Boedo <andresboedo@gmail.com> |
||
|
|
a956dbec71 |
Add name property to HTTPRequestPath (#3790)
This will be used for diagnostics |
||
|
|
03d93bb061 |
Add HTTPRequest.DiagnosticsPath (#3791)
Create DiagnosticsHTTPRequestPath for Diagnostics Depends on #3790 which adds the name |
||
|
|
5e968ad268 |
Paywalls: implemented PostPaywallEventsOperation (#3158)
This adds the operation + `PaywallEventsRequest` and associated tests. Also added method to `InternalAPI` for posting events. |
||
|
|
833524314d |
HTTPClient: extracted HTTPRequestPath protocol (#2986)
This paves the way to add a second set of paths with a separate server URL to be able to shed requests to offerings and product entitlement mapping to a separate server. ### Changes: - New `HTTPRequestPath` with the same properties as `HTTPRequest.Path` + a new `serverHostURL` - Moved proxy logic from `SystemInfo`/`HTTPClient` to `HTTPRequestPath` - Simplified `HTTPRequest` implementation |