Skip to content

Commit

Permalink
adding realtime update to all server-side sdk docs (#770)
Browse files Browse the repository at this point in the history
* adding .net realtime update docs

* adding initialization options to go sdk

* adding go, java, nest

* adding php, python, ruby

* updates for language specific formats

* adding cloud bucketing options to java

* Updating ruby option types

* Update docs/sdk/server-side-sdks/php/php-usage.md

Co-authored-by: Jamie Sinn <jamie@devcycle.com>

* Updates given most recent round of comments

* cleaning up descriptions

* Update proxy docs and feature pages

* update feature page

* Update docs/sdk/server-side-sdks/php/php-gettingstarted.md

Co-authored-by: Jamie Sinn <jamie@devcycle.com>

* python update

* Update docs/sdk/features.md

Co-authored-by: Adam Wootton <adam@taplytics.com>

* Update docs/sdk/features.md

Co-authored-by: Adam Wootton <adam@taplytics.com>

* fixing for adam's comments

* removed example options

* updates to feature page

---------

Co-authored-by: Jamie Sinn <jamie@devcycle.com>
Co-authored-by: Adam Wootton <adam@taplytics.com>
  • Loading branch information
3 people authored Nov 15, 2024
1 parent 379ad8d commit e1e4d5e
Show file tree
Hide file tree
Showing 20 changed files with 428 additions and 86 deletions.
44 changes: 27 additions & 17 deletions docs/sdk/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,30 +302,40 @@ For instructions on setting up a custom domain, see [Custom Domains](/platform/e

## Realtime Updates

DevCycle SDKs are capable of being notified in real time that new configuration changes have been made in the DevCycle platform.
All DevCycle SDKs are capable of being notified in realtime that new configuration changes have been made in the DevCycle platform.
DevCycle leverages Server-Sent Events (SSE) to notify the SDKs that a feature (targeting rules, variable values, etc.)
has been saved and that they should fetch the new configuration.
has been updated and that they should fetch the new configuration. A connection URL is included in the config that the SDK fetches,
triggering the SDK to open a connection with our SSE provider and listen for any changes in the given environment.

**Supported SDKs**
- Javascript
- React
- iOS
- Android
- Flutter
- NodeJS (including Nest)
- Next.js
- Python
- Ruby
- Java
- Go
- .NET
- PHP (via SDK Proxy)

### SDK Specifics

#### **Javascript SDK**, **React SDK**

#### Client-Side SDK

A connection URL is included in the config that the SDK fetches, triggering the SDK to open a connection with our SSE provider listening
for any changes from the dashboard.

The following Client-Side SDKs currently have Realtime Updates:
If the user loses focus on the webpage for longer then the `inactivityDelay` (the default of which is set to 2 minutes, and can be configured through the options), the SDK will disconnect from the SSE provider and will reconnect when the user opens the tab / window again (i.e. the page's visibility state = `visible`). The SDK will also request a new configuration during reconnection to receive any updates it may have missed while the realtime connection was closed.

- Javascript SDK
- React SDK
- iOS SDK
- Android SDK
- Flutter SDK
#### **iOS SDK**, **Android SDK** & **Flutter SDK**

##### **Javascript SDK**, **React SDK**
If the user backgrounds the application for some period of time, the SDK will disconnect from the SSE provider and will reconnect again when the user brings the application to the foreground. When the application is brought to the foreground the SDK will request a new configuration to receive any updates it may have missed while the realtime connection was closed.

If the user loses focus on the webpage for longer then the `inactivityDelay` (the default of which is set to 2 minutes, and can be configured through the options), the SDK will disconnect from the SSE provider and will reconnect when the user opens the tab / window again (i.e. the page's visibility state = `visible`). The SDK will also request a new configuration during reconnection to receive any updates it may have missed while the realtime connection was closed.
#### Server-Side SDKs

##### **iOS SDK**, **Android SDK** & **Flutter SDK**
If the server loses its connection it will be re-opened it will be re-opened automatically after a configurable interval.

If the user backgrounds the application for some period of time, the SDK will disconnect from the SSE provider and will reconnect again when the user brings the application to the foreground. When the application is brought to the foreground the SDK will request a new configuration to receive any updates it may have missed while the realtime connection was closed.

## Local and Cloud Bucketing

Expand Down
54 changes: 31 additions & 23 deletions docs/sdk/sdk-proxy/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,37 @@ Alternatively - it can be configured via environment variables. The following en

`DVC_LB_PROXY_SDK_KEY` is the only required environment variable if not using a configuration file

| KEY | TYPE | DEFAULT | DESCRIPTION |
|--------------------------------------------------------|---------------|---------|---------------------------------------------------------------------------------|
| DVC_LB_PROXY_CONFIG | String | | The path to a JSON configuration file. |
| DVC_LB_PROXY_UNIX_SOCKET_PATH | String | | The path to the Unix socket. |
| DVC_LB_PROXY_HTTP_PORT | Integer | 8080 | The port to listen on for HTTP requests. Defaults to 8080. |
| DVC_LB_PROXY_UNIX_SOCKET_ENABLED | True or False | false | Whether to enable the Unix socket. Defaults to false. |
| DVC_LB_PROXY_HTTP_ENABLED | True or False | true | Whether to enable the HTTP server. Defaults to true. |
| DVC_LB_PROXY_SDK_KEY | String | | The Server SDK key to use for this instance. |
| DVC_LB_PROXY_PLATFORMDATA_SDKTYPE | String | | Internal variable, setting a value other than default is not recommended. |
| DVC_LB_PROXY_PLATFORMDATA_SDKVERSION | String | | Internal variable, setting a value other than default is not recommended. |
| DVC_LB_PROXY_PLATFORMDATA_PLATFORMVERSION | String | | Internal variable, setting a value other than default is not recommended. |
| DVC_LB_PROXY_PLATFORMDATA_DEVICEMODEL | String | | Internal variable, setting a value other than default is not recommended. |
| DVC_LB_PROXY_PLATFORMDATA_PLATFORM | String | | Internal variable, setting a value other than default is not recommended. |
| DVC_LB_PROXY_PLATFORMDATA_HOSTNAME | String | | Internal variable, setting a value other than default is not recommended. |
| DVC_LB_PROXY_SDKCONFIG_EVENT_FLUSH_INTERVAL_MS | Duration | | The interval at which events are flushed to the events api in milliseconds. |
| DVC_LB_PROXY_SDKCONFIG_CONFIG_POLLING_INTERVAL_MS | Duration | | The interval at which the SDK polls the config CDN for updates in milliseconds. |
| DVC_LB_PROXY_SDKCONFIG_REQUEST_TIMEOUT | Duration | | The timeout for requests to the config CDN and events API in milliseconds. |
| DVC_LB_PROXY_SDKCONFIG_DISABLE_AUTOMATIC_EVENT_LOGGING | True or False | false | Whether to disable automatic event logging. Defaults to false. |
| DVC_LB_PROXY_SDKCONFIG_DISABLE_CUSTOM_EVENT_LOGGING | True or False | false | Whether to disable custom event logging. Defaults to false. |
| DVC_LB_PROXY_SDKCONFIG_MAX_EVENT_QUEUE_SIZE | Integer | | The maximum number of events to be in the queue before dropping events. |
| DVC_LB_PROXY_SDKCONFIG_FLUSH_EVENT_QUEUE_SIZE | Integer | | The minimum number of events to be in the queue before flushing events. |
| DVC_LB_PROXY_SDKCONFIG_CONFIG_CDN_URI | String | | The URI of the Config CDN - leave unspecified if not needing an outbound proxy. |
| DVC_LB_PROXY_SDKCONFIG_EVENTSAPIURI | String | | The URI of the Events API - leave unspecified if not needing an outbound proxy. |
| KEY | TYPE | DEFAULT | REQUIRED | DESCRIPTION |
|----------------------------------------------------------|---------------|---------|----------|---------------------------------------------------------------------------------|
| DEVCYCLE_PROXY_CONFIG | String | | | The path to a JSON configuration file. |
| DEVCYCLE_PROXY_UNIX_SOCKET_PATH | String | | | The path to the Unix socket. |
| DEVCYCLE_PROXY_HTTP_PORT | Integer | 8080 | | The port to listen on for HTTP requests. Defaults to 8080. |
| DEVCYCLE_PROXY_UNIX_SOCKET_ENABLED | True or False | false | | Whether to enable the Unix socket. Defaults to false. |
| DEVCYCLE_PROXY_UNIX_SOCKET_PERMISSIONS | String | 0755 | | The permissions to set on the Unix socket. Defaults to 0755 |
| DEVCYCLE_PROXY_HTTP_ENABLED | True or False | true | | Whether to enable the HTTP server. Defaults to true. |
| DEVCYCLE_PROXY_SDK_KEY | String | | true | The Server SDK key to use for this instance. |
| DEVCYCLE_PROXY_PLATFORMDATA_SDKTYPE | String | | | |
| DEVCYCLE_PROXY_PLATFORMDATA_SDKVERSION | String | | | |
| DEVCYCLE_PROXY_PLATFORMDATA_PLATFORMVERSION | String | | | |
| DEVCYCLE_PROXY_PLATFORMDATA_DEVICEMODEL | String | | | |
| DEVCYCLE_PROXY_PLATFORMDATA_PLATFORM | String | | | |
| DEVCYCLE_PROXY_PLATFORMDATA_HOSTNAME | String | | | |
| DEVCYCLE_PROXY_SDKCONFIG_EVENT_FLUSH_INTERVAL_MS | Duration | | | The interval at which events are flushed to the events api in milliseconds. |
| DEVCYCLE_PROXY_SDKCONFIG_CONFIG_POLLING_INTERVAL_MS | Duration | | | The interval at which the SDK polls the config CDN for updates in milliseconds. |
| DEVCYCLE_PROXY_SDKCONFIG_REQUEST_TIMEOUT | Duration | | | The timeout for requests to the config CDN and events API in milliseconds. |
| DEVCYCLE_PROXY_SDKCONFIG_DISABLE_AUTOMATIC_EVENT_LOGGING | True or False | false | | Whether to disable automatic event logging. Defaults to false. |
| DEVCYCLE_PROXY_SDKCONFIG_DISABLE_CUSTOM_EVENT_LOGGING | True or False | false | | Whether to disable custom event logging. Defaults to false. |
| DEVCYCLE_PROXY_SDKCONFIG_MAX_EVENT_QUEUE_SIZE | Integer | | | The maximum number of events to be in the queue before dropping events. |
| DEVCYCLE_PROXY_SDKCONFIG_FLUSH_EVENT_QUEUE_SIZE | Integer | | | The minimum number of events to be in the queue before flushing events. |
| DEVCYCLE_PROXY_SDKCONFIG_CONFIG_CDN_URI | String | | | The URI of the Config CDN - leave unspecified if not needing an outbound proxy. |
| DEVCYCLE_PROXY_SDKCONFIG_EVENTSAPIURI | String | | | The URI of the Events API - leave unspecified if not needing an outbound proxy. |

:::info

For customers on an Enterprise plan, if you would like support in enabling [Realtime Updates](https://docs.devcycle.com/sdk/features#realtime-updates) or
configuring any other initialization option for the SDK Proxy please [contact support](mailto:support@devcycle.com).

:::

## Post-Installation

Expand Down
50 changes: 45 additions & 5 deletions docs/sdk/server-side-sdks/dotnet/dotnet-gettingstarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ namespace Example {
```
[//]: # (wizard-initialize-end)

### Initialization With Callback

### Initialization with Callback
You can also setup a callback to be notified when the client is fully initialized and use `DevCycleLocalOptions` to further configure the client.

```csharp
Expand All @@ -69,11 +68,9 @@ using DevCycle.SDK.Server.Common.API;
using DevCycle.SDK.Server.Common.Model;
using DevCycle.SDK.Server.Common.Model.Local;
using Microsoft.Extensions.Logging;

namespace Example {
public class Example {
private static DevCycleLocalClient client;

static async Task Main(string[] args) {
client = new DevCycleLocalClientBuilder()
.SetSDKKey("<DEVCYCLE_SERVER_SDK_KEY>")
Expand All @@ -87,17 +84,60 @@ namespace Example {
})
.SetLogger(LoggerFactory.Create(builder => builder.AddConsole()))
.Build();

try {
await Task.Delay(5000);
} catch (TaskCanceledException) {
System.Environment.Exit(0);
}
}
private static void ClientInitialized() {
// Start using the client here
}
}
}
```

## Initialization Options

The SDK exposes various initialization options which can be set when initializing the DevCycle client:

```csharp

namespace Example {
public class Example {
private static DevCycleLocalClient client;

static async Task Main(string[] args) {
client = new DevCycleLocalClientBuilder()
.SetSDKKey("<DEVCYCLE_SERVER_SDK_KEY>")
.SetOptions(new DevCycleLocalOptions())
.SetLogger(LoggerFactory.Create(builder => builder.AddConsole()))
.Build();

}

private static void ClientInitialized() {
// Start using the client here
}
}
}
```

| DevCycle Option | Type | Description |
|------------------------------|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| enableEdgeDB | bool | Enables the usage of EdgeDB for DevCycle that syncs User Data to DevCycle. <br />NOTE: This is only available with Cloud Bucketing enabled. |
| configPollingIntervalMs | int | Controls the polling interval in milliseconds to fetch new environment config changes, defaults to 10 seconds, minimum value is 1 second. |
| configPollingTimeoutMs | int | Controls the request timeout to fetch new environment config changes, defaults to 5 seconds, must be less than the configPollingIntervalMS value, minimum value is 1 second. |
| disableAutomaticEvents | bool | Disables logging of sdk generated events (e.g. aggVariableEvaluated, aggVariableDefaulted) to DevCycle. |
| disableCustomEvents | bool | Disables logging of custom events, from `track()` method, and user data to DevCycle. |
| flushEventQueueSize | int | Controls the maximum size the event queue can grow to until a flush is forced. Defaults to `1000`. |
| maxEventsInQueue | int | Controls the maximum size the event queue can grow to until events are dropped. Defaults to `2000`. |
| eventRequestChunkSize | int | Count of events to chunk per event upload request. Defaults to `100`. |
| eventFlushIntervalMs | int | Controls the interval between flushing events to the DevCycle servers. Defaults to `10000`. |
| cdnUri | string | Contact support for usage instructions. |
| cdnSlug | string | Contact support for usage instructions. |
| eventsApiUri | string | Contact support for usage instructions. |
| eventsApiSlug | string | Contact support for usage instructions. |
| cdnCustomHeaders | Dictionary | Contact support for usage instructions. |
| eventsApiCustomHeaders | Dictionary | Contact support for usage instructions. |
| enableBetaRealtimeUpdates | bool | Enables the usage of Beta Realtime Updates for DevCycle. This feature is currently in beta. |
20 changes: 20 additions & 0 deletions docs/sdk/server-side-sdks/dotnet/dotnet-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,23 @@ To further enable various deployment configurations - we provide a background pr
or the SDK is not able to make requests to the DevCycle API directly. The installation and setup process for the proxy can be found here: https://github.com/DevCycleHQ/sdk-proxy#readme.

See the [SDK Proxy](../../sdk-proxy/index.md) section for more information.

## Enabling Beta Realtime Updates

:::warning
This feature is in beta, and may not function as expected. Please ensure that you have the latest version of the SDK.
:::

This functionality will reduce the number of polling requests that are made to the DevCycle Config CDN, and instead will
use a long-lived HTTP connection (Server Sent Events) to receive updates when there is a new config available.
This reduces outbound network traffic, as well as optimizes the SDK for efficiency.

To enable Beta Realtime Updates, pass in the `enableBetaRealtimeUpdates` option to the SDK initialization:

```csharp
client = new DevCycleLocalClientBuilder()
.SetSDKKey("<DEVCYCLE_SERVER_SDK_KEY>")
.SetOptions(new DevCycleLocalOptions(enableBetaRealtimeUpdates: true))
.SetLogger(LoggerFactory.Create(builder => builder.AddConsole()))
.Build();
```
Loading

0 comments on commit e1e4d5e

Please sign in to comment.