Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update sdk section #49

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 107 additions & 8 deletions docs/sdk/client-side/android/index.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
---
title: Android reference
title: Android
slug: /sdk/client-side/android
toc_max_heading_level: 4
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

This category contains topics explaining how to configure Bucketeer's Android SDK.

:::tip Android SDK Version (Stable)

Bucketeer Android SDK has reached the production stage, offering you a stable and reliable experience.

:::

:::info Compatibility

The Bucketeer SDK is compatible with Android SDK versions 21 and higher (Android 5.0, Lollipop).
Expand Down Expand Up @@ -110,23 +117,25 @@ val client = BKTClient.getInstance()
</TabItem>
</Tabs>

:::note
:::info Default timeout

The initialize process immediately starts polling the latest evaluations from Bucketeer in the background using the interval `pollingInterval` configuration while the application is in the **foreground state**.
When the application changes to the **background state**, it will use the `backgroundPollingInterval` configuration.
By default, Bucketeer SDK will uses a 30s timeout to fetch data from the server.
htessaro marked this conversation as resolved.
Show resolved Hide resolved

:::

If you want to use the feature flag on Splash or Main views, and the user opens your application for the first time, it may not have enough time to fetch the variations from the Bucketeer server.
If you want to use the feature flag on Splash or Main views, and the user opens your application for the first time, it may not have enough time to fetch the variations from the Bucketeer server. In this case, we recommend using the `Future<BKTException?>` returned from the initialize method. In addition, you can define a custom timeout.
htessaro marked this conversation as resolved.
Show resolved Hide resolved

For this case, we recommend using the `Future<BKTException?>` returned from the initialize method.
:::caution Initialization Timeout error

:::note
During the initialization process, errors **are not** related to the initialization itself. Instead, they arise from timeout overflows, indicating the data variations from the server weren't received. It's important to note that the initialization process proceeds as usual, even if such errors occur. Therefore, receiving an error message does not indicate a failure in the initialization process itself.
htessaro marked this conversation as resolved.
Show resolved Hide resolved

Be aware that if an error is returned in the initialize process, it is regarding the fetch evaluation timeout error, not the initialize process itself.
Even if a timeout error occurs and the SDK fails to fetch data variations during the initialization, the [polling](android#polling) feature will attempt to retrieve variation data from the server at regular intervals.
htessaro marked this conversation as resolved.
Show resolved Hide resolved

:::

The following code block illustrates implementing `Future<BKTException?>`` along with timeout functionality. In the event of a timeout error, you can present the off variation content to your users or use any other strategy to handle the error when there is no cache or the cache is not updated.
htessaro marked this conversation as resolved.
Show resolved Hide resolved
Otherwise, if the system receives the variation data before the timeout overflow, you can provide the appropriate content to users based on the flag retrieved from the server.
htessaro marked this conversation as resolved.
Show resolved Hide resolved

<Tabs>
<TabItem value="kt" label="Kotlin">

Expand Down Expand Up @@ -158,6 +167,96 @@ viewLifecycleOwner.lifecycleScope.launch {
</TabItem>
</Tabs>

#### Polling

The initialize process immediately starts polling the latest evaluations from Bucketeer in the background using the interval `pollingInterval` configuration while the application is in the **foreground state**.
htessaro marked this conversation as resolved.
Show resolved Hide resolved
When the application changes to the **background state**, it will use the `backgroundPollingInterval` configuration.

#### Polling retry behavior

The Bucketeer SDK regularly polls the latest evaluations from Buckteer based on the pollingInterval parameter. By default, the `pollingInterval` is set to 10 minutes, but you can adjust it to suit your needs.
htessaro marked this conversation as resolved.
Show resolved Hide resolved

If a polling request fails, the SDK initiates a retry procedure. The SDK attempts a new polling request every minute up to 5 times. If all five retry attempts fail, the SDK sends a new polling request once the `pollingInterval` time elapses. The table below illustrates this scenario:
htessaro marked this conversation as resolved.
Show resolved Hide resolved

<div className="center-table">
<table>
<thead>
<tr>
<th>Polling Time</th>
<th>Retry Time</th>
<th>Request Status</th>
</tr>
</thead>
<tbody>
<tr>
<td>10:00</td>
<td>-</td>
<td>Fail</td>
</tr>
<tr>
<td>- </td>
<td>10:01</td>
<td>Fail</td>
</tr>
<tr>
<td>- </td>
<td>10:02</td>
<td>Fail</td>
</tr>
<tr>
<td>- </td>
<td>10:03</td>
<td>Fail</td>
</tr>
<tr>
<td>-</td>
<td>10:04</td>
<td>Fail</td>
</tr>
<tr>
<td>-</td>
<td>10:05</td>
<td>Fail</td>
</tr>
<tr>
<td>10:10</td>
<td>-</td>
<td>Successful</td>
</tr>
</tbody>
</table>
</div>

The polling counter, which uses the `pollingInterval` information, resets in case of a successful retry. The table below exemplifies the described scenario.
htessaro marked this conversation as resolved.
Show resolved Hide resolved
<div className="center-table">
<table>
<thead>
<tr>
<th>Polling Time</th>
<th>Retry Time</th>
<th>Request status</th>
</tr>
</thead>
<tbody>
<tr>
<td>10:00</td>
<td>-</td>
<td>Fail</td>
</tr>
<tr>
<td>- </td>
<td>10:01</td>
<td>Successful</td>
</tr>
<tr>
<td>10:11</td>
<td>-</td>
<td>Successful</td>
</tr>
</tbody>
</table>
</div>

## Supported features

### Evaluating user
Expand Down
132 changes: 124 additions & 8 deletions docs/sdk/client-side/flutter/index.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
---
title: Flutter reference
title: Flutter (Beta)
htessaro marked this conversation as resolved.
Show resolved Hide resolved
slug: /sdk/client-side/flutter
toc_max_heading_level: 4
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

This category contains topics explaining how to configure Bucketeer's Flutter SDK.

:::caution Flutter SDK Version (Beta)
cre8ivejp marked this conversation as resolved.
Show resolved Hide resolved

The Bucketeer Flutter is currently in its Beta stage.

If you encounter any issues or have suggestions for improvement, [contact Bucketeer team](https://app.slack.com/client/T08PSQ7BQ/C043026BME1).

:::

## Getting started

Before starting, ensure that you follow the [Getting Started](/getting-started) guide.
Expand Down Expand Up @@ -105,30 +114,137 @@ final client = BKTClient.instance;
</TabItem>
</Tabs>

:::note
:::info Default timeout

The initialize process immediately starts polling the latest evaluations from Bucketeer in the background using the interval `pollingInterval` configuration while the application is in the **foreground state**. When the application changes to the **background state**, it will use the `backgroundPollingInterval` configuration.
By default, Bucketeer SDK will uses a 30s timeout to fetch data from the server.

:::

If you want to use the feature flag on Splash or Main views, and the user opens your application for the first time, it may not have enough time to fetch the variations from the Bucketeer server.
If you want to use the feature flag on Splash or Main views, and the user opens your application for the first time, it may not have enough time to fetch the variations from the Bucketeer server. For this case, we recommend using the `timeout` option in the initialize method. It will block until the SDK receives the latest user variations.

For this case, we recommend using the `timeout` option in the initialize method. It will block until the SDK receives the latest user variations.
:::caution Initialization Timeout error

During the initialization process, errors **are not** related to the initialization itself. Instead, they arise from timeout overflows, indicating the data variations from the server weren't received. It's important to note that the initialization process proceeds as usual, even if such errors occur. Therefore, receiving an error message does not indicate a failure in the initialization process itself.

Even if a timeout error occurs and the SDK fails to fetch data variations during the initialization, the [polling](flutter#polling) feature will attempt to retrieve variation data from the server at regular intervals.

:::

The following code block illustrates how to use the timeout functionality. In the event of a timeout error, you can present the off variation content to your users or use any other strategy to handle the error when there is no cache or the cache is not updated.
Otherwise, if the system receives the variation data before the timeout overflow, you can provide the appropriate content to users based on the flag retrieved from the server.

<Tabs>
<TabItem value="dart" label="Dart">

```dart showLineNumbers
/// It will unlock without waiting until the fetching variation process finishes
int timeout = 1000;
int timeout = 5000;

await BKTClient.initialize(config: config, user: user, timeoutMillis: timeout);
final client = BKTClient.instance;
if (result.isSuccess) {
htessaro marked this conversation as resolved.
Show resolved Hide resolved
final client = BKTClient.instance;
if (showNewFeature) {
/// The Application code to show the new feature
} else {
/// The code to run if the feature is off
}
} else {
/// Handle the error when there is no cache or the cache is not updated
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cre8ivejp, the original code didn't use a conditional to treat timeout errors. I tried to adapt the code from the update section. However, I don't know if it's correct.

```

</TabItem>
</Tabs>

#### Polling

The initialize process immediately starts polling the latest evaluations from Bucketeer in the background using the interval `pollingInterval` configuration while the application is in the **foreground state**. When the application changes to the **background state**, it will use the `backgroundPollingInterval` configuration.

#### Polling retry behavior

The Bucketeer SDK regularly polls the latest evaluations from Buckteer based on the pollingInterval parameter. By default, the `pollingInterval` is set to 10 minutes, but you can adjust it to suit your needs.

If a polling request fails, the SDK initiates a retry procedure. The SDK attempts a new polling request every minute up to 5 times. If all five retry attempts fail, the SDK sends a new polling request once the `pollingInterval` time elapses. The table below illustrates this scenario:

<div className="center-table">
<table>
<thead>
<tr>
<th>Polling Time</th>
<th>Retry Time</th>
<th>Request Status</th>
</tr>
</thead>
<tbody>
<tr>
<td>10:00</td>
<td>-</td>
<td>Fail</td>
</tr>
<tr>
<td>- </td>
<td>10:01</td>
<td>Fail</td>
</tr>
<tr>
<td>- </td>
<td>10:02</td>
<td>Fail</td>
</tr>
<tr>
<td>- </td>
<td>10:03</td>
<td>Fail</td>
</tr>
<tr>
<td>-</td>
<td>10:04</td>
<td>Fail</td>
</tr>
<tr>
<td>-</td>
<td>10:05</td>
<td>Fail</td>
</tr>
<tr>
<td>10:10</td>
<td>-</td>
<td>Successful</td>
</tr>
</tbody>
</table>
</div>

The polling counter, which uses the `pollingInterval` information, resets in case of a successful retry. The table below exemplifies the described scenario.
<div className="center-table">
<table>
<thead>
<tr>
<th>Polling Time</th>
<th>Retry Time</th>
<th>Request status</th>
</tr>
</thead>
<tbody>
<tr>
<td>10:00</td>
<td>-</td>
<td>Fail</td>
</tr>
<tr>
<td>- </td>
<td>10:01</td>
<td>Successful</td>
</tr>
<tr>
<td>10:11</td>
<td>-</td>
<td>Successful</td>
</tr>
</tbody>
</table>
</div>

## Supported features

### Evaluating user
Expand Down Expand Up @@ -203,7 +319,7 @@ if (result.isSuccess) {
/// The code to run if the feature is off
}
} else {
/// The code to run if the feature is off
/// Handle the error when there is no cache or the cache is not updated
}
```

Expand Down
Loading