Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release] 1.49.0 - Typed completion error and custom URLs (#317)
## New Features #### Typed callback errors `Statsig.start` would call completion with an error string. We deprecated it in favor of `Statsig.initialize`. It improves error handling by calling completion with a `StatsigClientError`. ```swift // New initializer Statsig.initialize(sdkKey: "...") { (error: StatsigClientError?) in if let error = error { print(error.message) // Use error.code and error.cause to get more information on the error } } // Previous initializer (now deprecated) Statsig.start(sdkKey: "...") { (error: String?) in if let error = error { print(error) } } ``` Here's the interface for `StatsigClientError`: ```swift public class StatsigClientError { public let code: StatsigClientErrorCode public let message: String public let cause: (any Error)? } ``` And here's how to handle the different `StatsigClientErrorCode` error codes: ```swift switch error.code { case .alreadyStarted: case .invalidClientSDKKey: case .initTimeoutExpired: case .clientUnstarted: case .failedToFetchValues: } ``` #### Custom URLs Endpoints for initialization and event logging could customized, but the SDK ignored the path from those URLs. To avoid breaking the existing behavior, we added two new options that overwrite the full URL: `initializationURL` and `eventLoggingURL`. ```swift // New option Statsig.initialize(sdkKey: "...", options: StatsigOptions(initializationURL: URL(string: "https://example.com/setup"))) // Sends a request to https://example.com/setup // Existing option Statsig.initialize(sdkKey: "...", options: StatsigOptions(api: "https://example.com")) // Sends a request to https://example.com/v1/initialize // Doesn't support path customization ``` ## Improvements #### More data on exposure events - rule passed for dynamic configs >Included In This Release >- eec3c0a andre-statsig > - Change StatsigClientError parent class from LocalizedError to Error (#315) >- 7477f7f andre-statsig > - Rename Url to URL (#314) >- 1decf36 andre-statsig > - Update tests (#316) >- 00a0ef7 andre-statsig > - Add passed field to exposures (#313) >- 2cbe6fb andre-statsig > - Reduce warnings (#312) >- 44e206a andre-statsig > - Support path components on custom URLs (#310) >- 21e5cbb andre-statsig > - Fix sample app (#311) >- e8162f0 andre-statsig > - Create separate methods that receive an error object (#308)
- Loading branch information