Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/sdk/combined-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"check": "yarn prettier && yarn lint && yarn build && yarn test"
},
"dependencies": {
"@launchdarkly/js-client-sdk": "0.7.0",
"@launchdarkly/js-client-sdk": "0.11.0",
"@launchdarkly/observability": "0.2.0",
"@launchdarkly/session-replay": "0.2.0"
},
Expand Down
28 changes: 22 additions & 6 deletions packages/sdk/combined-browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
*
* This SDK is intended for use in browser environments. It includes the observability and session replay plugins.
*
* In typical usage, you will call {@link initialize} once at startup time to obtain an instance of
* In typical usage, you will call {@link createClient} once at startup time to obtain an instance of
* {@link LDClient}, which provides access to all of the SDK's functionality.
*
* For more information, see the [SDK Reference Guide](https://docs.launchdarkly.com/sdk/client-side/javascript).
*
* @packageDocumentation
*/
import { initialize as initializeJsClient, LDClient, LDOptions } from '@launchdarkly/js-client-sdk';
import {
createClient as createClientJs,
LDClient,
LDContext,
LDOptions,
} from '@launchdarkly/js-client-sdk';
import Observability, { ObserveOptions } from '@launchdarkly/observability';
import SessionReplay, { RecordOptions } from '@launchdarkly/session-replay';

Expand Down Expand Up @@ -42,18 +47,29 @@ export interface LDBrowserOptions extends LDOptions {
*
* Usage:
* ```
* import { initialize } from '@launchdarkly/browser';
* const client = initialize(clientSideId, context, options);
* import { createClient } from '@launchdarkly/browser';
* const client = createClient(clientSideId, context, options);
*
* // Attach event listeners and add any additional initialization logic here
*
* // Then start the client
* client.start();
* ```
*
* @param clientSideId
* The client-side ID, also known as the environment ID.
* @param context
* The initial context used to identify the user. @see {@link LDContext}
* @param options
* Optional configuration settings.
* @return
* The new client instance.
*/
export function initialize(clientSideId: string, options?: LDBrowserOptions): LDClient {
export function createClient(
clientSideId: string,
context: LDContext,
options?: LDBrowserOptions,
): LDClient {
const optionsWithPlugins = {
...options,
plugins: [
Expand All @@ -62,5 +78,5 @@ export function initialize(clientSideId: string, options?: LDBrowserOptions): LD
new SessionReplay(options?.tmpProjectId ?? '1', options?.sessionReplay),
],
};
return initializeJsClient(clientSideId, optionsWithPlugins);
return createClientJs(clientSideId, context, optionsWithPlugins);
}
Loading