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
4 changes: 3 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
1.14.0 (September 12, 2024)
1.14.0 (September 13, 2024)
- Added `status` property to Split reducer's slice of state to track the SDK events of non-default clients (Related to https://github.com/splitio/redux-client/issues/113).
- Added `lastUpdate` and `isTimedout` properties to the object returned by the `getStatus` helper and `selectTreatmentAndStatus` and `selectTreatmentWithConfigAndStatus` selectors, to expose the last event timestamp and the timedout status of the SDK clients (Related to https://github.com/splitio/redux-client/issues/113).
- Added `selectStatus` selector to retrieve the status properties of the SDK manager and clients from the Split state.
- Added remaining TypeScript types and interfaces to the library index exports, allowing them to be imported from the library index in TypeScript, e.g., `import type { IInitSplitSdkParams } from '@splitsoftware/splitio-redux'`.
- Updated `selectTreatmentAndStatus` and `selectTreatmentWithConfigAndStatus` selectors to retrieve status properties from the state rather than the SDK client instances directly.
- Updated @splitsoftware/splitio package to version 10.28.0 that includes minor updates:
- Added `sync.requestOptions.getHeaderOverrides` configuration option to enhance SDK HTTP request Headers for Authorization Frameworks.
Expand Down
8 changes: 3 additions & 5 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,10 @@ export function getSplits(): SplitIO.SplitViews {
}

/**
* Gets an object with the status properties of the SDK client or manager:
* Gets an object with the status properties of the SDK client or manager.
*
* - `isReady` indicates if the SDK client has emitted the SDK_READY event.
* - `isReadyFromCache` indicates if the SDK client has emitted the SDK_READY_FROM_CACHE event.
* - `hasTimedout` indicates if the SDK client has emitted the SDK_READY_TIMED_OUT event.
* - `isDestroyed` indicates if the SDK client has been destroyed, i.e., if the `destroySplitSdk` action was dispatched.
* This function is similar to the `selectStatus` selector, but it does not require the Split state as a parameter since it uses the global `splitSdk` object.
* Consider using the `selectStatus` selector instead for a more Redux-friendly approach.
*
* @param {SplitIO.SplitKey} key To use only on client-side. Ignored in server-side. If a key is provided and a client associated to that key has been used, the status of that client is returned.
* If no key is provided, the status of the main client and manager is returned (the main client shares the status with the manager).
Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
export { splitReducer } from './reducer';
export { initSplitSdk, getTreatments, destroySplitSdk, splitSdk } from './asyncActions';
export { track, getSplitNames, getSplit, getSplits, getStatus } from './helpers';
export { selectTreatmentValue, selectTreatmentWithConfig, selectTreatmentAndStatus, selectTreatmentWithConfigAndStatus } from './selectors';
export { selectTreatmentValue, selectTreatmentWithConfig, selectTreatmentAndStatus, selectTreatmentWithConfigAndStatus, selectStatus } from './selectors';

// For React-redux
export { connectSplit } from './react-redux/connectSplit';
export { connectToggler, mapTreatmentToProps, mapIsFeatureOnToProps } from './react-redux/connectToggler';

export { ISplitState } from './types';
// Types
export { IStatus, ISplitState, IGetSplitState, IInitSplitSdkParams, IGetTreatmentsParams, IDestroySplitSdkParams, ITrackParams } from './types';
13 changes: 12 additions & 1 deletion src/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,18 @@ export function selectTreatmentWithConfigAndStatus(splitState: ISplitState, feat
};
}

function selectStatus(splitState: ISplitState, key?: SplitIO.SplitKey): IStatus {
/**
* Extracts an object with the status properties of the SDK client or manager from the Split state.
*
* @param {ISplitState} splitState
* @param {SplitIO.SplitKey} key To use only on client-side. Ignored in server-side. If a key is provided and a client associated to that key has been used, the status of that client is returned.
* If no key is provided, the status of the main client and manager is returned (the main client shares the status with the manager).
*
* @returns {IStatus} The status of the SDK client or manager.
*
* @see {@link https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK#subscribe-to-events}
*/
export function selectStatus(splitState: ISplitState, key?: SplitIO.SplitKey): IStatus {
const status = splitState ?
isMainClient(key) ?
splitState :
Expand Down
10 changes: 5 additions & 5 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@ export interface IStatus {

/**
* isReady indicates if Split client is ready, i.e., if it has emitted an SDK_READY event.
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#advanced-subscribe-to-events-and-changes}
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#subscribe-to-events}
*/
isReady: boolean;

/**
* isReadyFromCache indicates if Split client has emitted an SDK_READY_FROM_CACHE event, what means that the SDK is ready to
* evaluate using LocalStorage cached data (which might be stale).
* This flag only applies for the Browser if using LOCALSTORAGE as storage type.
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#advanced-subscribe-to-events-and-changes}
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#subscribe-to-events}
*/
isReadyFromCache: boolean;

/**
* isTimedout indicates if the Split client has emitted an SDK_READY_TIMED_OUT event and is not ready.
* In other words, `isTimedout` is equivalent to `hasTimeout && !isReady`.
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#advanced-subscribe-to-events-and-changes}
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#subscribe-to-events}
*/
isTimedout: boolean;

/**
* hasTimedout indicates if the Split client has ever emitted an SDK_READY_TIMED_OUT event.
* It's meant to keep a reference that the SDK emitted a timeout at some point, not the current state.
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#advanced-subscribe-to-events-and-changes}
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#subscribe-to-events}
*/
hasTimedout: boolean;

Expand All @@ -38,7 +38,7 @@ export interface IStatus {

/**
* lastUpdate is the timestamp of the last Split client event (SDK_READY, SDK_READY_TIMED_OUT or SDK_UPDATE).
* @see {@link https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK#advanced-subscribe-to-events-and-changes}
* @see {@link https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK#subscribe-to-events}
*/
lastUpdate: number;
}
Expand Down
Loading