Skip to content
Merged
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
22 changes: 22 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
package-node-server-sdk-otel-release: ${{ steps.release.outputs['packages/telemetry/node-server-sdk-otel--release_created'] }}
package-tooling-jest-release: ${{ steps.release.outputs['packages/tooling/jest--release_created'] }}
package-react-universal-release: ${{ steps.release.outputs['packages/sdk/react-universal--release_created'] }}
package-browser-released: ${{ steps.release.outputs['packages/sdk/browser--release_created'] }}
steps:
- uses: googleapis/release-please-action@v4
id: release
Expand Down Expand Up @@ -170,6 +171,27 @@ jobs:
workspace_path: packages/sdk/react-native
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}

release-browser:
runs-on: ubuntu-latest
needs: ['release-please', 'release-sdk-client']
permissions:
id-token: write
contents: write
if: ${{ always() && !failure() && !cancelled() && needs.release-please.outputs.package-browser-released == 'true'}}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
registry-url: 'https://registry.npmjs.org'
- id: release-react-native
name: Full release of packages/sdk/browser
uses: ./actions/full-release
with:
workspace_path: packages/sdk/browser
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}


release-server-node:
runs-on: ubuntu-latest
needs: ['release-please', 'release-sdk-server']
Expand Down
3 changes: 2 additions & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
"packages/store/node-server-sdk-redis": "4.1.23",
"packages/shared/sdk-client": "1.9.0",
"packages/sdk/react-native": "10.8.0",
"packages/telemetry/node-server-sdk-otel": "1.0.15"
"packages/telemetry/node-server-sdk-otel": "1.0.15",
"packages/sdk/browser": "0.0.0"
}
5 changes: 4 additions & 1 deletion packages/sdk/browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
[![NPM][browser-sdk-dt-badge]][browser-sdk-npm-link]
-->

# ⛔️⛔️⛔️⛔️
> [!CAUTION]
> This library is a beta version and should not be considered ready for production use while this message is visible.
> This library is a alpha version and should not be considered ready for production use while this message is visible.

# ☝️☝️☝️☝️☝️☝️

<!--
## Install
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { init, LDClient, LDLogger, LDOptions } from '@launchdarkly/js-client-sdk';
import { initialize, LDClient, LDLogger, LDOptions } from '@launchdarkly/js-client-sdk';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the name to match existing package.

It means client/server are not consistent, so we may want to add init to the client, or add initialize to the server, then mark as deprecated.


import { CommandParams, CommandType, ValueType } from './CommandParams';
import { CreateInstanceParams, SDKConfigParams } from './ConfigParams';
Expand All @@ -19,7 +19,6 @@ function makeSdkConfig(options: SDKConfigParams, tag: string) {
withReasons: options.clientSide.evaluationReasons,
logger: makeLogger(`${tag}.sdk`),
// useReport: options.clientSide.useReport,
// sendEventsOnlyForVariation: true,
};

if (options.serviceEndpoints) {
Expand Down Expand Up @@ -198,7 +197,7 @@ export async function newSdkClientEntity(options: CreateInstanceParams) {
options.configuration.clientSide?.initialUser ||
options.configuration.clientSide?.initialContext ||
makeDefaultInitialContext();
const client = init(options.configuration.credential || 'unknown-env-id', sdkConfig);
const client = initialize(options.configuration.credential || 'unknown-env-id', sdkConfig);
let failed = false;
try {
await Promise.race([
Expand Down
2 changes: 0 additions & 2 deletions packages/sdk/browser/contract-tests/entity/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import './style.css';
import TestHarnessWebSocket from './TestHarnessWebSocket';

// const client = init('618959580d89aa15579acf1d', AutoEnvAttributes.Enabled);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot this at some point. Ok though client-side IDs are not secret.


async function runContractTests() {
const ws = new TestHarnessWebSocket('ws://localhost:8001');
ws.connect();
Expand Down
13 changes: 8 additions & 5 deletions packages/sdk/browser/src/BrowserClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,19 @@ import BrowserPlatform from './platform/BrowserPlatform';
* Applications should configure the client at page load time and reuse the same instance.
*
* For more information, see the [SDK Reference Guide](https://docs.launchdarkly.com/sdk/client-side/javascript).
*
* @ignore Implementation Note: We are not supporting dynamically setting the connection mode on the LDClient.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This caused the entire type not to be in the docs. Moved these implementation notes.

* @ignore Implementation Note: The SDK does not support offline mode. Instead bootstrap data can be used.
* @ignore Implementation Note: The browser SDK has different identify options, so omits the base implementation
* @ignore from the interface.
*/
export type LDClient = Omit<
CommonClient,
'setConnectionMode' | 'getConnectionMode' | 'getOffline' | 'identify'
> & {
/**
* @ignore
* Implementation Note: We are not supporting dynamically setting the connection mode on the LDClient.
* Implementation Note: The SDK does not support offline mode. Instead bootstrap data can be used.
* Implementation Note: The browser SDK has different identify options, so omits the base implementation
* from the interface.
*/

/**
* Specifies whether or not to open a streaming connection to LaunchDarkly for live flag updates.
*
Expand Down
30 changes: 29 additions & 1 deletion packages/sdk/browser/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/**
* This is the API reference for the LaunchDarkly Client-Side SDK for JavaScript.
*
* This SDK is intended for use in browser environments.
*
* In typical usage, you will call {@link initialize} 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.
*
* @packageDocumentation
*/
import {
AutoEnvAttributes,
EvaluationSeriesContext,
Expand Down Expand Up @@ -52,7 +64,23 @@ export type {
IdentifySeriesStatus,
};

export function init(clientSideId: string, options?: LDOptions): LDClient {
/**
* Creates an instance of the LaunchDarkly client.
*
* Usage:
* ```
* import { initialize } from 'launchdarkly-js-client-sdk';
* const client = initialize(envKey, context, options);
* ```
*
* @param clientSideId
* The client-side id, also known as the environment ID.
* @param options
* Optional configuration settings.
* @return
* The new client instance.
*/
export function initialize(clientSideId: string, options?: LDOptions): LDClient {
// AutoEnvAttributes are not supported yet in the browser SDK.
return new BrowserClient(clientSideId, AutoEnvAttributes.Disabled, options);
}
3 changes: 2 additions & 1 deletion release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
},
"packages/store/node-server-sdk-dynamodb": {},
"packages/store/node-server-sdk-redis": {},
"packages/telemetry/node-server-sdk-otel": {}
"packages/telemetry/node-server-sdk-otel": {},
"packages/sdk/browser": {}
},
"plugins": [
{
Expand Down