-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathLDOptions.ts
More file actions
319 lines (290 loc) · 11.9 KB
/
LDOptions.ts
File metadata and controls
319 lines (290 loc) · 11.9 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
import type { LDLogger } from '@launchdarkly/js-sdk-common';
import { LDClientDataSystemOptions } from './datasource/LDClientDataSystemOptions';
import { Hook } from './integrations/Hooks';
import { LDInspection } from './LDInspection';
export interface LDOptions {
/**
* Whether all context attributes (except the context key) should be marked as private, and
* not sent to LaunchDarkly in analytics events.
*
* @defaultValue false.
*/
allAttributesPrivate?: boolean;
/**
* Information about the application the LaunchDarkly SDK is running in.
*
* These properties are optional and informational. They may be used in LaunchDarkly
* analytics or other product features.
*/
applicationInfo?: {
/**
* 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;
};
/**
* The base uri for the LaunchDarkly server. Most users should use the default value.
*
* @defaultValue https://clientsdk.launchdarkly.com.
*/
baseUri?: string;
/**
* 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 queue is flushed, events will be discarded. Increasing the capacity means that events
* are less likely to be discarded, at the cost of consuming more memory. Note that in regular usage
* flag evaluations do not produce individual events, only summary counts, so you only need a large
* capacity if you are generating a large number of click, pageview, or identify events (or if you
* are using the event debugger).
*
* @defaultValue 100.
*/
capacity?: number;
/**
* Enables debug logging.
*
* @defaultValue false.
*/
debug?: boolean;
/**
* Set to true to opt out of sending diagnostics data.
*
* Unless `diagnosticOptOut` 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.
*
* @defaultValue false.
*/
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 6. See {@link diagnosticOptOut}
* for more information on the diagnostics data being sent.
*
* @defaultValue 900s.
*/
diagnosticRecordingInterval?: number;
/**
* The base uri for the LaunchDarkly events server. Most users should use the default value.
*
* @defaultValue https://events.launchdarkly.com.
*/
eventsUri?: string;
/**
* The interval in between flushes of the analytics events queue, in seconds.
*
* @defaultValue 2s for browser implementations 30s for others.
*/
flushInterval?: number;
/**
* An object that will perform logging for the client.
*
* @remarks
* Set a custom {@link LDLogger} if you want full control of logging behavior.
*
* @defaultValue The default logging implementation will varybased on platform. For the browser
* the default logger will log "info" level and higher priorty messages and it will log messages to
* console.info, console.warn, and console.error. Other platforms may use a `BasicLogger` instance
* also defaulted to the "info" level.
*/
logger?: LDLogger;
/**
* The maximum number of locally cached contexts. The cache is used to decrease initialization
* latency and to provide fallback flag values when the SDK cannot reach LaunchDarkly services.
*
* @remarks
* Setting this to `0` disables caching entirely: the SDK will not read from or
* write to the cache, and any previously cached entries will be pruned from
* local storage.
*
* To suppress cache read/writes **without** removing existing cached data, use
* {@link LDOptions.disableCache} instead.
*
* @defaultValue 5
*/
maxCachedContexts?: number;
/**
* Specifies a list of attribute names (either built-in or custom) which should be marked as
* private, and not sent to LaunchDarkly in analytics events. You can also specify this on a
* per-context basis with {@link LDContextMeta.privateAttributes}.
*
* Any contexts sent to LaunchDarkly with this configuration active will have attributes with
* these names removed in analytic events. This is in addition to any attributes that were
* marked as private for an individual context with {@link LDContextMeta.privateAttributes}.
* Setting {@link LDOptions.allAttributesPrivate} to true overrides this.
*
* If and only if a parameter starts with a slash, it is interpreted as a slash-delimited path
* that can denote a nested property within a JSON object. For instance, "/address/street" means
* that if there is an attribute called "address" that is a JSON object, and one of the object's
* properties is "street", the "street" property will be redacted from the analytics data but
* other properties within "address" will still be sent. This syntax also uses the JSON Pointer
* convention of escaping a literal slash character as "~1" and a tilde as "~0".
*/
privateAttributes?: Array<string>;
/**
* Whether to send analytics events back to LaunchDarkly.
*
* @defaultValue true.
*/
sendEvents?: boolean;
/**
* Sets the initial reconnect delay for the streaming connection, in seconds.
*
* 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.
*
* @defaultValue 1s.
*/
streamInitialReconnectDelay?: number;
/**
* The base uri for the LaunchDarkly streaming server. Most users should use the default value.
*
* @defaultValue https://clientstream.launchdarkly.com.
*/
streamUri?: string;
/**
* The time between polling requests, in seconds. Ignored in streaming mode.
*
* The minimum polling interval is 30 seconds.
*/
pollInterval?: number;
/**
* Directs the SDK to use the REPORT method for HTTP requests instead of GET. (Default: `false`)
*
* This setting applies both to requests to the streaming service, as well as flag requests when the SDK is in polling
* mode.
*/
useReport?: boolean;
/**
* Whether LaunchDarkly should provide additional information about how flag values were
* calculated.
*
* The additional information will then be available through the client's
* {@link LDClient.variationDetail} method. Since this increases the size of network requests,
* such information is not sent unless you set this option to true.
*
* @defaultValue false.
*/
withReasons?: boolean;
/**
* For use by wrapper libraries to set an identifying name for the wrapper being used.
*
* This will be sent as diagnostic information to the LaunchDarkly servers to allow recording
* metrics on the usage of these wrapper libraries.
*/
wrapperName?: string;
/**
* For use by wrapper libraries to set version to be included alongside `wrapperName`.
*
* If `wrapperName` is unset, this field will be ignored.
*/
wrapperVersion?: 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 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 { TheHook } from '@launchdarkly/some-hook';
*
* const client = init('my-sdk-key', { hooks: [new TheHook()] });
* ```
*/
hooks?: Hook[];
/**
* Inspectors can be used for collecting information for monitoring, analytics, and debugging.
*
*
* @deprecated Hooks should be used instead of inspectors and inspectors will be removed in
* a future version. If you need functionality that is not exposed using hooks, then please
* let us know through a github issue or support.
*/
inspectors?: LDInspection[];
/**
* Whether to clean old persistent data. If set to true, the SDK will check to see if old
* there are any persistent data that is generated by an older version and remove it.
*
* @defaultValue false.
*/
cleanOldPersistentData?: boolean;
/**
* @internal
*
* WARNING: This option is EXPERIMENTAL and UNSUPPORTED. It is subject to
* change or removal without notice. Do not use in production applications.
* Using this option may result in unexpected behavior, data loss, or
* breaking changes in future SDK versions. LaunchDarkly does not provide
* support for configurations using this option.
*
* Configuration for the FDv2 data system. When present, the SDK uses
* the FDv2 protocol for flag delivery instead of the default FDv1
* protocol.
*/
dataSystem?: LDClientDataSystemOptions;
/**
* Set to `true` to suppress all reads and writes to the persistent flag cache
* in local storage.
*
* @remarks
* Unlike setting {@link LDOptions.maxCachedContexts} to `0`,
* this does **not** remove previously cached data — existing entries are left
* intact. This takes precedence over `maxCachedContexts`.
*
* @defaultValue false
*/
disableCache?: boolean;
}