Commit Graph
122 Commits
Author SHA1 Message Date
Jacob Rakidzich c688108f44 UserDefaults Crash Fix (#5917)
* First pass–replace user defaults with file cache

* update tests and encoding mechanism

* Start on tests

* Wrap up tests

* clear for large item cache

* Migrate to a version of the cache that allows lookup by key instead of by index

* Mock cache is not used in this file, update it to the tailor made one just in case it's needed later
2025-12-22 12:21:21 +01:00
RickandRevenueCat Git Bot 94ac735467 Track connection_error_reason property in diagnostics for HTTP errors (#5860)
* 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

* Implemented tracking ConnectionErrorReason using DiagnosticsTracker on HTTP errors

* Add new file to workspace

* Updated string value of ConnectionErrorReason cases to match Android implementation

* [skip ci] Generating new test snapshots (#5868)

* [skip ci] Generating new test snapshots (#5869)

* [skip ci] Generating new test snapshots (#5870)

* [skip ci] Generating new test snapshots (#5871)

* [skip ci] Generating new test snapshots (#5872)

* [skip ci] Generating new test snapshots (#5874)

* [skip ci] Generating new test snapshots (#5873)

* Updated the list of URLError.code's that we consider a network error

---------

Co-authored-by: RevenueCat Git Bot <72824662+RCGitBot@users.noreply.github.com>
2025-11-26 13:51:54 +01:00
Rick 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
2025-11-26 11:16:04 +01:00
Rosie Watson 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
2025-11-19 08:26:43 +00:00
d11c054407 Use cached offerings on network errors (#5707)
* Use offerings cache on (most) network errors

* Add unit tests for `NetworkError`'s `shouldFallBackToCachedOfferings`

* Add unit tests for `shouldFallBackToCachedOfferings`

* Fix lint

* Add some more unit tests

* Add `isLoadShedderResponse` and `isFallbackURLResponse` properties to `VerifiedHTTPResponse`

Keeps the values also when returned by the ETagManager

* lint

* Add some tests for ETagManager

* Rename `isFallbackURLResponse` to `isFallbackUrlResponse` to prevent decoding issues

* Add tests for actual source of original cached response of ETagManager

* Add tests to HTTPClientTests regarding the new booleans

* lint

* Add `originalSource` to `CustomerInfo`

* Adds `isLoadedFromCache` boolean to CustomerInfo

* Add docs

* Unit tests for new customer info properties

* Make `OriginalSource.CustomerInfo` a `String` enum

* Add decoding tests for Customer Info with new original source field

* Add `.loadShedder` check for Customer Info obtained in Load Shedder integration tests

* Update fixture

* improve internal docs

* Add intermediate object `Offerings.Contents` to wrap `OfferingsResponse` + `OriginalSource` and `loadedFromCache`

* Adapt existing unit tests to changes in `Offerings` underlying objects

* Check Offerings original source in existing integration tests

* Fix StoreKit unit tests

* Fix RevenueCatUI tests

* More Offerings.Contents tests

* Fix test

* Add more tests

* Fix lint

* [skip ci] Generating new test snapshots (#5741)

* [skip ci] Generating new test snapshots (#5742)

* [skip ci] Generating new test snapshots (#5743)

* [skip ci] Generating new test snapshots (#5744)

* [skip ci] Generating new test snapshots (#5745)

* [skip ci] Generating new test snapshots (#5746)

* [skip ci] Generating new test snapshots (#5747)

* [skip ci] Generating new test snapshots (#5748)

* Use enum for `HTTPResponseSource`

* Update tests

* Adapt to changes in `VerifiedHTTPResponse`

* Lint

* Adapt to changes in `VerifiedHTTPResponse`

* update tests

* Add log when a request to the fallback URL was handled by load shedder (which should never happen)

* rename `HTTPResponseSource` to `HTTPResponseOriginalSource`

* Adapt to changes

* fix lint

* Adapt to changes

* Fix CustomerInfo's OriginalSource implementation + fix unit test

* Fix tests compilation

* Add Cached offerings integration test

* Fix RCUI compilation

* Move isFromCache boolean from `Offerings.Contents` to `Offerings`

* Expand `ForceServerErrorStrategy` functionality

* Improve log when faking error response

* Correct implementation of fake error response without making a request (ForceServerErrorStrategy)

* Update tests + more tests

* Fix compilation of `OfferingsManagerTests`

* Fix compilation of `DebugViewSwiftUITests`

* Improve tests

* Fix `OfflineWithNoMappingStoreKitIntegrationTests`

* FIx compilation

---------

Co-authored-by: Toni Rico <toni.rico.diez@revenuecat.com>
Co-authored-by: RevenueCat Git Bot <72824662+RCGitBot@users.noreply.github.com>
2025-11-07 10:22:16 +00:00
Antonio Pallares eaee0c3592 Fix signature verification fallback urls (#5756)
* Fix signature verification for fallback URLs

* Add tests for signing with fallback path

* Lint

* Add log
2025-11-06 22:43:27 +01:00
Antonio Pallares 6335078c13 Add backend source to VerifiedHTTPResponse (#5736)
* Add `isLoadShedderResponse` and `isFallbackURLResponse` properties to `VerifiedHTTPResponse`

Keeps the values also when returned by the ETagManager

* lint

* Add some tests for ETagManager

* Rename `isFallbackURLResponse` to `isFallbackUrlResponse` to prevent decoding issues

* Add tests for actual source of original cached response of ETagManager

* Add tests to HTTPClientTests regarding the new booleans

* lint

* Use enum for `HTTPResponseSource`

* Update tests

* Add log when a request to the fallback URL was handled by load shedder (which should never happen)

* rename `HTTPResponseSource` to `HTTPResponseOriginalSource`

* fix lint
2025-11-04 20:17:33 +01:00
Rick 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
2025-11-04 13:35:20 +01:00
Pol Miro 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.
2025-10-30 14:52:35 +01:00
Antonio Pallares 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
2025-10-29 18:43:19 +01:00
Pol MiroandClaude 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>
2025-10-29 11:56:48 +01:00
Rick fae90a3da9 Allowing HTTP requests to be retried with fallback host after netwok / DNS errors as well as 5xx errors (#5703)
* Allowing HTTP requests to be retried with fallback host after network / DNS errors as well as 5xx errors

* Fixed linting issues

* Linting
2025-10-24 15:06:04 +02:00
Antonio Pallares 36daf56d20 Add infrastructure to enable richer server down integration tests (#5700)
* Add infrastructure to enable richer server down integration tests

* Fix lint

* Fix compilation and add tests for ForceServerErrorsStrategy

* Fix lint

* Fix compilation

* Fix compilation of Integration tests

* Fix tests now that server errors are not simulated locally

* Fix import

* Temp: all integration tests enabled

* rename

* Improve log message

* Revert "Temp: all integration tests enabled"

This reverts commit fd0316f267.

* Add `failExceptFallbackUrls` `ForceServerErrorStrategy`
2025-10-24 10:03:39 +02:00
Jacob Rakidzich 04bc10266b Finalize video component to include a checksum, dark mode support, and optimize memory usage for large file downloads (#5631)
* Checksum and tests

* add checksum to video component models

* Update cache warming

* put the checksum in the right spot and update the view model

* File repo updates

* add missing assertion

* revert accidental trailiing comma

* Checksum from file

* Ensure cache invalidates when the checksum changes

* Use checksum as filename if available

* greedily fill space while loading occurs

* update remote image usage of the repository

* Reduce memory footprint of large file downloads by streaming the download to a temp file

* Update keyed deferred value storage key to include checksum

* remove unused argument

* remove wip comment

* Get tests to compile

* Write tests for the large item cache type

* remove test from the file repository suite

* trailing commas

* remove cache warming of videos

* remove un-needed change causing existential types

* delete the temporary file after success or failure of the code block

* log with the checksums

* optimize checksum generation to occur at the same time as the temp file storage

* starting to work on border gradients,

* Revert "starting to work on border gradients,"

This reverts commit 429e6d2fab.

* clarity regarding dark mode urls
2025-10-14 08:05:01 -05:00
Jacob Rakidzich f730d9df52 Create File Repository for use in upcoming feature work (#5477)
* Pull files from staging branch to introduce a file repository and intelligent task sharing

* removed typed throws and fix some docs

* Make tests satisfy predictive swift 6 failures

* @_spi(Internal) public

* Stop using the shared instance in an instance method

* Pull cache directory logic out of file repository

* update cache naming conventions

* @fire-at-will feedback -> use url instead of path

* Use strings file pattern

* remove priority from repository

* Remove RC Internal access from keyed deferred value store

* Remove spi internal from cache and network service

* makeSUT -> makeSystemUnderTest

* remove public scope in extensions

* rename function for clarity
2025-08-21 05:41:52 -05:00
Antonio Pallares 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
2025-07-29 18:31:15 +02:00
Antonio Pallares b7c98a0783 Rename internal WebProducts APIs to WebOfferingProducts (#5416)
* Rename existing WebProducts to WebOfferingProducts

* fix lint

* fix wrong file reference
2025-07-23 13:56:20 +02:00
Will Taylor 01a352d9e9 Virtual Currency Support (#5108) 2025-07-07 12:11:27 -05:00
Pol Piella Abadia 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.

* Do not run health check when running integration tests
2025-07-07 17:00:54 +01:00
Pol Piella Abadia 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 26de54308c.

* Revert "[DX-457] Log the SDK configuration report on every `#DEBUG` run (#5317)"

This reverts commit 21f226de00.
2025-07-03 13:22:47 +01:00
Pol Piella Abadia 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
2025-07-02 14:00:48 +01:00
Antonio Pallares f120cb26cc Preferred locale override (#5288)
* Add new public APIs to RevenueCatUI to set the preferred local for the UI components

* fix compliation of RevenueCatUI with new APIs

* add API tests

* implement preferred locale in paywalls

* complete implementation

* adapt unit tests

* adapt paywalls tester

* Add new tests to check preferred locale override

* fix lint

* discard all changes in RevenueCatUI (for separate PR)

* remove trailing comma

* fix tests

* Fix tests

* fix paywalls tester compilation

* remove spoiler from future PR

* Refactor `PreferredLocalesProvider` (#5299)

* refactor: reduce `PreferredLocalesProviderType` into `PreferredLocalesProvider` class

* make `preferredLocaleOverride` private in `PreferredLocalesProvider`

* make `SystemInfo`'s `preferredLocalesProvider` private

* rename `PreferredLocalesProvider`'s mock init parameters

* fix compilation issue
2025-06-30 16:28:32 +02:00
Toni RicoandRevenueCat Git Bot 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>
2025-05-21 13:37:56 +02:00
Toni Rico 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
2025-05-06 23:28:59 +02:00
Antonio Pallares e0c94708be [Diagnostics] add host parameter to http_request_performed event (#4982)
* 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

* implement new `host` parameter in `http_request_performed` diagnostics event

* add unit tests for new `host` diagnostics parameter

* 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

* fix unit test

* remove extra comma

* fix unit test
2025-04-25 17:05:33 +00:00
Antonio Pallares 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
2025-04-25 12:00:13 +00:00
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>
2025-04-24 13:46:21 +00:00
Toni RicoandRevenueCat Git Bot 868f848bae Add X-Is-Backgrounded header (#4938)
* Add X-Is-Backgrounded header

* Add unit test for presence of new header

* [skip ci] Generating new test snapshots (#4939)

* [skip ci] Generating new test snapshots (#4940)

* [skip ci] Generating new test snapshots (#4941)

* [skip ci] Generating new test snapshots (#4942)

* [skip ci] Generating new test snapshots (#4943)

* [skip ci] Generating new test snapshots (#4944)

* [skip ci] Generating new test snapshots (#4945)

* Lock isAppBackgrounded state to false during tests

* one more update

* Revert "Lock isAppBackgrounded state to false during tests"

This reverts commit 6a915a756a.

* Lock isAppBackgrounded state to false during tests

* Update tests

* Fix iOS 15 snapshot tests

* Remove unused isApplicationBackgrounded async method

---------

Co-authored-by: RevenueCat Git Bot <72824662+RCGitBot@users.noreply.github.com>
2025-04-03 10:37:02 +02:00
Antonio Pallares b0292f2ee7 [Diagnostics] add missing parameter to http_request_performed event (#4857)
* refactor: create `DiagnosticsEvent.Properties` struct with all possible fields in a diagnostics event

* chore: remove unnecessary `CodingKeys` and values as `JSONEncoder.KeyEncodingStrategy.convertToSnakeCase` is used in the diagnostics requests

* tests: WIP: adapt unit tests to new `DiagnosticsEvent.Properties`

* fix: have values in Diagnostics events be snake case

* tests: adapt unit tests to Diagnostics events changes

* fix: `name` parameter in DiagnosticsEvent

* tests: fix snapshot testing of JSON to use `.iso8601` date format

* tests: have `JSONEncoder` of snapshot tests be a copy of the encoder user in the SDK

* tests: update the dates in the `CustomerInfo` snapshots for decoding tests to have ISO 8601 format

* fix: remove duplicated import

* refactor: centralize some info transformations in `DiagnosticsEvent.Properties`' init

* tests: add snapshot tests for `DiagnosticsEvents` object

* feat: add `is_retry` parameter to Diagnostics `http_request_performed` event

* tests: consider new `isRetry` parameter in existing `DiagnosticsEvent` tests

* fix: make sure that the `http_request_performed` event is always called

The previous implementation would skip sending the event in the case of getting a `networkError`
2025-03-07 11:26:32 +01:00
Facundo Menzella 6b5c430082 chore: Enable force_unwrapping for SwiftLint (#4820)
* enable force_unwrapping

* avoid force unwrap

* fixed all errors

* remove extra disable
2025-02-26 12:40:49 +01:00
Antonio Pallares 25d1507411 UI Preview Mode: add extra header to network requests (#4752)
* feat: add new header to network requests when in UI preview mode

* test: add unit tests for header in network requests when in UI Preview mode
2025-01-31 12:33:19 +01:00
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>
2024-11-25 16:14:32 +01:00
JayShortway 57766ce7a2 Adds X-Is-Debug-Build header (#4364) 2024-10-10 17:00:03 +02:00
Toni Rico 4503a837e6 [Diagnostics] Refactor diagnostics track methods to handle background work automatically (#4270)
* Refactor diagnostics track methods to handle background work automaticaly

* fix swiftlint
2024-09-26 16:33:28 +02:00
Toni RicoandRevenueCat Git Bot fe181bd5e9 Add kochava integration (#4274)
* Reapply "Add `$kochavaDeviceId` attribution convenience method (#4238)" (#4265)

This reverts commit f2ce4416da.

* Add userAgent tracking for attribution networks

* Fix tests

* Add X-Platform-Device header

* Rename user agent to device version

* Use correct attribution method

* [skip ci] Generating new test snapshots (#4278)

* [skip ci] Generating new test snapshots (#4279)

* [skip ci] Generating new test snapshots (#4280)

* [skip ci] Generating new test snapshots (#4281)

* [skip ci] Generating new test snapshots (#4282)

* [skip ci] Generating new test snapshots (#4283)

* Generating new test snapshots (#4284)

* Fix ttests

---------

Co-authored-by: RevenueCat Git Bot <72824662+RCGitBot@users.noreply.github.com>
2024-09-25 19:59:36 +02:00
Toni Rico 597af5f215 [Diagnostics] Add backend_error_code property (#4236)
<!-- Thank you for contributing to Purchases! Before pressing the
"Create Pull Request" button, please provide the following: -->

### Checklist
- [ ] If applicable, unit tests
- [ ] If applicable, create follow-up issues for `purchases-android` and
hybrids

### Motivation
<!-- Why is this change required? What problem does it solve? -->
<!-- Please link to issues following this format: Resolves #999999 -->

### Description
This adds the `backend_error_code` property to diagnostics
`http_request_performed` events.
2024-09-04 09:03:34 +02:00
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>
2024-08-09 15:26:55 +02:00
Will Taylor 348258a41f only retry post receipt for 429 status codes 2024-07-25 16:46:31 -05:00
Will Taylor a4055375f6 retry requests with HTTP status 429 2024-07-23 12:41:16 -05:00
Cesar de la Vega 29250a4f11 Add X-Preferred-Locales header (#4008)
Added a new `X-Supported-Locales` header to be used in the new customer
center feature
2024-07-02 17:32:50 +02:00
NachoSoto 2bcd0ce328 5.0.0 changes: support SK2 by default 2024-07-01 14:37:21 -05:00
Josh Holtz c6e185ff07 Only install swiftlint on Xcode 15 jobs (#3913)
### Motivation

Better implementation of
https://github.com/RevenueCat/purchases-ios/pull/3909 and what was just
commited to `5.0-dev`

### Description

- Only install `swiftlint` on Xcode 15.3 jobs
- Also moved Ruby 3.2.2 install into `install-bundle-dependencies` which
was also done in `5.0-dev`
2024-05-18 08:21:02 -05:00
Toni Rico bb8066d9b3 Add http_request_performed diagnostics event (#3897)
### Description
This adds a new diagnostics event `http_request_performed` with some
useful information we would like to track about the http requests
performed to our servers.
2024-05-16 15:13:40 +02:00
Cesar de la Vega becc15243b Add origin to HTTPResponseType (#3793)
This is needed for Diagnostics
2024-04-10 13:38:15 +02:00
Cesar de la Vega a956dbec71 Add name property to HTTPRequestPath (#3790)
This will be used for diagnostics
2024-04-10 13:06:05 +02:00
Cesar de la Vega 03d93bb061 Add HTTPRequest.DiagnosticsPath (#3791)
Create DiagnosticsHTTPRequestPath for Diagnostics

Depends on #3790 which adds the name
2024-04-10 13:00:48 +02:00
NachoSoto 1cea9978aa Trusted Entitlements: tests for signature verification without header hash (#3505)
Follow up to #3424. This adds coverage to ensure that the backend
continues to sign correctly for old SDK versions that don't support
this.
2023-12-21 12:47:34 -08:00
NachoSoto fb76e662e8 Trusted Entitlements: add support for signing request headers (#3424)
This adds support for including arbitrary headers in the signature
verification, therefore preventing tampering of them.
2023-12-21 11:53:10 -08:00
NachoSoto e31a531ca1 HTTPClient: test all request headers (#3425)
This allows us to verify exactly what headers are included in all
requests.

It also simplifies the implementation for #3424.
2023-11-17 12:19:49 -08:00
Josh HoltzandNachoSoto 7d78633fd8 Adds X-Storefront request header for App Store Storefront (#3405)
### Motivation

Allow backend to determine Storefront of customer

### Description

- Adds `X-Storefront` as a default header
- Uses `StoreKit 1` implementation since its not `async`
- `StoreKit 2` implementation is `async` and would require a some
restructuring that we don't need right now

---------

Co-authored-by: NachoSoto <ignaciosoto90@gmail.com>
2023-11-14 14:04:07 -08:00