You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-4Lines changed: 28 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,6 @@ import { init } from "@eppo/js-client-sdk";
33
33
awaitinit({ apiKey:"<SDK-KEY-FROM-DASHBOARD>" });
34
34
```
35
35
36
-
37
36
#### Assign anywhere
38
37
39
38
```javascript
@@ -85,7 +84,35 @@ The `init` function accepts the following optional configuration arguments.
85
84
|**`throwOnFailedInitialization`**| boolean | Throw an error (reject the promise) if unable to fetch initial configurations during initialization. |`true`|
86
85
|**`numPollRequestRetries`**| number | If polling for updated configurations after initialization, the number of additional times a request will be attempted before giving up. Subsequent attempts are done using an exponential backoff. |`7`|
87
86
87
+
## Off-line initialization
88
+
89
+
The SDK supports off-line initialization if you want to initialize the SDK with a configuration from your server SDK or other external process. In this mode the SDK will not attempt to fetch a configuration from Eppo's CDN, instead only using the provided values.
88
90
91
+
This function is synchronous and ready to handle assignments after it returns.
// The configuration will be not-obfuscated from your server SDK. If you have obfuscated flag values, you can use the `ObfuscatedFlag` type.
99
+
const flagsConfiguration:Record<string, Flag | ObfuscatedFlag> =JSON.parse(configurationJsonString);
100
+
101
+
offlineInit({
102
+
flagsConfiguration,
103
+
// If you have obfuscated flag values, you can use the `ObfuscatedFlag` type.
104
+
isObfuscated:true,
105
+
});
106
+
```
107
+
108
+
The `offlineInit` function accepts the following optional configuration arguments.
109
+
110
+
| Option | Type | Description | Default |
111
+
| ------ | ----- | ----- | ----- |
112
+
|**`assignmentLogger`**|[IAssignmentLogger](https://github.com/Eppo-exp/js-client-sdk-common/blob/75c2ea1d91101d579138d07d46fca4c6ea4aafaf/src/assignment-logger.ts#L55-L62)| A callback that sends each assignment to your data warehouse. Required only for experiment analysis. See [example](#assignment-logger) below. |`null`|
113
+
|**`flagsConfiguration`**| Record<string, Flag \| ObfuscatedFlag> | The flags configuration to use for the SDK. |`null`|
114
+
|**`isObfuscated`**| boolean | Whether the flag values are obfuscated. |`false`|
115
+
|**`throwOnFailedInitialization`**| boolean | Throw an error if an error occurs during initialization. |`true`|
89
116
90
117
## Assignment logger
91
118
@@ -119,6 +146,3 @@ Eppo's SDKs are built for simplicity, speed and reliability. Flag configurations
119
146
## React
120
147
121
148
Visit the [Eppo docs](https://docs.geteppo.com/sdks/client-sdks/javascript#usage-in-react) for best practices when using this SDK within a React context.
0 commit comments