Skip to content

Commit

Permalink
feat: React Native SDK major release. (#369)
Browse files Browse the repository at this point in the history
This prepares for the React Native SDK major release as well as the
release of common/client-sdk.
  • Loading branch information
yusinto authored Feb 8, 2024
1 parent 6349b98 commit 1d5ca40
Show file tree
Hide file tree
Showing 15 changed files with 125 additions and 93 deletions.
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ This includes shared libraries, used by SDKs and other tools, as well as SDKs.

| SDK packages | npm | issues | tests |
| ------------------------------------------------------------------------------ | ----------------------------------------------------------------- | ------------------------------------------------- | --------------------------------------------------------------------- |
| [@launchdarkly/akamai-server-base-sdk](packages/sdk/akamai-base/README.md) | [![NPM][sdk-akamai-base-npm-badge]][sdk-akamai-base-npm-link] | [Akamai Base][package-sdk-akamai-base-issues] | [![Actions Status][sdk-akamai-base-ci-badge]][sdk-akamai-base-ci] |
| [@launchdarkly/akamai-server-edgekv-sdk](packages/sdk/akamai-edgekv/README.md) | [![NPM][sdk-akamai-edgekv-npm-badge]][sdk-akamai-edgekv-npm-link] | [Akamai EdgeKV][package-sdk-akamai-edgekv-issues] | [![Actions Status][sdk-akamai-edgekv-ci-badge]][sdk-akamai-edgekv-ci] |
| [@launchdarkly/cloudflare-server-sdk](packages/sdk/cloudflare/README.md) | [![NPM][sdk-cloudflare-npm-badge]][sdk-cloudflare-npm-link] | [Cloudflare][package-sdk-cloudflare-issues] | [![Actions Status][sdk-cloudflare-ci-badge]][sdk-cloudflare-ci] |
| [@launchdarkly/node-server-sdk](packages/sdk/server-node/README.md) | [![NPM][sdk-server-node-npm-badge]][sdk-server-node-npm-link] | [Node.js Server][package-sdk-server-node-issues] | [![Actions Status][sdk-server-node-ci-badge]][sdk-server-node-ci] |
| [@launchdarkly/vercel-server-sdk](packages/sdk/vercel/README.md) | [![NPM][sdk-vercel-npm-badge]][sdk-vercel-npm-link] | [Vercel][package-sdk-vercel-issues] | [![Actions Status][sdk-vercel-ci-badge]][sdk-vercel-ci] |
| [@launchdarkly/akamai-server-base-sdk](packages/sdk/akamai-base/README.md) | [![NPM][sdk-akamai-base-npm-badge]][sdk-akamai-base-npm-link] | [Akamai Base][package-sdk-akamai-base-issues] | [![Actions Status][sdk-akamai-base-ci-badge]][sdk-akamai-base-ci] |
| [@launchdarkly/akamai-server-edgekv-sdk](packages/sdk/akamai-edgekv/README.md) | [![NPM][sdk-akamai-edgekv-npm-badge]][sdk-akamai-edgekv-npm-link] | [Akamai EdgeKV][package-sdk-akamai-edgekv-issues] | [![Actions Status][sdk-akamai-edgekv-ci-badge]][sdk-akamai-edgekv-ci] |
| [@launchdarkly/react-native-client-sdk](packages/sdk/react-native/README.md) | [![NPM][sdk-react-native-npm-badge]][sdk-react-native-npm-link] | [React-Native][package-sdk-react-native-issues] | [![Actions Status][sdk-react-native-ci-badge]][sdk-react-native-ci] |

| Shared packages | npm | issues | tests |
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------- |
| [@launchdarkly/js-sdk-common](packages/shared/common/README.md) | [![NPM][common-npm-badge]][common-npm-link] | [Common][package-shared-common-issues] | [![Actions Status][shared-common-ci-badge]][shared-common-ci] |
| [@launchdarkly/js-client-sdk-common](packages/shared/sdk-client/README.md) | [![NPM][js-client-sdk-common-npm-badge]][js-client-sdk-common-npm-link] | [Common Client][package-shared-sdk-client-issues] | [![Actions Status][shared-sdk-client-ci-badge]][shared-sdk-client-ci] |
| [@launchdarkly/js-server-sdk-common](packages/shared/sdk-server/README.md) | [![NPM][js-server-sdk-common-npm-badge]][js-server-sdk-common-npm-link] | [Common Server][package-shared-sdk-server-issues] | [![Actions Status][shared-sdk-server-ci-badge]][shared-sdk-server-ci] |
| [@launchdarkly/js-server-sdk-common-edge](packages/shared/sdk-server-edge/README.md) | [![NPM][js-server-sdk-common-edge-badge]][js-server-sdk-common-edge-link] | [Common Server Edge][package-shared-sdk-server-edge-issues] | [![Actions Status][shared-sdk-server-edge-ci-badge]][shared-sdk-server-edge-ci] |

Expand Down Expand Up @@ -74,6 +76,12 @@ We encourage pull requests and other contributions from the community. Check out
[shared-sdk-server-ci-badge]: https://github.com/launchdarkly/js-core/actions/workflows/sdk-server.yml/badge.svg
[shared-sdk-server-ci]: https://github.com/launchdarkly/js-core/actions/workflows/sdk-server.yml
[package-shared-sdk-server-issues]: https://github.com/launchdarkly/js-core/issues?q=is%3Aissue+is%3Aopen+label%3A%22package%3A+shared%2Fsdk-server%22+
[//]: # 'shared/sdk-client'
[js-client-sdk-common-npm-badge]: https://img.shields.io/npm/v/@launchdarkly/js-client-sdk-common.svg?style=flat-square
[js-client-sdk-common-npm-link]: https://www.npmjs.com/package/@launchdarkly/js-client-sdk-common
[shared-sdk-client-ci-badge]: https://github.com/launchdarkly/js-core/actions/workflows/sdk-client.yml/badge.svg
[shared-sdk-client-ci]: https://github.com/launchdarkly/js-core/actions/workflows/sdk-client.yml
[package-shared-sdk-client-issues]: https://github.com/launchdarkly/js-core/issues?q=is%3Aissue+is%3Aopen+label%3A%22package%3A+shared%2Fsdk-client%22+
[//]: # 'shared/sdk-server-edge'
[js-server-sdk-common-edge-badge]: https://img.shields.io/npm/v/@launchdarkly/js-server-sdk-common-edge.svg?style=flat-square
[js-server-sdk-common-edge-link]: https://www.npmjs.com/package/@launchdarkly/js-server-sdk-common-edge
Expand Down Expand Up @@ -106,6 +114,16 @@ We encourage pull requests and other contributions from the community. Check out
[sdk-vercel-dm-badge]: https://img.shields.io/npm/dm/@launchdarkly/vercel-server-sdk.svg?style=flat-square
[sdk-vercel-dt-badge]: https://img.shields.io/npm/dt/@launchdarkly/vercel-server-sdk.svg?style=flat-square
[package-sdk-vercel-issues]: https://github.com/launchdarkly/js-core/issues?q=is%3Aissue+is%3Aopen+label%3A%22package%3A+sdk%2Fvercel%22+
[//]: # 'sdk/react-native'
[sdk-react-native-ci-badge]: https://github.com/launchdarkly/js-core/actions/workflows/react-native.yml/badge.svg
[sdk-react-native-ci]: https://github.com/launchdarkly/js-core/actions/workflows/react-native.yml
[sdk-react-native-npm-badge]: https://img.shields.io/npm/v/@launchdarkly/react-native-client-sdk.svg?style=flat-square
[sdk-react-native-npm-link]: https://www.npmjs.com/package/@launchdarkly/react-native-client-sdk
[sdk-react-native-ghp-badge]: https://img.shields.io/static/v1?label=GitHub+Pages&message=API+reference&color=00add8
[sdk-react-native-ghp-link]: https://launchdarkly.github.io/js-core/packages/sdk/react-native/docs/
[sdk-react-native-dm-badge]: https://img.shields.io/npm/dm/@launchdarkly/react-native-client-sdk.svg?style=flat-square
[sdk-react-native-dt-badge]: https://img.shields.io/npm/dt/@launchdarkly/react-native-client-sdk.svg?style=flat-square
[package-sdk-react-native-issues]: https://github.com/launchdarkly/js-core/issues?q=is%3Aissue+is%3Aopen+label%3A%22package%3A+sdk%2Freact-native%22+
[//]: # 'sdk/akamai-base'
[sdk-akamai-base-ci-badge]: https://github.com/launchdarkly/js-core/actions/workflows/akamai-base.yml/badge.svg
[sdk-akamai-base-ci]: https://github.com/launchdarkly/js-core/actions/workflows/akamai-base.yml
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"scripts": {
"clean": "yarn workspaces foreach -pt run clean",
"build": "yarn workspaces foreach -p --topological-dev run build",
"//": "When using build:doc you need to specify the workspace. 'yarn run build:doc packages/shared/common' for example.",
"//": "When using build:doc you need to specify the workspace. 'yarn run build:doc -- packages/shared/common' for example.",
"build:doc": "npx typedoc --options $1/typedoc.json",
"lint": "npx eslint . --ext .ts",
"lint:fix": "yarn run lint -- --fix",
Expand Down
34 changes: 19 additions & 15 deletions packages/sdk/react-native/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@
[![NPM][sdk-react-native-dm-badge]][sdk-react-native-npm-link]
[![NPM][sdk-react-native-dt-badge]][sdk-react-native-npm-link]

> [!WARNING]
> UNSUPPORTED This SDK is in pre-release development and is not supported.
The LaunchDarkly React Native SDK is designed primarily for use in mobile environments. It follows the client-side
LaunchDarkly model for multi-user contexts.

The LaunchDarkly React Native SDK is designed primarily for use in mobile environments. It follows the client-side LaunchDarkly model for multi-user contexts.

This SDK is a replacement of [launchdarkly-react-native-client-sdk](https://github.com/launchdarkly/react-native-client-sdk). Please consider updating your application to use this package instead.
This SDK is a complete rewrite of the React Native SDK and replaces [launchdarkly-react-native-client-sdk](https://github.com/launchdarkly/react-native-client-sdk). The
APIs are based on the JS SDK rather than the iOS and Android SDKs. It is not a wrapper of the iOS and Android SDKs.
It is implemented purely in JS and supports Expo. Please consider updating your application to use this package instead.

For more information, see the [complete reference guide for this SDK](https://docs.launchdarkly.com/sdk/client-side/react-native).

This library is an alpha version and should not be considered ready for production use while this message is visible.

## Install

```shell
Expand All @@ -35,21 +33,27 @@ and re-run pod install for [auto-linking to work](https://github.com/react-nativ

## Quickstart

1. Wrap your application with `LDProvider` passing it an LDClient and
an LDContext:
1. Wrap your application with `LDProvider` and set the `client` prop to an instance of `ReactNativeLDClient`. Call
`identify` at a later time to get flags. In the example below, `identify` is called on App mount:

```jsx
```tsx
// App.tsx
import { LDProvider, ReactNativeLDClient } from '@launchdarkly/react-native-client-sdk';

const featureClient = new ReactNativeLDClient('mobile-key', AutoEnvAttributes.Enabled);
const userContext = { kind: 'user', key: 'test-user-1' };

const App = () => (
<LDProvider client={featureClient} context={userContext}>
<Welcome />
</LDProvider>
);
const App = () => {
useEffect(() => {
featureClient.identify(userContext).catch((e) => console.error(e));
}, []);

return (
<LDProvider client={featureClient}>
<YourComponent />
</LDProvider>
);
};

export default App;
```
Expand Down
2 changes: 0 additions & 2 deletions packages/shared/sdk-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
This project contains Typescript classes and interfaces that are applicable to client-side SDKs.

This library is a beta version and should not be considered ready for production use while this message is visible.

## Contributing

See [Contributing](../CONTRIBUTING.md).
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/sdk-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "commonjs",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"homepage": "https://github.com/launchdarkly/js-core/tree/main/packages/shared/sdk-server",
"homepage": "https://github.com/launchdarkly/js-core/tree/main/packages/shared/sdk-client",
"repository": {
"type": "git",
"url": "https://github.com/launchdarkly/js-core.git"
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/sdk-client/src/LDClientImpl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('sdk-client object', () => {
diagnosticOptOut: false,
diagnosticRecordingInterval: 900,
eventsUri: 'https://events.launchdarkly.com',
flushInterval: 2,
flushInterval: 30,
inspectors: [],
logger: {
destination: expect.any(Function),
Expand Down
1 change: 0 additions & 1 deletion packages/shared/sdk-client/src/api/ConnectionMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* The connection mode for the SDK to use.
*
* @remarks
*
* The following connection modes are supported:
*
* offline - When the SDK is set offline it will stop receiving updates and will stop sending
Expand Down
26 changes: 19 additions & 7 deletions packages/shared/sdk-client/src/api/LDClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ export interface LDClient {

/**
* Gets the SDK connection mode.
*
* @remarks
* Possible values are offline or streaming. See {@link ConnectionMode} for more information.
*/
getConnectionMode(): ConnectionMode;

Expand Down Expand Up @@ -146,9 +149,12 @@ export interface LDClient {
jsonVariationDetail(key: string, defaultValue: unknown): LDEvaluationDetailTyped<unknown>;

/**
* Returns the logger configured as part of LDOptions during construction.
* The logger configured as part of LDOptions during construction.
*
* @remarks
* For more information, read {@link LDOptions.logger} and {@link LDLogger}.
*
* For more, read {@link LDOptions.logger}.
* @returns The configured {@link LDLogger}.
*/
logger: LDLogger;

Expand All @@ -169,6 +175,7 @@ export interface LDClient {
* Determines the numeric variation of a feature flag for a context, along with information about
* how it was calculated.
*
* @remarks
* The `reason` property of the result will also be included in analytics events, if you are
* capturing detailed event data for this flag.
*
Expand Down Expand Up @@ -199,16 +206,18 @@ export interface LDClient {
/**
* Registers an event listener.
*
* The following event names (keys) are used by the client:
* @remarks
* You can subscribe to one of the supported {@link EventName}:
*
* - `"error"`: General event for any kind of error condition during client operation.
* The callback parameter is an Error object. If you do not listen for "error"
* events, then the errors will be logged with `console.log()`.
* - `"change"`: The client has received new feature flag data. This can happen either
* because you have switched contexts with {@link identify}, or because the client has a
* stream connection and has received a live change to a flag value (see below).
* The callback parameters are the context and an array of flag keys that have changed.
*
* - `"error"`: General event for any kind of error condition during client operation.
* The callback parameters are the context and an Error object. Errors are also output by
* the {@link logger} at the error level.
*
* @param key
* The name of the event for which to listen.
* @param callback
Expand All @@ -220,7 +229,7 @@ export interface LDClient {
/**
* Sets the SDK connection mode.
*
* @param mode - One of supported {@link ConnectionMode}. By default, the SDK uses 'streaming'.
* @param mode - One of supported {@link ConnectionMode}. By default, the SDK uses streaming.
*/
setConnectionMode(mode: ConnectionMode): void;

Expand All @@ -241,6 +250,7 @@ export interface LDClient {
* Determines the string variation of a feature flag for a context, along with information about
* how it was calculated.
*
* @remarks
* The `reason` property of the result will also be included in analytics events, if you are
* capturing detailed event data for this flag.
*
Expand Down Expand Up @@ -277,6 +287,7 @@ export interface LDClient {
* We recommend using strongly typed variation methods which perform
* type checks and handle type errors.
*
* @remarks
* Determines the variation of a feature flag.
*
* In the client-side JavaScript SDKs, this is always a fast synchronous operation because all of
Expand All @@ -295,6 +306,7 @@ export interface LDClient {
* We recommend using strongly typed variation detail methods which perform
* type checks and handle type errors.
*
* @remarks
* Determines the variation of a feature flag for a context, along with information about how it was
* calculated.
*
Expand Down
Loading

0 comments on commit 1d5ca40

Please sign in to comment.