diff --git a/docs/docs/clients/client-side/javascript.md b/docs/docs/clients/client-side/javascript.md index c433074e5fc8..60de58d89b16 100644 --- a/docs/docs/clients/client-side/javascript.md +++ b/docs/docs/clients/client-side/javascript.md @@ -31,8 +31,9 @@ npm i flagsmith --save :::tip -The ReactNative SDK shares the exact same implementation of Flagsmith, however, the defaults for some underlying -libraries (e.g. AsyncStorage) use React Native compatible implementations. +The React Native SDK shares the exact same implementation of Flagsmith, however it requires an implementation of +AsyncStorage to be provided (e.g. @react-native-community/async-storage) in order to utilise analytics and caching. See +[here](/clients/javascript#initialisation-options). ::: @@ -61,7 +62,7 @@ flagsmith.init({ environmentID: '', // api:"http://localhost:8000/api/v1/" set this if you are self hosting, and point it to your API cacheFlags: true, // stores flags in localStorage cache - enableAnalytics: true, // See https://docs.flagsmith.com/flag-analytics/ for more info + enableAnalytics: true, // See https://docs.flagsmith.com/flag-analytics/ for more info. onChange: (oldFlags, params) => { //Occurs whenever flags are changed const { isFromServer } = params; //determines if the update came from the server or local cached storage @@ -234,24 +235,24 @@ All function and property types can be seen ### Initialisation options -| Property | Description | Required | Default Value | -| ------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | -------: | -------------------------------------: | -| `environmentID: string` | Defines which project environment you wish to get flags for. _example ACME Project - Staging._ | **YES** | null | -| `onChange?: (previousFlags:IFlags, params:IRetrieveInfo, loadingState:LoadingState)=> void` | Your callback function for when the flags are retrieved `(previousFlags,{isFromServer:true/false,flagsChanged: true/false, traitsChanged:true/false})=>{...}` | **YES** | null | -| `onError?: (res:{message:string}) => void` | Callback function on failure to retrieve flags. `(error)=>{...}` | | null | -| `realtime?:boolean` | Whether to listen for [Real Time Flag events](/advanced-use/real-time-flags) | | false | -| `asyncStorage?:any` | Needed for cacheFlags option, used to tell the library what implementation of AsyncStorage your app uses, i.e. ReactNative.AsyncStorage vs @react-native-community/async-storage, for web this defaults to an internal implementation. | | null | -| `cacheFlags?: boolean` | Any time flags are retrieved they will be cached, flags and identities will then be retrieved from local storage before hitting the API (see cache options) | | null | -| `cacheOptions?: \{ttl?:number, skipAPI?:boolean\}` | A ttl in ms (default to 0 which is infinite) and option to skip hitting the API in flagsmith.init if there's cache available. | | \{ttl:0, skipAPI:false\} | -| `enableAnalytics?: boolean` | [Enable sending flag analytics](/advanced-use/flag-analytics.md) for getValue and hasFeature evaluations. | | false | -| `enableLogs?: boolean` | Enables logging for key Flagsmith events | | null | -| `defaultFlags?: {flag_name: {enabled: boolean, value: string,number,boolean}}` | Allows you define default features, these will all be overridden on first retrieval of features. | | null | -| `preventFetch?: boolean` | If you want to disable fetching flags and call getFlags later. | | false | -| `state?: IState` | Set a predefined state, useful for SSR / isomorphic applications. | | false | -| `api?: string` | Use this property to define where you're getting feature flags from, e.g. if you're self hosting. | | https://edge.api.flagsmith.com/api/v1/ | -| `eventSourceUrl?: string` | Use this property to define where you're getting real-time flag update events (server sent events) from, e.g. if you're self hosting. | | https://edge.api.flagsmith.com/api/v1/ | -| `identity?: string` | Specifying an identity will fetch flags for that identity in the initial API call. | **YES** | null | -| `traits?:Record` | Specifying traits will send the traits for that identity in the initial API call. | **YES** | null | +| Property | Description | Required | Default Value | +| ------------------------------------------------------------------------------------------- | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | -------: | ----------------------------------------------------: | +| `environmentID: string` | Defines which project environment you wish to get flags for. _example ACME Project - Staging._ | **YES** | null | +| `onChange?: (previousFlags:IFlags, params:IRetrieveInfo, loadingState:LoadingState)=> void` | Your callback function for when the flags are retrieved `(previousFlags,{isFromServer:true/false,flagsChanged: true/false, traitsChanged:true/false})=>{...}` | **YES** | null | +| `onError?: (res:{message:string}) => void` | Callback function on failure to retrieve flags. `(error)=>{...}` | | null | +| `realtime?:boolean` | Whether to listen for [Real Time Flag events](/advanced-use/real-time-flags) | | false | +| `AsyncStorage?:any` | Needed in certain frameworks cacheFlags and enableAnalytics options, used to tell the library what implementation of AsyncStorage your app uses, e.g. @react-native-community/async-storage, for web this defaults to an internal implementation. | | built in implementation for web, otherwise undefined. | +| `cacheFlags?: boolean` | Any time flags are retrieved they will be cached, flags and identities will then be retrieved from local storage before hitting the API (see cache options). Requires AsyncStorage to be accessible. | | null | +| `cacheOptions?: \{ttl?:number, skipAPI?:boolean\}` | A ttl in ms (default to 0 which is infinite) and option to skip hitting the API in flagsmith.init if there's cache available. | | \{ttl:0, skipAPI:false\} | +| `enableAnalytics?: boolean` | [Enable sending flag analytics](/advanced-use/flag-analytics.md) for getValue and hasFeature evaluations. | | false | +| `enableLogs?: boolean` | Enables logging for key Flagsmith events | | null | +| `defaultFlags?: {flag_name: {enabled: boolean, value: string,number,boolean}}` | Allows you define default features, these will all be overridden on first retrieval of features. | | null | +| `preventFetch?: boolean` | If you want to disable fetching flags and call getFlags later. | | false | +| `state?: IState` | Set a predefined state, useful for SSR / isomorphic applications. | | false | +| `api?: string` | Use this property to define where you're getting feature flags from, e.g. if you're self hosting. | | https://edge.api.flagsmith.com/api/v1/ | +| `eventSourceUrl?: string` | Use this property to define where you're getting real-time flag update events (server sent events) from, e.g. if you're self hosting. | | https://edge.api.flagsmith.com/api/v1/ | +| `identity?: string` | Specifying an identity will fetch flags for that identity in the initial API call. | **YES** | null | +| `traits?:Record` | Specifying traits will send the traits for that identity in the initial API call. | **YES** | null | ### Available Functions diff --git a/docs/docs/clients/client-side/react.md b/docs/docs/clients/client-side/react.md index 672503bdabe0..7608c16abb94 100644 --- a/docs/docs/clients/client-side/react.md +++ b/docs/docs/clients/client-side/react.md @@ -32,8 +32,9 @@ npm i flagsmith --save :::tip -The ReactNative SDK shares the exact same implementation of Flagsmith, however, the defaults for some underlying -libraries (e.g. AsyncStorage) use React Native compatible implementations. +The React Native SDK shares the exact same implementation of Flagsmith, however, requires an implementation of +AsyncStorage to be provided (e.g. @react-native-community/async-storage) in order to utilise analytics and caching. See +[here](/clients/javascript#initialisation-options). :::