-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs: Update READMEs * docs: Update Provider README
- Loading branch information
1 parent
2c4ee11
commit c8437ac
Showing
2 changed files
with
26 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,11 +12,6 @@ Functionalities: | |
- Automatic data collection about which flags have been accessed by the application | ||
- Event tracking for instrumenting your application | ||
|
||
### Swift 6 support: strict concurrency | ||
|
||
If your app is using some of the features of Swift 6, we recommend setting the **Strict Concurrency Checking** to | ||
**Minimal**. | ||
|
||
## Dependency Setup | ||
|
||
### Swift Package Manager | ||
|
@@ -41,31 +36,34 @@ First, ensure you have your GitHub account added as an option (+ > Add Source Co | |
|
||
1. Add as a remote repository | ||
* Search for `[email protected]:spotify/confidence-sdk-swift.git` and click "Add Package" | ||
2. Clone the repository locally | ||
2. Clone the repository locally (only recommended if you are making changes to the SDK) | ||
* Clone locally using your preferred method | ||
* Use the "Add Local..." button to select the local folder | ||
|
||
**Note:** Option 2 is only recommended if you are making changes to the SDK. If working with the OpenFeature Provider, you will also need to add | ||
the relevant OpenFeature SDK dependency manually. | ||
### Swift 6 support | ||
|
||
If your app is using some of the features of Swift 6, we recommend setting the **Strict Concurrency Checking** to | ||
**Minimal**. | ||
|
||
### Creating the Confidence instance | ||
|
||
```swift | ||
import Confidence | ||
|
||
let confidence = Confidence.Builder(clientSecret: "mysecret").build() | ||
let confidence = Confidence.Builder(clientSecret: "mysecret", loggerLevel: .NONE).build() | ||
await confidence.fetchAndActivate() | ||
``` | ||
|
||
The client secret for your application can be generated in the Confidence portal. | ||
- The `clientSecret` for your application can be generated in the Confidence portal. | ||
- The `loggerLevel` sets the verbosity level for logging to console. This can be useful while testing your integration with the Confidence SDK. | ||
|
||
_Note: the Confidence SDK has been intended to work as a single instance in your Application. | ||
Creating multiple instances in the same runtime could lead to unexpected behaviours._ | ||
|
||
### Initialization strategy | ||
|
||
`confidence.activateAndFetch()` is an async function that fetches the flags from the Confidence backend, | ||
stores the result on disk, and make the same data ready for theApplication to be consumed. | ||
stores the result on disk, and make the same data ready for the Application to be consumed. | ||
|
||
The alternative option is to call `confidence.activate()`: this loads previously fetched flags data | ||
from storage and makes that available for the Application to consume right away. | ||
|
@@ -77,19 +75,19 @@ The context is a key-value map used for sampling and for targeting, when flag ar | |
It is also appended to the tracked events, making it a great way to create dimensions for metrics in Confidence. | ||
|
||
```swift | ||
confidence.putContext(context: ["key": ConfidenceValue(string: "value")]) // this will mutate the context of the current Confidence instance | ||
confidence.putContext(context: ["key": ConfidenceValue(string: "value")]) | ||
``` | ||
|
||
Note that a `ConfidenceValue` is accepted a map values, which has a constructor for all the value types | ||
supported by Confidence. | ||
|
||
### Resolving feature flags | ||
Once the flags are **activated**, you can access their value using the `getValue` method or the `getEvaluation` method. | ||
Both methods use generics to return a type defined by the default value type. | ||
Once the Confidence instance is **activated**, you can access the flag values using the | ||
`getValue` method or the `getEvaluation` functions. | ||
Both functions use generics to return a type defined by the default value type. | ||
|
||
The method `getEvaluation` returns an `Evaluation` object that contains the `value` of the flag, the `reason` | ||
for the value returned, and the `variant` selected. | ||
|
||
for the value returned and the `variant` selected. | ||
|
||
The method `getValue` will simply return the assigned value or the default. | ||
In the case of an error, the default value will be returned and the `Evaluation` contains information about the error. | ||
|
@@ -113,19 +111,11 @@ The SDK takes care of storing events in case of offline and retries in case of t | |
Note that the data struct can't contain the key `context`, as that is reserved for entries set via `putContext` (see below): | ||
violating this rule will cause the track function to throw an error. | ||
|
||
To set context data to be appended to all tracked events, here as example: | ||
To set context data to be appended to all tracked events, here is an example: | ||
```swift | ||
confidence.putContext(context: ["os_version": ConfidenceValue(string: "17.0")]) | ||
``` | ||
|
||
### Logging | ||
By default, the Confidence SDK will log errors and warnings locally to the console. You can change the preferred log level by passing a `loggerLevel` to the `Confidence.Builder` constructor. | ||
|
||
To turn off logging completely, you can pass `LoggingLevel.NONE` to the `Confidence.Builder`. | ||
|
||
# OpenFeature Provider | ||
If you want to use OpenFeature, an OpenFeature Provider for the [OpenFeature SDK](https://github.com/open-feature/kotlin-swift) is also available. | ||
|
||
## Usage | ||
|
||
If you want to use OpenFeature, an OpenFeature Provider for the [OpenFeature SDK](https://github.com/open-feature/kotlin-sdk) is also available. | ||
See the [dedicated Provider Readme](https://github.com/spotify/confidence-sdk-swift/tree/main/Sources/ConfidenceProvider). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters