-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathLDOptions.ts
More file actions
362 lines (327 loc) · 12.6 KB
/
LDOptions.ts
File metadata and controls
362 lines (327 loc) · 12.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
import { LDClientContext, LDLogger, subsystem, VoidFunction } from '@launchdarkly/js-sdk-common';
import { Hook } from '../integrations/Hook';
import { LDDataSourceUpdates, LDFeatureStore } from '../subsystems';
import { LDBigSegmentsOptions } from './LDBigSegmentsOptions';
import { LDDataSystemOptions } from './LDDataSystemOptions';
import { LDProxyOptions } from './LDProxyOptions';
import { LDTLSOptions } from './LDTLSOptions';
/**
* LaunchDarkly initialization options.
*/
export interface LDOptions {
/**
* The base URI for the LaunchDarkly server.
*
* Most users should use the default value.
*/
baseUri?: string;
/**
* The base URI for the LaunchDarkly streaming server.
*
* Most users should use the default value.
*/
streamUri?: string;
/**
* The base URI for the LaunchDarkly events server.
*
* Most users should use the default value.
*/
eventsUri?: string;
/**
* The connection timeout, in seconds.
*/
timeout?: number;
/**
* The capacity of the analytics events queue.
*
* The client buffers up to this many events in memory before flushing. If the capacity is
* exceeded before the buffer is flushed, events will be discarded.
*/
capacity?: number;
/**
* Configures a logger for warnings and errors generated by the SDK.
*
* The logger can be any object that conforms to the {@link LDLogger} interface.
* For a simple implementation that lets you filter by log level, see
* {@link basicLogger}. You can also use an instance of `winston.Logger` from
* the Winston logging package.
*
* If you do not set this property, the SDK uses {@link basicLogger} with a
* minimum level of `info`.
*/
logger?: LDLogger;
/**
* A component that stores feature flags and related data received from LaunchDarkly.
*
* If you specify the {@link LDOptions#dataSystem}, this setting will be ignored.
*
* By default, this is an in-memory data structure. Database integrations are also
* available, as described in the
* [SDK features guide](https://docs.launchdarkly.com/sdk/concepts/data-stores).
*
* Some implementations provide the store implementation object itself, while others
* provide a factory function that creates the store implementation based on the SDK
* configuration; this property accepts either.
*/
featureStore?: LDFeatureStore | ((clientContext: LDClientContext) => LDFeatureStore);
/**
* Configuration options for the Data System that the SDK uses to get and maintain flags and other
* data from LaunchDarkly and other sources.
*
* Setting this option supersedes
*
* Example (Recommended):
* ```typescript
* let dataSystemOptions = {
* dataSource: {
* type: 'standard';
* // options can be customized here, though defaults are recommended
* },
* }
*
* Example (Polling with DynamoDB Persistent Store):
* ```typescript
* import { DynamoDBFeatureStore } from '@launchdarkly/node-server-sdk-dynamodb';
*
* let dataSystemOptions = {
* dataSource: {
* type: 'pollingOnly';
* pollInterval: 300;
* },
* persistentStore: DynamoDBFeatureStore('your-table', { cacheTTL: 30 });
* }
* const client = init('my-sdk-key', { hooks: [new TracingHook()] });
* ```
*/
dataSystem?: LDDataSystemOptions;
/**
* Additional parameters for configuring the SDK's Big Segments behavior.
*
* Big Segments are a specific type of user segments. For more information, read the
* LaunchDarkly documentation: https://docs.launchdarkly.com/home/users/big-segments
*
* By default, there is no configuration and Big Segments cannot be evaluated. In this
* case, any flag evaluation that references a Big Segment will behave as if no users
* are included in any Big Segments, and the {@link LDEvaluationReason} associated with any
* such flag evaluation will have a `bigSegmentsStatus` of `"NOT_CONFIGURED"`.
*/
bigSegments?: LDBigSegmentsOptions;
/**
* A component that obtains feature flag data and puts it in the feature store.
*
* If you specify the {@link LDOptions#dataSystem}, this setting will be ignored.
*/
updateProcessor?:
| object
| ((
clientContext: LDClientContext,
dataSourceUpdates: LDDataSourceUpdates,
initSuccessHandler: VoidFunction,
errorHandler?: (e: Error) => void,
) => subsystem.LDStreamProcessor);
/**
* The interval in between flushes of the analytics events queue, in seconds.
*/
flushInterval?: number;
/**
* The time between polling requests, in seconds. Ignored in streaming mode.
*
* If you specify the {@link LDOptions#dataSystem}, this setting will be ignored.
*/
pollInterval?: number;
/**
* Allows you to specify configuration for an optional HTTP proxy.
*/
proxyOptions?: LDProxyOptions;
/**
* Whether the client should be initialized in offline mode.
*/
offline?: boolean;
/**
* Whether streaming mode should be used to receive flag updates.
*
* If you specify the {@link LDOptions#dataSystem}, this setting will be ignored.
*
* This is true by default. If you set it to false, the client will use polling.
* Streaming should only be disabled on the advice of LaunchDarkly support.
*/
stream?: boolean;
/**
* Sets the initial reconnect delay for the streaming connection, in seconds.
*
* If you specify the {@link LDOptions#dataSystem}, this setting will be ignored.
*
* The streaming service uses a backoff algorithm (with jitter) every time the connection needs
* to be reestablished. The delay for the first reconnection will start near this value, and then
* increase exponentially for any subsequent connection failures.
*
* The default value is 1.
*/
streamInitialReconnectDelay?: number;
/**
* Whether you are using the LaunchDarkly relay proxy in daemon mode.
*
* If you specify the {@link LDOptions#dataSystem}, this setting will be ignored.
*
* In this configuration, the client will not connect to LaunchDarkly to get feature flags,
* but will instead get feature state from a database (Redis or another supported feature
* store integration) that is populated by the relay. By default, this is false.
*/
useLdd?: boolean;
/**
* Whether to send analytics events back to LaunchDarkly. By default, this is true.
*/
sendEvents?: boolean;
/**
* Whether all context attributes (except the context key) should be marked as private, and
* not sent to LaunchDarkly.
*
* By default, this is false.
*/
allAttributesPrivate?: boolean;
/**
* The names of any context attributes that should be marked as private, and not sent
* to LaunchDarkly.
*/
privateAttributes?: Array<string>;
/**
* The number of context keys that the event processor can remember at any one time,
* so that duplicate context details will not be sent in analytics events.
*
* Defaults to 1000.
*/
contextKeysCapacity?: number;
/**
* The interval (in seconds) at which the event processor will reset its set of
* known context keys.
*
* Defaults to 300.
*/
contextKeysFlushInterval?: number;
/**
* Additional parameters to pass to the Node HTTPS API for secure requests. These can include any
* of the TLS-related parameters supported by `https.request()`, such as `ca`, `cert`, and `key`.
*
* For more information, see the Node documentation for `https.request()` and `tls.connect()`.
*/
tlsParams?: LDTLSOptions;
/**
* Set to true to opt out of sending diagnostics data.
*
* Unless the `diagnosticOptOut` field is set to true, the client will send some diagnostics data
* to the LaunchDarkly servers in order to assist in the development of future SDK improvements.
* These diagnostics consist of an initial payload containing some details of SDK in use, the
* SDK's configuration, and the platform the SDK is being run on, as well as payloads sent
* periodically with information on irregular occurrences such as dropped events.
*/
diagnosticOptOut?: boolean;
/**
* The interval at which periodic diagnostic data is sent, in seconds.
*
* The default is 900 (every 15 minutes) and the minimum value is 60 (every minute).
*/
diagnosticRecordingInterval?: number;
/**
* For use by wrapper libraries to set an identifying name for the wrapper being used.
*
* This will be sent in User-Agent headers during requests to the LaunchDarkly servers to allow
* recording metrics on the usage of these wrapper libraries.
*/
wrapperName?: string;
/**
* For use by wrapper libraries to report the version of the library in use.
*
* If `wrapperName` is not set, this field will be ignored. Otherwise the version string will be
* included in the User-Agent headers along with the `wrapperName` during requests to the
* LaunchDarkly servers.
*/
wrapperVersion?: string;
/**
* Information about the application where the LaunchDarkly SDK is running.
*
* Note that this config option may be renamed to applicationInfo in a future major version
* to be consistent with other SDKs.
*/
application?: {
/**
* A unique identifier representing the application where the LaunchDarkly SDK is running.
*
* This can be specified as any string value as long as it only uses the following characters:
* ASCII letters, ASCII digits, period, hyphen, underscore. A string containing any other
* characters will be ignored.
*
* Example: `authentication-service`
*/
id?: string;
/**
* A unique identifier representing the version of the application where the LaunchDarkly SDK is
* running.
*
* This can be specified as any string value as long as it only uses the following characters:
* ASCII letters, ASCII digits, period, hyphen, underscore. A string containing any other
* characters will be ignored.
*
* Example: `1.0.0` (standard version string) or `abcdef` (sha prefix)
*/
version?: string;
/**
* A human-friendly application name representing the application where the LaunchDarkly SDK is running.
*
* This can be specified as any string value as long as it only uses the following characters: ASCII letters,
* ASCII digits, period, hyphen, underscore. A string containing any other characters will be ignored.
*/
name?: string;
/**
* A human-friendly name representing the version of the application where the LaunchDarkly SDK is running.
*
* This can be specified as any string value as long as it only uses the following characters: ASCII letters,
* ASCII digits, period, hyphen, underscore. A string containing any other characters will be ignored.
*/
versionName?: string;
};
/**
* LaunchDarkly Server SDKs historically downloaded all flag configuration and segments for a particular environment
* during initialization.
*
* For some customers, this is an unacceptably large amount of data, and has contributed to performance issues
* within their products.
*
* Filtered environments aim to solve this problem. By allowing customers to specify subsets of an environment's
* flags using a filter key, SDKs will initialize faster and use less memory.
*
* This feature is releasing through a closed alpha and beta pipeline and may not be available for your account
* until public release.
*
* This payload filter key only applies to the default streaming and polling data sources. It will not affect
* TestData or FileData data sources, nor will it be applied to any data source provided through the featureStore
* config property.
*/
payloadFilterKey?: string;
/**
* Initial set of hooks for the client.
*
* Hooks provide entrypoints which allow for observation of SDK functions.
*
* LaunchDarkly provides integration packages, and most applications will not
* need to implement their own hooks. Refer to the `@launchdarkly/node-server-sdk-otel`
* for instrumentation for the `@launchdarkly/node-server-sdk`.
*
* Example:
* ```typescript
* import { init } from '@launchdarkly/node-server-sdk';
* import { TracingHook } from '@launchdarkly/node-server-sdk-otel';
*
* const client = init('my-sdk-key', { hooks: [new TracingHook()] });
* ```
*/
hooks?: Hook[];
/**
* Set to true to opt in to compressing event payloads if the SDK supports it, since the
* compression library may not be supported in the underlying SDK framework. If the compression
* library is not supported then event payloads will not be compressed even if this option
* is enabled.
*
* Defaults to false.
*/
enableEventCompression?: boolean;
}