From e888cfee9e41f5772a561334cb361bf980bbe9c8 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Wed, 27 Dec 2023 16:05:58 -0800 Subject: [PATCH] fix: remove beta warning for sdk-server. added tsdoc comments and readme for rn. --- .../react-native/src/ReactNativeLDClient.ts | 19 ++ packages/shared/sdk-client/README.md | 35 +++- .../shared/sdk-client/src/api/LDOptions.ts | 176 +++++++++--------- packages/shared/sdk-server/README.md | 2 - 4 files changed, 141 insertions(+), 91 deletions(-) diff --git a/packages/sdk/react-native/src/ReactNativeLDClient.ts b/packages/sdk/react-native/src/ReactNativeLDClient.ts index d642c5acf7..5058b4b9a9 100644 --- a/packages/sdk/react-native/src/ReactNativeLDClient.ts +++ b/packages/sdk/react-native/src/ReactNativeLDClient.ts @@ -9,7 +9,26 @@ import { import createPlatform from './platform'; +/** + * The React Native LaunchDarkly client. Instantiate this class to create an + * instance of the ReactNativeLDClient and pass it to the {@link LDProvider}. + * + * @example + * ```tsx + * const featureClient = new ReactNativeLDClient(MOBILE_KEY); + * + * + * + * + * ``` + */ export default class ReactNativeLDClient extends LDClientImpl { + /** + * Creates an instance of the LaunchDarkly client. + * + * @param sdkKey The LaunchDarkly mobile key. + * @param options {@link LDOptions} to initialize the client with. + */ constructor(sdkKey: string, options: LDOptions = {}) { const logger = options.logger ?? diff --git a/packages/shared/sdk-client/README.md b/packages/shared/sdk-client/README.md index 679c48c22e..ccc059e88e 100644 --- a/packages/shared/sdk-client/README.md +++ b/packages/shared/sdk-client/README.md @@ -1 +1,34 @@ -# sdk-client +# LaunchDarkly SDK JavaScript Common Client Code + +[![NPM][js-client-sdk-common-npm-badge]][js-client-sdk-common-npm-link] +[![Actions Status][shared-sdk-client-ci-badge]][shared-sdk-client-ci] +[![Documentation][shared-sdk-client-ghp-badge]][shared-sdk-client-ghp-link] + +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). + +## About LaunchDarkly + +- LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can: + - Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases. + - Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?). + - Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file. + - Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline. +- LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Check out [our documentation](https://docs.launchdarkly.com/sdk) for a complete list. +- Explore LaunchDarkly + - [launchdarkly.com](https://www.launchdarkly.com/ 'LaunchDarkly Main Website') for more information + - [docs.launchdarkly.com](https://docs.launchdarkly.com/ 'LaunchDarkly Documentation') for our documentation and SDK reference guides + - [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ 'LaunchDarkly API Documentation') for our API documentation + - [blog.launchdarkly.com](https://blog.launchdarkly.com/ 'LaunchDarkly Blog Documentation') for the latest product updates + +[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 +[shared-sdk-client-ghp-badge]: https://img.shields.io/static/v1?label=GitHub+Pages&message=API+reference&color=00add8 +[shared-sdk-client-ghp-link]: https://launchdarkly.github.io/js-core/packages/shared/sdk-client/docs/ diff --git a/packages/shared/sdk-client/src/api/LDOptions.ts b/packages/shared/sdk-client/src/api/LDOptions.ts index 946cce96e9..06484397c4 100644 --- a/packages/shared/sdk-client/src/api/LDOptions.ts +++ b/packages/shared/sdk-client/src/api/LDOptions.ts @@ -4,11 +4,44 @@ import type { LDInspection } from './LDInspection'; export interface LDOptions { /** - * An object that will perform logging for the client. + * Whether all context attributes (except the context key) should be marked as private, and + * not sent to LaunchDarkly in analytics events. * - * If not specified, the default is to use `basicLogger`. + * By default, this is false. */ - logger?: LDLogger; + allAttributesPrivate?: boolean; + + /** + * Information about the application where the LaunchDarkly SDK is running. + */ + application?: { + /** + * A unique identifier representing the application where the LaunchDarkly SDK is running. + * + * This can be specified as any string value as long as it only uses the following characters: ASCII letters, + * ASCII digits, period, hyphen, underscore. A string containing any other characters will be ignored. + * + * Example: `authentication-service` + */ + id?: string; + + /** + * A unique identifier representing the version of the application where the LaunchDarkly SDK is running. + * + * This can be specified as any string value as long as it only uses the following characters: ASCII letters, + * ASCII digits, period, hyphen, underscore. A string containing any other characters will be ignored. + * + * Example: `1.0.0` (standard version string) or `abcdef` (sha prefix) + */ + version?: string; + }; + + /** + * The base uri for the LaunchDarkly server. + * + * Most users should use the default value. + */ + baseUri?: string; /** * The initial set of flags to use until the remote set is retrieved. @@ -24,11 +57,37 @@ export interface LDOptions { bootstrap?: 'localStorage' | LDFlagSet; /** - * The base uri for the LaunchDarkly server. + * The capacity of the analytics events queue. * - * Most users should use the default value. + * The client buffers up to this many events in memory before flushing. If the capacity is exceeded + * before the queue is flushed, events will be discarded. Increasing the capacity means that events + * are less likely to be discarded, at the cost of consuming more memory. Note that in regular usage + * flag evaluations do not produce individual events, only summary counts, so you only need a large + * capacity if you are generating a large number of click, pageview, or identify events (or if you + * are using the event debugger). + * + * The default value is 100. */ - baseUri?: string; + capacity?: number; + + /** + * Set to true to opt out of sending diagnostics data. + * + * Unless `diagnosticOptOut` is set to true, the client will send some diagnostics data to the LaunchDarkly + * servers in order to assist in the development of future SDK improvements. These diagnostics consist of + * an initial payload containing some details of SDK in use, the SDK's configuration, and the platform the + * SDK is being run on, as well as payloads sent periodically with information on irregular occurrences such + * as dropped events. + */ + diagnosticOptOut?: boolean; + + /** + * The interval at which periodic diagnostic data is sent, in seconds. + * + * The default is 900 (every 15 minutes) and the minimum value is 6. See {@link diagnosticOptOut} + * for more information on the diagnostics data being sent. + */ + diagnosticRecordingInterval?: number; /** * The base uri for the LaunchDarkly events server. @@ -38,34 +97,31 @@ export interface LDOptions { eventsUri?: string; /** - * The base uri for the LaunchDarkly streaming server. + * The interval in between flushes of the analytics events queue, in seconds. * - * Most users should use the default value. + * The default value is 2s. */ - streamUri?: string; + flushInterval?: number; /** - * Whether LaunchDarkly should provide additional information about how flag values were - * calculated. + * The signed context key for Secure Mode. * - * The additional information will then be available through the client's - * {@link LDClient.variationDetail} method. Since this increases the size of network requests, - * such information is not sent unless you set this option to true. + * For more information, see the JavaScript SDK Reference Guide on + * [Secure mode](https://docs.launchdarkly.com/sdk/features/secure-mode#configuring-secure-mode-in-the-javascript-client-side-sdk). */ - withReasons?: boolean; + hash?: string; /** - * Whether to send analytics events back to LaunchDarkly. By default, this is true. + * Inspectors can be used for collecting information for monitoring, analytics, and debugging. */ - sendEvents?: boolean; + inspectors?: LDInspection[]; /** - * Whether all context attributes (except the context key) should be marked as private, and - * not sent to LaunchDarkly in analytics events. + * An object that will perform logging for the client. * - * By default, this is false. + * If not specified, the default is to use `basicLogger`. */ - allAttributesPrivate?: boolean; + logger?: LDLogger; /** * Specifies a list of attribute names (either built-in or custom) which should be marked as @@ -87,25 +143,9 @@ export interface LDOptions { privateAttributes?: Array; /** - * The capacity of the analytics events queue. - * - * The client buffers up to this many events in memory before flushing. If the capacity is exceeded - * before the queue is flushed, events will be discarded. Increasing the capacity means that events - * are less likely to be discarded, at the cost of consuming more memory. Note that in regular usage - * flag evaluations do not produce individual events, only summary counts, so you only need a large - * capacity if you are generating a large number of click, pageview, or identify events (or if you - * are using the event debugger). - * - * The default value is 100. - */ - capacity?: number; - - /** - * The interval in between flushes of the analytics events queue, in seconds. - * - * The default value is 2s. + * Whether to send analytics events back to LaunchDarkly. By default, this is true. */ - flushInterval?: number; + sendEvents?: boolean; /** * Sets the initial reconnect delay for the streaming connection, in seconds. @@ -119,23 +159,21 @@ export interface LDOptions { streamInitialReconnectDelay?: number; /** - * Set to true to opt out of sending diagnostics data. + * The base uri for the LaunchDarkly streaming server. * - * Unless `diagnosticOptOut` is set to true, the client will send some diagnostics data to the LaunchDarkly - * servers in order to assist in the development of future SDK improvements. These diagnostics consist of - * an initial payload containing some details of SDK in use, the SDK's configuration, and the platform the - * SDK is being run on, as well as payloads sent periodically with information on irregular occurrences such - * as dropped events. + * Most users should use the default value. */ - diagnosticOptOut?: boolean; + streamUri?: string; /** - * The interval at which periodic diagnostic data is sent, in seconds. + * Whether LaunchDarkly should provide additional information about how flag values were + * calculated. * - * The default is 900 (every 15 minutes) and the minimum value is 6. See {@link diagnosticOptOut} - * for more information on the diagnostics data being sent. + * The additional information will then be available through the client's + * {@link LDClient.variationDetail} method. Since this increases the size of network requests, + * such information is not sent unless you set this option to true. */ - diagnosticRecordingInterval?: number; + withReasons?: boolean; /** * For use by wrapper libraries to set an identifying name for the wrapper being used. @@ -151,42 +189,4 @@ export interface LDOptions { * If `wrapperName` is unset, this field will be ignored. */ wrapperVersion?: string; - - /** - * Information about the application where the LaunchDarkly SDK is running. - */ - application?: { - /** - * A unique identifier representing the application where the LaunchDarkly SDK is running. - * - * This can be specified as any string value as long as it only uses the following characters: ASCII letters, - * ASCII digits, period, hyphen, underscore. A string containing any other characters will be ignored. - * - * Example: `authentication-service` - */ - id?: string; - - /** - * A unique identifier representing the version of the application where the LaunchDarkly SDK is running. - * - * This can be specified as any string value as long as it only uses the following characters: ASCII letters, - * ASCII digits, period, hyphen, underscore. A string containing any other characters will be ignored. - * - * Example: `1.0.0` (standard version string) or `abcdef` (sha prefix) - */ - version?: string; - }; - - /** - * Inspectors can be used for collecting information for monitoring, analytics, and debugging. - */ - inspectors?: LDInspection[]; - - /** - * The signed context key for Secure Mode. - * - * For more information, see the JavaScript SDK Reference Guide on - * [Secure mode](https://docs.launchdarkly.com/sdk/features/secure-mode#configuring-secure-mode-in-the-javascript-client-side-sdk). - */ - hash?: string; } diff --git a/packages/shared/sdk-server/README.md b/packages/shared/sdk-server/README.md index 1d4dd7eba1..ab14b2ce78 100644 --- a/packages/shared/sdk-server/README.md +++ b/packages/shared/sdk-server/README.md @@ -6,8 +6,6 @@ This project contains Typescript classes and interfaces that are applicable to server-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).