@launchdarkly/js-client-sdk 0.12.1 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,7 +1,256 @@
1
- import { LDContext } from '@launchdarkly/js-client-sdk-common';
2
- export { AutoEnvAttributes, BasicLogger, BasicLoggerOptions, EvaluationSeriesContext, EvaluationSeriesData, Hook, HookMetadata, IdentifySeriesContext, IdentifySeriesData, IdentifySeriesResult, IdentifySeriesStatus, LDContext, LDContextCommon, LDContextMeta, LDDebugOverride, LDEvaluationDetail, LDEvaluationDetailTyped, LDEvaluationReason, LDFlagSet, LDFlagValue, LDIdentifyError, LDIdentifyResult, LDIdentifyShed, LDIdentifySuccess, LDIdentifyTimeout, LDInspection, LDLogLevel, LDLogger, LDMultiKindContext, LDPluginApplicationMetadata, LDPluginBase, LDPluginEnvironmentMetadata, LDPluginMetadata, LDPluginSdkMetadata, LDSingleKindContext, LDTimeoutError, LDWaitForInitializationComplete, LDWaitForInitializationFailed, LDWaitForInitializationOptions, LDWaitForInitializationResult, LDWaitForInitializationTimeout, TrackSeriesContext } from '@launchdarkly/js-client-sdk-common';
3
- import { B as BrowserOptions, L as LDClient } from './common-B4wKbl6r.cjs';
4
- export { b as LDIdentifyOptions, a as LDPlugin, c as basicLogger } from './common-B4wKbl6r.cjs';
1
+ import { LDIdentifyOptions, ItemDescriptor, LDClient as LDClient$1, LDContext, LDIdentifyResult, LDWaitForInitializationOptions, LDWaitForInitializationResult, LDPluginBase, Hook, LDOptions, BasicLoggerOptions, LDLogger } from '@launchdarkly/js-client-sdk-common';
2
+ export { AutoEnvAttributes, BasicLogger, BasicLoggerOptions, EvaluationSeriesContext, EvaluationSeriesData, Hook, HookMetadata, IdentifySeriesContext, IdentifySeriesData, IdentifySeriesResult, IdentifySeriesStatus, LDContext, LDContextCommon, LDContextMeta, LDContextStrict, LDDebugOverride, LDEvaluationDetail, LDEvaluationDetailTyped, LDEvaluationReason, LDFlagSet, LDFlagValue, LDIdentifyError, LDIdentifyResult, LDIdentifyShed, LDIdentifySuccess, LDIdentifyTimeout, LDInspection, LDLogLevel, LDLogger, LDMultiKindContext, LDPluginApplicationMetadata, LDPluginBase, LDPluginEnvironmentMetadata, LDPluginMetadata, LDPluginSdkMetadata, LDSingleKindContext, LDTimeoutError, LDWaitForInitializationComplete, LDWaitForInitializationFailed, LDWaitForInitializationOptions, LDWaitForInitializationResult, LDWaitForInitializationTimeout, TrackSeriesContext } from '@launchdarkly/js-client-sdk-common';
3
+
4
+ /**
5
+ * @property sheddable - If true, the identify operation will be sheddable. This means that if multiple identify operations are done, without
6
+ * waiting for the previous one to complete, then intermediate results will be discarded. When false, identify
7
+ * operations will be queued and completed sequentially.
8
+ *
9
+ * Defaults to true.
10
+ */
11
+ interface BrowserIdentifyOptions extends Omit<LDIdentifyOptions, 'waitForNetworkResults'> {
12
+ /**
13
+ * The signed context key if you are using [Secure Mode]
14
+ * (https://docs.launchdarkly.com/sdk/features/secure-mode#configuring-secure-mode-in-the-javascript-client-side-sdk).
15
+ */
16
+ hash?: string;
17
+ /**
18
+ * The initial set of flags to use until the remote set is retrieved.
19
+ *
20
+ * Bootstrap data can be generated by server SDKs. When bootstrap data is provided the SDK the
21
+ * identification operation will complete without waiting for any values from LaunchDarkly and
22
+ * the variation calls can be used immediately.
23
+ *
24
+ * If streaming is activated, either it is configured to always be used, or is activated
25
+ * via setStreaming, or via the addition of change handlers, then a streaming connection will
26
+ * subsequently be established.
27
+ *
28
+ * For more information, see the [SDK Reference Guide](https://docs.launchdarkly.com/sdk/features/bootstrapping#javascript).
29
+ */
30
+ bootstrap?: unknown;
31
+ /**
32
+ * Parsed bootstrap data that could be stored to ensure that the bootstrap data is only parsed once during the intialization
33
+ * process.
34
+ *
35
+ * @hidden
36
+ */
37
+ bootstrapParsed?: {
38
+ [key: string]: ItemDescriptor;
39
+ };
40
+ }
41
+
42
+ interface LDStartOptions extends LDWaitForInitializationOptions {
43
+ /**
44
+ * Optional bootstrap data to use for the identify operation. If {@link LDIdentifyOptions.bootstrap} is provided, it will be ignored.
45
+ */
46
+ bootstrap?: unknown;
47
+ /**
48
+ * Optional identify options to use for the identify operation. See {@link LDIdentifyOptions} for more information.
49
+ *
50
+ * @remarks
51
+ * Since the first identify option should never be sheddable, we omit the sheddable option from the interface to avoid confusion.
52
+ */
53
+ identifyOptions?: Omit<BrowserIdentifyOptions, 'sheddable'>;
54
+ }
55
+ /**
56
+ *
57
+ * The LaunchDarkly SDK client object.
58
+ *
59
+ * Applications should configure the client at page load time and reuse the same instance.
60
+ *
61
+ * For more information, see the [SDK Reference Guide](https://docs.launchdarkly.com/sdk/client-side/javascript).
62
+ */
63
+ type LDClient = Omit<LDClient$1, 'setConnectionMode' | 'getConnectionMode' | 'getOffline' | 'identify'> & {
64
+ /**
65
+ * @ignore
66
+ * Implementation Note: We are not supporting dynamically setting the connection mode on the LDClient.
67
+ * Implementation Note: The SDK does not support offline mode. Instead bootstrap data can be used.
68
+ * Implementation Note: The browser SDK has different identify options, so omits the base implementation
69
+ * from the interface.
70
+ */
71
+ /**
72
+ * Specifies whether or not to open a streaming connection to LaunchDarkly for live flag updates.
73
+ *
74
+ * If this is true, the client will always attempt to maintain a streaming connection; if false,
75
+ * it never will. If you leave the value undefined (the default), the client will open a streaming
76
+ * connection if you subscribe to `"change"` or `"change:flag-key"` events (see {@link LDClient.on}).
77
+ *
78
+ * This can also be set as the `streaming` property of {@link LDOptions}.
79
+ */
80
+ setStreaming(streaming?: boolean): void;
81
+ /**
82
+ * Identifies a context to LaunchDarkly and returns a promise which resolves to an object containing the result of
83
+ * the identify operation.
84
+ *
85
+ * Unlike the server-side SDKs, the client-side JavaScript SDKs maintain a current context state,
86
+ * which is set when you call `identify()`.
87
+ *
88
+ * Changing the current context also causes all feature flag values to be reloaded. Until that has
89
+ * finished, calls to {@link variation} will still return flag values for the previous context. You can
90
+ * await the Promise to determine when the new flag values are available.
91
+ *
92
+ * If used with the `sheddable` option set to true, then the identify operation will be sheddable. This means that if
93
+ * multiple identify operations are done, without waiting for the previous one to complete, then intermediate
94
+ * operations may be discarded.
95
+ *
96
+ * @param context
97
+ * The LDContext object.
98
+ * @param identifyOptions
99
+ * Optional configuration. Please see {@link LDIdentifyOptions}.
100
+ * @returns
101
+ * A promise which resolves to an object containing the result of the identify operation.
102
+ * The promise returned from this method will not be rejected.
103
+ *
104
+ * @ignore Implementation Note: Browser implementation has different options.
105
+ */
106
+ identify(pristineContext: LDContext, identifyOptions?: BrowserIdentifyOptions): Promise<LDIdentifyResult>;
107
+ /**
108
+ * Returns a Promise that tracks the client's initialization state.
109
+ *
110
+ * The Promise will be resolved to a {@link LDWaitForInitializationResult} object containing the
111
+ * status of the waitForInitialization operation.
112
+ *
113
+ * @example
114
+ * This example shows use of async/await syntax for specifying handlers:
115
+ * ```
116
+ * const result = await client.waitForInitialization({ timeout: 5 });
117
+ *
118
+ * if (result.status === 'complete') {
119
+ * doSomethingWithSuccessfullyInitializedClient();
120
+ * } else if (result.status === 'failed') {
121
+ * doSomethingForFailedStartup(result.error);
122
+ * } else if (result.status === 'timeout') {
123
+ * doSomethingForTimedOutStartup();
124
+ * }
125
+ * ```
126
+ *
127
+ * @remarks
128
+ * You can also use event listeners ({@link on}) for the same purpose: the event `"initialized"`
129
+ * indicates success, and `"error"` indicates an error.
130
+ *
131
+ * @param options
132
+ * Optional configuration. Please see {@link LDWaitForInitializationOptions}.
133
+ *
134
+ * @returns
135
+ * A Promise that will be resolved to a {@link LDWaitForInitializationResult} object containing the
136
+ * status of the waitForInitialization operation.
137
+ */
138
+ waitForInitialization(options?: LDWaitForInitializationOptions): Promise<LDWaitForInitializationResult>;
139
+ /**
140
+ * Starts the client and returns a promise that resolves to the initialization result.
141
+ *
142
+ * The promise will resolve to a {@link LDWaitForInitializationResult} object containing the
143
+ * status of the waitForInitialization operation.
144
+ *
145
+ * @param options Optional configuration. Please see {@link LDStartOptions}.
146
+ */
147
+ start(options?: LDStartOptions): Promise<LDWaitForInitializationResult>;
148
+ };
149
+
150
+ /**
151
+ * Interface for plugins to the LaunchDarkly SDK.
152
+ */
153
+ interface LDPlugin extends LDPluginBase<LDClient, Hook> {
154
+ }
155
+
156
+ /**
157
+ * Initialization options for the LaunchDarkly browser SDK.
158
+ */
159
+ interface BrowserOptions extends Omit<LDOptions, 'initialConnectionMode'> {
160
+ /**
161
+ * Whether the client should make a request to LaunchDarkly for Experimentation metrics (goals).
162
+ *
163
+ * This is true by default, meaning that this request will be made on every page load.
164
+ * Set it to false if you are not using Experimentation and want to skip the request.
165
+ */
166
+ fetchGoals?: boolean;
167
+ /**
168
+ * A function which, if present, can change the URL in analytics events to something other
169
+ * than the actual browser URL. It will be called with the current browser URL as a parameter,
170
+ * and returns the value that should be stored in the event's `url` property.
171
+ *
172
+ * It may be useful to customize the `url` to provide specific meaning, incorporate
173
+ * client-side routing concerns, or redact tokens or other info.
174
+ */
175
+ eventUrlTransformer?: (url: string) => string;
176
+ /**
177
+ * Whether or not to open a streaming connection to LaunchDarkly for live flag updates.
178
+ *
179
+ * If this is true, the client will always attempt to maintain a streaming connection; if false,
180
+ * it never will. If you leave the value undefined (the default), the client will open a streaming
181
+ * connection if you subscribe to `"change"` or `"change:flag-key"` events.
182
+ *
183
+ * This is equivalent to calling `client.setStreaming()` with the same value.
184
+ */
185
+ streaming?: boolean;
186
+ /**
187
+ * Determines if the SDK responds to entering different visibility states, such as foreground and background.
188
+ * An example is flushing buffered events when going to the background.
189
+ *
190
+ * This is true by default. Generally speaking the SDK will be able to most reliably deliver
191
+ * events with this setting on.
192
+ *
193
+ * It may be useful to disable for environments where not all window/document objects are
194
+ * available, such as when running the SDK in a browser extension.
195
+ */
196
+ automaticBackgroundHandling?: boolean;
197
+ /**
198
+ * A list of plugins to be used with the SDK.
199
+ *
200
+ * Plugin support is currently experimental and subject to change.
201
+ */
202
+ plugins?: LDPlugin[];
203
+ }
204
+
205
+ /**
206
+ * Provides a basic {@link LDLogger} implementation.
207
+ *
208
+ * This logging implementation uses a basic format that includes only the log level
209
+ * and the message text. By default this uses log level 'info' and the output is
210
+ * written to `console.error`.
211
+ *
212
+ * To use the logger created by this function, put it into {@link LDOptions.logger}. If
213
+ * you do not set {@link LDOptions.logger} to anything, the SDK uses a default logger
214
+ * that will log "info" level and higher priorty messages and it will log messages to
215
+ * console.info, console.warn, and console.error.
216
+ *
217
+ * @param options Configuration for the logger. If no options are specified, the
218
+ * logger uses `{ level: 'info' }`.
219
+ *
220
+ * @example
221
+ * This example shows how to use `basicLogger` in your SDK options to enable console
222
+ * logging only at `warn` and `error` levels.
223
+ * ```javascript
224
+ * const ldOptions = {
225
+ * logger: basicLogger({ level: 'warn' }),
226
+ * };
227
+ * ```
228
+ *
229
+ * @example
230
+ * This example shows how to use `basicLogger` in your SDK options to cause all
231
+ * log output to go to `console.log`
232
+ * ```javascript
233
+ * const ldOptions = {
234
+ * logger: basicLogger({ destination: console.log }),
235
+ * };
236
+ * ```
237
+ *
238
+ * * @example
239
+ * The configuration also allows you to control the destination for each log level.
240
+ * ```javascript
241
+ * const ldOptions = {
242
+ * logger: basicLogger({
243
+ * destination: {
244
+ * debug: console.debug,
245
+ * info: console.info,
246
+ * warn: console.warn,
247
+ * error:console.error
248
+ * }
249
+ * }),
250
+ * };
251
+ * ```
252
+ */
253
+ declare function basicLogger(options: BasicLoggerOptions): LDLogger;
5
254
 
6
255
  /**
7
256
  * This is the API reference for the LaunchDarkly Client-Side SDK for JavaScript.
@@ -46,4 +295,4 @@ export { b as LDIdentifyOptions, a as LDPlugin, c as basicLogger } from './commo
46
295
  */
47
296
  declare function createClient(clientSideId: string, pristineContext: LDContext, options?: BrowserOptions): LDClient;
48
297
 
49
- export { LDClient, BrowserOptions as LDOptions, createClient };
298
+ export { type LDClient, type BrowserIdentifyOptions as LDIdentifyOptions, type BrowserOptions as LDOptions, type LDPlugin, type LDStartOptions, basicLogger, createClient };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,256 @@
1
- import { LDContext } from '@launchdarkly/js-client-sdk-common';
2
- export { AutoEnvAttributes, BasicLogger, BasicLoggerOptions, EvaluationSeriesContext, EvaluationSeriesData, Hook, HookMetadata, IdentifySeriesContext, IdentifySeriesData, IdentifySeriesResult, IdentifySeriesStatus, LDContext, LDContextCommon, LDContextMeta, LDDebugOverride, LDEvaluationDetail, LDEvaluationDetailTyped, LDEvaluationReason, LDFlagSet, LDFlagValue, LDIdentifyError, LDIdentifyResult, LDIdentifyShed, LDIdentifySuccess, LDIdentifyTimeout, LDInspection, LDLogLevel, LDLogger, LDMultiKindContext, LDPluginApplicationMetadata, LDPluginBase, LDPluginEnvironmentMetadata, LDPluginMetadata, LDPluginSdkMetadata, LDSingleKindContext, LDTimeoutError, LDWaitForInitializationComplete, LDWaitForInitializationFailed, LDWaitForInitializationOptions, LDWaitForInitializationResult, LDWaitForInitializationTimeout, TrackSeriesContext } from '@launchdarkly/js-client-sdk-common';
3
- import { B as BrowserOptions, L as LDClient } from './common-B4wKbl6r.js';
4
- export { b as LDIdentifyOptions, a as LDPlugin, c as basicLogger } from './common-B4wKbl6r.js';
1
+ import { LDIdentifyOptions, ItemDescriptor, LDClient as LDClient$1, LDContext, LDIdentifyResult, LDWaitForInitializationOptions, LDWaitForInitializationResult, LDPluginBase, Hook, LDOptions, BasicLoggerOptions, LDLogger } from '@launchdarkly/js-client-sdk-common';
2
+ export { AutoEnvAttributes, BasicLogger, BasicLoggerOptions, EvaluationSeriesContext, EvaluationSeriesData, Hook, HookMetadata, IdentifySeriesContext, IdentifySeriesData, IdentifySeriesResult, IdentifySeriesStatus, LDContext, LDContextCommon, LDContextMeta, LDContextStrict, LDDebugOverride, LDEvaluationDetail, LDEvaluationDetailTyped, LDEvaluationReason, LDFlagSet, LDFlagValue, LDIdentifyError, LDIdentifyResult, LDIdentifyShed, LDIdentifySuccess, LDIdentifyTimeout, LDInspection, LDLogLevel, LDLogger, LDMultiKindContext, LDPluginApplicationMetadata, LDPluginBase, LDPluginEnvironmentMetadata, LDPluginMetadata, LDPluginSdkMetadata, LDSingleKindContext, LDTimeoutError, LDWaitForInitializationComplete, LDWaitForInitializationFailed, LDWaitForInitializationOptions, LDWaitForInitializationResult, LDWaitForInitializationTimeout, TrackSeriesContext } from '@launchdarkly/js-client-sdk-common';
3
+
4
+ /**
5
+ * @property sheddable - If true, the identify operation will be sheddable. This means that if multiple identify operations are done, without
6
+ * waiting for the previous one to complete, then intermediate results will be discarded. When false, identify
7
+ * operations will be queued and completed sequentially.
8
+ *
9
+ * Defaults to true.
10
+ */
11
+ interface BrowserIdentifyOptions extends Omit<LDIdentifyOptions, 'waitForNetworkResults'> {
12
+ /**
13
+ * The signed context key if you are using [Secure Mode]
14
+ * (https://docs.launchdarkly.com/sdk/features/secure-mode#configuring-secure-mode-in-the-javascript-client-side-sdk).
15
+ */
16
+ hash?: string;
17
+ /**
18
+ * The initial set of flags to use until the remote set is retrieved.
19
+ *
20
+ * Bootstrap data can be generated by server SDKs. When bootstrap data is provided the SDK the
21
+ * identification operation will complete without waiting for any values from LaunchDarkly and
22
+ * the variation calls can be used immediately.
23
+ *
24
+ * If streaming is activated, either it is configured to always be used, or is activated
25
+ * via setStreaming, or via the addition of change handlers, then a streaming connection will
26
+ * subsequently be established.
27
+ *
28
+ * For more information, see the [SDK Reference Guide](https://docs.launchdarkly.com/sdk/features/bootstrapping#javascript).
29
+ */
30
+ bootstrap?: unknown;
31
+ /**
32
+ * Parsed bootstrap data that could be stored to ensure that the bootstrap data is only parsed once during the intialization
33
+ * process.
34
+ *
35
+ * @hidden
36
+ */
37
+ bootstrapParsed?: {
38
+ [key: string]: ItemDescriptor;
39
+ };
40
+ }
41
+
42
+ interface LDStartOptions extends LDWaitForInitializationOptions {
43
+ /**
44
+ * Optional bootstrap data to use for the identify operation. If {@link LDIdentifyOptions.bootstrap} is provided, it will be ignored.
45
+ */
46
+ bootstrap?: unknown;
47
+ /**
48
+ * Optional identify options to use for the identify operation. See {@link LDIdentifyOptions} for more information.
49
+ *
50
+ * @remarks
51
+ * Since the first identify option should never be sheddable, we omit the sheddable option from the interface to avoid confusion.
52
+ */
53
+ identifyOptions?: Omit<BrowserIdentifyOptions, 'sheddable'>;
54
+ }
55
+ /**
56
+ *
57
+ * The LaunchDarkly SDK client object.
58
+ *
59
+ * Applications should configure the client at page load time and reuse the same instance.
60
+ *
61
+ * For more information, see the [SDK Reference Guide](https://docs.launchdarkly.com/sdk/client-side/javascript).
62
+ */
63
+ type LDClient = Omit<LDClient$1, 'setConnectionMode' | 'getConnectionMode' | 'getOffline' | 'identify'> & {
64
+ /**
65
+ * @ignore
66
+ * Implementation Note: We are not supporting dynamically setting the connection mode on the LDClient.
67
+ * Implementation Note: The SDK does not support offline mode. Instead bootstrap data can be used.
68
+ * Implementation Note: The browser SDK has different identify options, so omits the base implementation
69
+ * from the interface.
70
+ */
71
+ /**
72
+ * Specifies whether or not to open a streaming connection to LaunchDarkly for live flag updates.
73
+ *
74
+ * If this is true, the client will always attempt to maintain a streaming connection; if false,
75
+ * it never will. If you leave the value undefined (the default), the client will open a streaming
76
+ * connection if you subscribe to `"change"` or `"change:flag-key"` events (see {@link LDClient.on}).
77
+ *
78
+ * This can also be set as the `streaming` property of {@link LDOptions}.
79
+ */
80
+ setStreaming(streaming?: boolean): void;
81
+ /**
82
+ * Identifies a context to LaunchDarkly and returns a promise which resolves to an object containing the result of
83
+ * the identify operation.
84
+ *
85
+ * Unlike the server-side SDKs, the client-side JavaScript SDKs maintain a current context state,
86
+ * which is set when you call `identify()`.
87
+ *
88
+ * Changing the current context also causes all feature flag values to be reloaded. Until that has
89
+ * finished, calls to {@link variation} will still return flag values for the previous context. You can
90
+ * await the Promise to determine when the new flag values are available.
91
+ *
92
+ * If used with the `sheddable` option set to true, then the identify operation will be sheddable. This means that if
93
+ * multiple identify operations are done, without waiting for the previous one to complete, then intermediate
94
+ * operations may be discarded.
95
+ *
96
+ * @param context
97
+ * The LDContext object.
98
+ * @param identifyOptions
99
+ * Optional configuration. Please see {@link LDIdentifyOptions}.
100
+ * @returns
101
+ * A promise which resolves to an object containing the result of the identify operation.
102
+ * The promise returned from this method will not be rejected.
103
+ *
104
+ * @ignore Implementation Note: Browser implementation has different options.
105
+ */
106
+ identify(pristineContext: LDContext, identifyOptions?: BrowserIdentifyOptions): Promise<LDIdentifyResult>;
107
+ /**
108
+ * Returns a Promise that tracks the client's initialization state.
109
+ *
110
+ * The Promise will be resolved to a {@link LDWaitForInitializationResult} object containing the
111
+ * status of the waitForInitialization operation.
112
+ *
113
+ * @example
114
+ * This example shows use of async/await syntax for specifying handlers:
115
+ * ```
116
+ * const result = await client.waitForInitialization({ timeout: 5 });
117
+ *
118
+ * if (result.status === 'complete') {
119
+ * doSomethingWithSuccessfullyInitializedClient();
120
+ * } else if (result.status === 'failed') {
121
+ * doSomethingForFailedStartup(result.error);
122
+ * } else if (result.status === 'timeout') {
123
+ * doSomethingForTimedOutStartup();
124
+ * }
125
+ * ```
126
+ *
127
+ * @remarks
128
+ * You can also use event listeners ({@link on}) for the same purpose: the event `"initialized"`
129
+ * indicates success, and `"error"` indicates an error.
130
+ *
131
+ * @param options
132
+ * Optional configuration. Please see {@link LDWaitForInitializationOptions}.
133
+ *
134
+ * @returns
135
+ * A Promise that will be resolved to a {@link LDWaitForInitializationResult} object containing the
136
+ * status of the waitForInitialization operation.
137
+ */
138
+ waitForInitialization(options?: LDWaitForInitializationOptions): Promise<LDWaitForInitializationResult>;
139
+ /**
140
+ * Starts the client and returns a promise that resolves to the initialization result.
141
+ *
142
+ * The promise will resolve to a {@link LDWaitForInitializationResult} object containing the
143
+ * status of the waitForInitialization operation.
144
+ *
145
+ * @param options Optional configuration. Please see {@link LDStartOptions}.
146
+ */
147
+ start(options?: LDStartOptions): Promise<LDWaitForInitializationResult>;
148
+ };
149
+
150
+ /**
151
+ * Interface for plugins to the LaunchDarkly SDK.
152
+ */
153
+ interface LDPlugin extends LDPluginBase<LDClient, Hook> {
154
+ }
155
+
156
+ /**
157
+ * Initialization options for the LaunchDarkly browser SDK.
158
+ */
159
+ interface BrowserOptions extends Omit<LDOptions, 'initialConnectionMode'> {
160
+ /**
161
+ * Whether the client should make a request to LaunchDarkly for Experimentation metrics (goals).
162
+ *
163
+ * This is true by default, meaning that this request will be made on every page load.
164
+ * Set it to false if you are not using Experimentation and want to skip the request.
165
+ */
166
+ fetchGoals?: boolean;
167
+ /**
168
+ * A function which, if present, can change the URL in analytics events to something other
169
+ * than the actual browser URL. It will be called with the current browser URL as a parameter,
170
+ * and returns the value that should be stored in the event's `url` property.
171
+ *
172
+ * It may be useful to customize the `url` to provide specific meaning, incorporate
173
+ * client-side routing concerns, or redact tokens or other info.
174
+ */
175
+ eventUrlTransformer?: (url: string) => string;
176
+ /**
177
+ * Whether or not to open a streaming connection to LaunchDarkly for live flag updates.
178
+ *
179
+ * If this is true, the client will always attempt to maintain a streaming connection; if false,
180
+ * it never will. If you leave the value undefined (the default), the client will open a streaming
181
+ * connection if you subscribe to `"change"` or `"change:flag-key"` events.
182
+ *
183
+ * This is equivalent to calling `client.setStreaming()` with the same value.
184
+ */
185
+ streaming?: boolean;
186
+ /**
187
+ * Determines if the SDK responds to entering different visibility states, such as foreground and background.
188
+ * An example is flushing buffered events when going to the background.
189
+ *
190
+ * This is true by default. Generally speaking the SDK will be able to most reliably deliver
191
+ * events with this setting on.
192
+ *
193
+ * It may be useful to disable for environments where not all window/document objects are
194
+ * available, such as when running the SDK in a browser extension.
195
+ */
196
+ automaticBackgroundHandling?: boolean;
197
+ /**
198
+ * A list of plugins to be used with the SDK.
199
+ *
200
+ * Plugin support is currently experimental and subject to change.
201
+ */
202
+ plugins?: LDPlugin[];
203
+ }
204
+
205
+ /**
206
+ * Provides a basic {@link LDLogger} implementation.
207
+ *
208
+ * This logging implementation uses a basic format that includes only the log level
209
+ * and the message text. By default this uses log level 'info' and the output is
210
+ * written to `console.error`.
211
+ *
212
+ * To use the logger created by this function, put it into {@link LDOptions.logger}. If
213
+ * you do not set {@link LDOptions.logger} to anything, the SDK uses a default logger
214
+ * that will log "info" level and higher priorty messages and it will log messages to
215
+ * console.info, console.warn, and console.error.
216
+ *
217
+ * @param options Configuration for the logger. If no options are specified, the
218
+ * logger uses `{ level: 'info' }`.
219
+ *
220
+ * @example
221
+ * This example shows how to use `basicLogger` in your SDK options to enable console
222
+ * logging only at `warn` and `error` levels.
223
+ * ```javascript
224
+ * const ldOptions = {
225
+ * logger: basicLogger({ level: 'warn' }),
226
+ * };
227
+ * ```
228
+ *
229
+ * @example
230
+ * This example shows how to use `basicLogger` in your SDK options to cause all
231
+ * log output to go to `console.log`
232
+ * ```javascript
233
+ * const ldOptions = {
234
+ * logger: basicLogger({ destination: console.log }),
235
+ * };
236
+ * ```
237
+ *
238
+ * * @example
239
+ * The configuration also allows you to control the destination for each log level.
240
+ * ```javascript
241
+ * const ldOptions = {
242
+ * logger: basicLogger({
243
+ * destination: {
244
+ * debug: console.debug,
245
+ * info: console.info,
246
+ * warn: console.warn,
247
+ * error:console.error
248
+ * }
249
+ * }),
250
+ * };
251
+ * ```
252
+ */
253
+ declare function basicLogger(options: BasicLoggerOptions): LDLogger;
5
254
 
6
255
  /**
7
256
  * This is the API reference for the LaunchDarkly Client-Side SDK for JavaScript.
@@ -46,4 +295,4 @@ export { b as LDIdentifyOptions, a as LDPlugin, c as basicLogger } from './commo
46
295
  */
47
296
  declare function createClient(clientSideId: string, pristineContext: LDContext, options?: BrowserOptions): LDClient;
48
297
 
49
- export { LDClient, BrowserOptions as LDOptions, createClient };
298
+ export { type LDClient, type BrowserIdentifyOptions as LDIdentifyOptions, type BrowserOptions as LDOptions, type LDPlugin, type LDStartOptions, basicLogger, createClient };