diff --git a/CHANGES.txt b/CHANGES.txt index 30fd0f1..0f51aa9 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,6 @@ 1.13.0 (May 23, 2024) - - Added new `selectSplitTreatment` and `selectSplitTreatmentWithConfig` selectors as a replacement for the now deprecated `selectTreatmentValue` and `selectTreatmentWithConfig` selectors. The new selectors retrieves more advanced use cases. - The old selectors will be removed in a future major version. + - Added new `selectSplitTreatment` and `selectSplitTreatmentWithConfig` selectors as an alternative to `selectTreatmentValue` and `selectTreatmentWithConfig` selectors respectively. + The new selectors retrieve an object with the treatment and the status properties of the client (`isReady`, `isReadyFromCache`, `isTimedout`, `hasTimedout`, `isDestroyed`, and `lastUpdate`) for conditional rendering based on the SDK status. 1.12.0 (May 10, 2024) - Updated @splitsoftware/splitio package to version 10.26.0 that includes minor updates: @@ -80,7 +80,7 @@ - Updated localhost mode to emit SDK_READY_FROM_CACHE event in Browser when using localStorage (issue https://github.com/splitio/react-client/issues/34). - Updated streaming logic to use the newest version of our streaming service, including: - Integration with Auth service V2, connecting to the new channels and applying the received connection delay. - - Implemented handling of the new MySegmentsV2 notification types (SegmentRemoval, KeyList, Bounded and Unbounded) + - Implemented handling of the new MySegmentsV2 notification types (SegmentRemoval, KeyList, Bounded and Unbounded). - New control notification for environment scoped streaming reset. - Updated Enzyme and Jest development dependencies to fix vulnerabilities. @@ -108,13 +108,13 @@ - Added an optional callback parameter to `destroySplitSdk` action creator: `onDestroy`, to listen when the SDK has gracefully shut down. 1.1.0 (May 11, 2020) - - Bugfixing - incorrect evaluation of feature flags on browser when using `getTreatments` with a different user key than the default, caused by not waiting the fetch of segments. + - Bugfixing - Incorrect evaluation of feature flags on browser when using `getTreatments` with a different user key than the default, caused by not waiting the fetch of segments (Related to issue https://github.com/splitio/redux-client/issues/9). - Added `destroySplitSdk` action creator to gracefully shutdown the SDK. - Added two new status properties to split's piece of state: `hasTimedout` and `isDestroyed` to better reflect the current state of the associated factory. 1.0.1 (April 6, 2020) - - Updated dependencies to fix vulnerabilities - - Bugfixing - support numbers as user keys + - Updated dependencies to fix vulnerabilities. + - Bugfixing - Support numbers as user keys. 1.0.0 (January 24, 2020) - Initial public release! diff --git a/src/__tests__/selectors.test.ts b/src/__tests__/selectors.test.ts index f2a1fbf..27d7d4f 100644 --- a/src/__tests__/selectors.test.ts +++ b/src/__tests__/selectors.test.ts @@ -36,9 +36,9 @@ describe('selectTreatmentValue', () => { }); it('returns "control" and log error if the given splitState is invalid', () => { - const errorSpy = jest.spyOn(console, 'error'); + const logSpy = jest.spyOn(console, 'log'); expect(selectTreatmentValue((STATE_READY as unknown as ISplitState), SPLIT_1, USER_INVALID)).toBe(CONTROL); - expect(errorSpy).toBeCalledWith(ERROR_SELECTOR_NO_SPLITSTATE); + expect(logSpy).toBeCalledWith(ERROR_SELECTOR_NO_SPLITSTATE); }); }); @@ -66,8 +66,8 @@ describe('selectTreatmentWithConfig', () => { }); it('returns "control" and log error if the given splitState is invalid', () => { - const errorSpy = jest.spyOn(console, 'error'); + const logSpy = jest.spyOn(console, 'log'); expect(selectTreatmentWithConfig((STATE_READY as unknown as ISplitState), SPLIT_1, USER_INVALID)).toBe(CONTROL_WITH_CONFIG); - expect(errorSpy).toBeCalledWith(ERROR_SELECTOR_NO_SPLITSTATE); + expect(logSpy).toBeCalledWith(ERROR_SELECTOR_NO_SPLITSTATE); }); }); diff --git a/src/selectors.ts b/src/selectors.ts index d6e77e1..0cc9364 100644 --- a/src/selectors.ts +++ b/src/selectors.ts @@ -54,7 +54,7 @@ export function selectTreatmentWithConfig(splitState: ISplitState, featureFlagNa } /** - * This function extracts a treatment evaluation from the Split state. It returns an object that contains the treatment string value and the status properties of the client: `isReady`, `isReadyFromCache`, `hasTimedout`, `isDestroyed`. + * This function extracts a treatment evaluation from the Split state. It returns an object that contains the treatment string value and the status properties of the client: `isReady`, `isReadyFromCache`, `isTimedout`, `hasTimedout`, `isDestroyed`, and `lastUpdate`. * If a treatment is not found, it returns the default value, which is `'control'` if not specified. * A treatment is not found if an invalid Split state is passed or if a `getTreatments` action has not been dispatched for the provided feature flag name and key. * @@ -72,7 +72,7 @@ export function selectSplitTreatment(splitState: ISplitState, featureFlagName: s } /** - * This function extracts a treatment evaluation from the Split state. It returns an object that contains the treatment object and the status properties of the client: `isReady`, `isReadyFromCache`, `hasTimedout`, `isDestroyed`. + * This function extracts a treatment evaluation from the Split state. It returns an object that contains the treatment object and the status properties of the client: `isReady`, `isReadyFromCache`, `isTimedout`, `hasTimedout`, `isDestroyed`, and `lastUpdate`. * If a treatment is not found, it returns the default value as treatment, which is `{ treatment: 'control', configuration: null }` if not specified. * A treatment is not found if an invalid Split state is passed or if a `getTreatments` action has not been dispatched for the provided feature flag name and key. * diff --git a/src/types.ts b/src/types.ts index 7ce42a3..e73d3e3 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,13 +1,13 @@ export interface ISplitStatus { /** - * isReady indicates if Split SDK is ready, i.e., if it has emitted an SDK_READY event. + * isReady indicates if Split SDK 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} */ isReady: boolean; /** - * isReadyFromCache indicates if Split SDK has emitted an SDK_READY_FROM_CACHE event, what means that the SDK is ready to + * isReadyFromCache indicates if Split SDK 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} @@ -15,26 +15,26 @@ export interface ISplitStatus { isReadyFromCache: boolean; /** - * isTimedout indicates if the Split SDK has emitted an SDK_READY_TIMED_OUT event and is not ready. + * isTimedout indicates if the Split SDK client has emitted an SDK_READY_TIMED_OUT event and is not ready. * @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#advanced-subscribe-to-events-and-changes} */ isTimedout: boolean; /** - * hasTimedout indicates if the Split SDK has ever emitted an SDK_READY_TIMED_OUT event. + * hasTimedout indicates if the Split SDK 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} */ hasTimedout: boolean; /** - * isDestroyed indicates if the Split SDK has been destroyed by dispatching a `destroySplitSdk` action. + * isDestroyed indicates if the Split SDK client has been destroyed by dispatching a `destroySplitSdk` action. * @see {@link https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK#shutdown} */ isDestroyed: boolean; /** - * lastUpdate is the timestamp of the last Split SDK event (SDK_READY, SDK_READY_TIMED_OUT or SDK_UPDATE). + * lastUpdate is the timestamp of the last Split SDK 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} */ lastUpdate: number;