Skip to content

Commit

Permalink
Comment updates and Test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilianoSanchez committed May 23, 2024
1 parent 7934c65 commit d7d522b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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!
8 changes: 4 additions & 4 deletions src/__tests__/selectors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

Expand Down Expand Up @@ -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);
});
});
4 changes: 2 additions & 2 deletions src/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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.
*
Expand Down
12 changes: 6 additions & 6 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
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}
*/
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;
Expand Down

0 comments on commit d7d522b

Please sign in to comment.