Skip to content

Commit 1d5ca40

Browse files
authored
feat: React Native SDK major release. (#369)
This prepares for the React Native SDK major release as well as the release of common/client-sdk.
1 parent 6349b98 commit 1d5ca40

File tree

15 files changed

+125
-93
lines changed

15 files changed

+125
-93
lines changed

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ This includes shared libraries, used by SDKs and other tools, as well as SDKs.
77

88
| SDK packages | npm | issues | tests |
99
| ------------------------------------------------------------------------------ | ----------------------------------------------------------------- | ------------------------------------------------- | --------------------------------------------------------------------- |
10+
| [@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] |
11+
| [@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] |
1012
| [@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] |
1113
| [@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] |
1214
| [@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] |
13-
| [@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] |
14-
| [@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] |
15+
| [@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] |
1516

1617
| Shared packages | npm | issues | tests |
1718
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------- |
1819
| [@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] |
20+
| [@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] |
1921
| [@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] |
2022
| [@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] |
2123

@@ -74,6 +76,12 @@ We encourage pull requests and other contributions from the community. Check out
7476
[shared-sdk-server-ci-badge]: https://github.com/launchdarkly/js-core/actions/workflows/sdk-server.yml/badge.svg
7577
[shared-sdk-server-ci]: https://github.com/launchdarkly/js-core/actions/workflows/sdk-server.yml
7678
[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+
79+
[//]: # 'shared/sdk-client'
80+
[js-client-sdk-common-npm-badge]: https://img.shields.io/npm/v/@launchdarkly/js-client-sdk-common.svg?style=flat-square
81+
[js-client-sdk-common-npm-link]: https://www.npmjs.com/package/@launchdarkly/js-client-sdk-common
82+
[shared-sdk-client-ci-badge]: https://github.com/launchdarkly/js-core/actions/workflows/sdk-client.yml/badge.svg
83+
[shared-sdk-client-ci]: https://github.com/launchdarkly/js-core/actions/workflows/sdk-client.yml
84+
[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+
7785
[//]: # 'shared/sdk-server-edge'
7886
[js-server-sdk-common-edge-badge]: https://img.shields.io/npm/v/@launchdarkly/js-server-sdk-common-edge.svg?style=flat-square
7987
[js-server-sdk-common-edge-link]: https://www.npmjs.com/package/@launchdarkly/js-server-sdk-common-edge
@@ -106,6 +114,16 @@ We encourage pull requests and other contributions from the community. Check out
106114
[sdk-vercel-dm-badge]: https://img.shields.io/npm/dm/@launchdarkly/vercel-server-sdk.svg?style=flat-square
107115
[sdk-vercel-dt-badge]: https://img.shields.io/npm/dt/@launchdarkly/vercel-server-sdk.svg?style=flat-square
108116
[package-sdk-vercel-issues]: https://github.com/launchdarkly/js-core/issues?q=is%3Aissue+is%3Aopen+label%3A%22package%3A+sdk%2Fvercel%22+
117+
[//]: # 'sdk/react-native'
118+
[sdk-react-native-ci-badge]: https://github.com/launchdarkly/js-core/actions/workflows/react-native.yml/badge.svg
119+
[sdk-react-native-ci]: https://github.com/launchdarkly/js-core/actions/workflows/react-native.yml
120+
[sdk-react-native-npm-badge]: https://img.shields.io/npm/v/@launchdarkly/react-native-client-sdk.svg?style=flat-square
121+
[sdk-react-native-npm-link]: https://www.npmjs.com/package/@launchdarkly/react-native-client-sdk
122+
[sdk-react-native-ghp-badge]: https://img.shields.io/static/v1?label=GitHub+Pages&message=API+reference&color=00add8
123+
[sdk-react-native-ghp-link]: https://launchdarkly.github.io/js-core/packages/sdk/react-native/docs/
124+
[sdk-react-native-dm-badge]: https://img.shields.io/npm/dm/@launchdarkly/react-native-client-sdk.svg?style=flat-square
125+
[sdk-react-native-dt-badge]: https://img.shields.io/npm/dt/@launchdarkly/react-native-client-sdk.svg?style=flat-square
126+
[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+
109127
[//]: # 'sdk/akamai-base'
110128
[sdk-akamai-base-ci-badge]: https://github.com/launchdarkly/js-core/actions/workflows/akamai-base.yml/badge.svg
111129
[sdk-akamai-base-ci]: https://github.com/launchdarkly/js-core/actions/workflows/akamai-base.yml

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"scripts": {
2424
"clean": "yarn workspaces foreach -pt run clean",
2525
"build": "yarn workspaces foreach -p --topological-dev run build",
26-
"//": "When using build:doc you need to specify the workspace. 'yarn run build:doc packages/shared/common' for example.",
26+
"//": "When using build:doc you need to specify the workspace. 'yarn run build:doc -- packages/shared/common' for example.",
2727
"build:doc": "npx typedoc --options $1/typedoc.json",
2828
"lint": "npx eslint . --ext .ts",
2929
"lint:fix": "yarn run lint -- --fix",

packages/sdk/react-native/README.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@
66
[![NPM][sdk-react-native-dm-badge]][sdk-react-native-npm-link]
77
[![NPM][sdk-react-native-dt-badge]][sdk-react-native-npm-link]
88

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

12-
The LaunchDarkly React Native SDK is designed primarily for use in mobile environments. It follows the client-side LaunchDarkly model for multi-user contexts.
13-
14-
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.
12+
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
13+
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.
14+
It is implemented purely in JS and supports Expo. Please consider updating your application to use this package instead.
1515

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

18-
This library is an alpha version and should not be considered ready for production use while this message is visible.
19-
2018
## Install
2119

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

3634
## Quickstart
3735

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

41-
```jsx
39+
```tsx
4240
// App.tsx
4341
import { LDProvider, ReactNativeLDClient } from '@launchdarkly/react-native-client-sdk';
4442

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

48-
const App = () => (
49-
<LDProvider client={featureClient} context={userContext}>
50-
<Welcome />
51-
</LDProvider>
52-
);
46+
const App = () => {
47+
useEffect(() => {
48+
featureClient.identify(userContext).catch((e) => console.error(e));
49+
}, []);
50+
51+
return (
52+
<LDProvider client={featureClient}>
53+
<YourComponent />
54+
</LDProvider>
55+
);
56+
};
5357

5458
export default App;
5559
```

packages/shared/sdk-client/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
1010
This project contains Typescript classes and interfaces that are applicable to client-side SDKs.
1111

12-
This library is a beta version and should not be considered ready for production use while this message is visible.
13-
1412
## Contributing
1513

1614
See [Contributing](../CONTRIBUTING.md).

packages/shared/sdk-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "commonjs",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",
7-
"homepage": "https://github.com/launchdarkly/js-core/tree/main/packages/shared/sdk-server",
7+
"homepage": "https://github.com/launchdarkly/js-core/tree/main/packages/shared/sdk-client",
88
"repository": {
99
"type": "git",
1010
"url": "https://github.com/launchdarkly/js-core.git"

packages/shared/sdk-client/src/LDClientImpl.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ describe('sdk-client object', () => {
7474
diagnosticOptOut: false,
7575
diagnosticRecordingInterval: 900,
7676
eventsUri: 'https://events.launchdarkly.com',
77-
flushInterval: 2,
77+
flushInterval: 30,
7878
inspectors: [],
7979
logger: {
8080
destination: expect.any(Function),

packages/shared/sdk-client/src/api/ConnectionMode.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* The connection mode for the SDK to use.
33
*
44
* @remarks
5-
*
65
* The following connection modes are supported:
76
*
87
* offline - When the SDK is set offline it will stop receiving updates and will stop sending

packages/shared/sdk-client/src/api/LDClient.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ export interface LDClient {
8282

8383
/**
8484
* Gets the SDK connection mode.
85+
*
86+
* @remarks
87+
* Possible values are offline or streaming. See {@link ConnectionMode} for more information.
8588
*/
8689
getConnectionMode(): ConnectionMode;
8790

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

148151
/**
149-
* Returns the logger configured as part of LDOptions during construction.
152+
* The logger configured as part of LDOptions during construction.
153+
*
154+
* @remarks
155+
* For more information, read {@link LDOptions.logger} and {@link LDLogger}.
150156
*
151-
* For more, read {@link LDOptions.logger}.
157+
* @returns The configured {@link LDLogger}.
152158
*/
153159
logger: LDLogger;
154160

@@ -169,6 +175,7 @@ export interface LDClient {
169175
* Determines the numeric variation of a feature flag for a context, along with information about
170176
* how it was calculated.
171177
*
178+
* @remarks
172179
* The `reason` property of the result will also be included in analytics events, if you are
173180
* capturing detailed event data for this flag.
174181
*
@@ -199,16 +206,18 @@ export interface LDClient {
199206
/**
200207
* Registers an event listener.
201208
*
202-
* The following event names (keys) are used by the client:
209+
* @remarks
210+
* You can subscribe to one of the supported {@link EventName}:
203211
*
204-
* - `"error"`: General event for any kind of error condition during client operation.
205-
* The callback parameter is an Error object. If you do not listen for "error"
206-
* events, then the errors will be logged with `console.log()`.
207212
* - `"change"`: The client has received new feature flag data. This can happen either
208213
* because you have switched contexts with {@link identify}, or because the client has a
209214
* stream connection and has received a live change to a flag value (see below).
210215
* The callback parameters are the context and an array of flag keys that have changed.
211216
*
217+
* - `"error"`: General event for any kind of error condition during client operation.
218+
* The callback parameters are the context and an Error object. Errors are also output by
219+
* the {@link logger} at the error level.
220+
*
212221
* @param key
213222
* The name of the event for which to listen.
214223
* @param callback
@@ -220,7 +229,7 @@ export interface LDClient {
220229
/**
221230
* Sets the SDK connection mode.
222231
*
223-
* @param mode - One of supported {@link ConnectionMode}. By default, the SDK uses 'streaming'.
232+
* @param mode - One of supported {@link ConnectionMode}. By default, the SDK uses streaming.
224233
*/
225234
setConnectionMode(mode: ConnectionMode): void;
226235

@@ -241,6 +250,7 @@ export interface LDClient {
241250
* Determines the string variation of a feature flag for a context, along with information about
242251
* how it was calculated.
243252
*
253+
* @remarks
244254
* The `reason` property of the result will also be included in analytics events, if you are
245255
* capturing detailed event data for this flag.
246256
*
@@ -277,6 +287,7 @@ export interface LDClient {
277287
* We recommend using strongly typed variation methods which perform
278288
* type checks and handle type errors.
279289
*
290+
* @remarks
280291
* Determines the variation of a feature flag.
281292
*
282293
* In the client-side JavaScript SDKs, this is always a fast synchronous operation because all of
@@ -295,6 +306,7 @@ export interface LDClient {
295306
* We recommend using strongly typed variation detail methods which perform
296307
* type checks and handle type errors.
297308
*
309+
* @remarks
298310
* Determines the variation of a feature flag for a context, along with information about how it was
299311
* calculated.
300312
*

0 commit comments

Comments
 (0)