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 11 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
112 changes: 103 additions & 9 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,20 +117,17 @@ 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.
The initialize process default timeout is 5 seconds.

:::

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, the SDK cache may be old or not exist and 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.

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

:::note

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.
During the initialization process, errors **are not** related to the initialization itself. Instead, they arise from a timeout request, indicating the variations data from the server weren't received. Therefore, the SDK will work as usual and update the variations in the next [polling](android#polling) request.

:::

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

#### Polling

The initialize process immediately starts polling the latest evaluations from the Bucketeer server 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 the server 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 shows 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 shows 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
128 changes: 120 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,133 @@ 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.
The initialize process default timeout is 5 seconds.

:::

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, the SDK cache may be old or not exist and 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.
htessaro marked this conversation as resolved.
Show resolved Hide resolved

:::caution Initialization Timeout error

For this case, we recommend using the `timeout` option in the initialize method. It will block until the SDK receives the latest user variations.
During the initialization process, errors **are not** related to the initialization itself. Instead, they arise from a timeout request, indicating the variations data from the server weren't received. Therefore, the SDK will work as usual and update the variations in the next [polling](flutter#polling) request.

:::

<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 the Bucketeer server 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 the server 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 shows 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 shows 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 +315,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
Loading