Skip to content

Commit

Permalink
[release] 1.49.0 - Typed completion error and custom URLs (#317)
Browse files Browse the repository at this point in the history
## 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
andre-statsig authored Dec 10, 2024
1 parent eec3c0a commit af44eda
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Sources/Statsig/DeviceEnvironment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ struct DeviceEnvironment {

static internal let deviceOS = PlatformCompatibility.deviceInfo.os
static internal let sdkType: String = "ios-client"
static internal let sdkVersion: String = "1.48.1"
static internal let sdkVersion: String = "1.49.0"

let lock = NSLock()
var sessionID: String? { UUID().uuidString }
Expand Down
2 changes: 1 addition & 1 deletion Statsig.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |spec|

spec.name = "Statsig"
spec.version = "1.48.1"
spec.version = "1.49.0"
spec.summary = "Statsig enables developers to ship code faster and more safely."
spec.description = <<-DESC
Statsig enables developers to ship code faster and more safely by providing:
Expand Down

0 comments on commit af44eda

Please sign in to comment.