-License: [MIT](https://github.com/piotrwitek/utility-types/blob/master/LICENSE)
-
[**node-uuid**](https://github.com/kelektiv/node-uuid)
Copyright © 2010-2016 Robert Kieffer and other contributors
License: [MIT](https://github.com/kelektiv/node-uuid/blob/master/LICENSE.md)
diff --git a/package.json b/package.json
index ed4887f4..3dac6489 100644
--- a/package.json
+++ b/package.json
@@ -42,8 +42,7 @@
},
"dependencies": {
"@optimizely/optimizely-sdk": "^5.3.4",
- "hoist-non-react-statics": "^3.3.2",
- "utility-types": "^2.1.0 || ^3.0.0"
+ "hoist-non-react-statics": "^3.3.2"
},
"peerDependencies": {
"react": ">=16.8.0"
diff --git a/src/withOptimizely.tsx b/src/withOptimizely.tsx
index 93cdc526..0160f175 100644
--- a/src/withOptimizely.tsx
+++ b/src/withOptimizely.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import * as React from 'react';
-import { Subtract } from 'utility-types';
import { OptimizelyContextConsumer, OptimizelyContextInterface } from './Context';
import { ReactSDKClient } from './client';
@@ -26,7 +25,7 @@ export interface WithOptimizelyProps {
isServerSide: boolean;
}
-export type WithoutOptimizelyProps = Subtract
;
+export type WithoutOptimizelyProps
= Omit
;
export function withOptimizely
(
Component: React.ComponentType
diff --git a/yarn.lock b/yarn.lock
index e2ee69f8..13be85c0 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4800,11 +4800,6 @@ url-parse@^1.5.3:
querystringify "^2.1.1"
requires-port "^1.0.0"
-"utility-types@^2.1.0 || ^3.0.0":
- version "3.11.0"
- resolved "https://registry.yarnpkg.com/utility-types/-/utility-types-3.11.0.tgz#607c40edb4f258915e901ea7995607fdf319424c"
- integrity sha512-6Z7Ma2aVEWisaL6TvBCy7P8rm2LQoPv6dJ7ecIaIixHcwfbJ0x7mWdbcwlIM5IGQxPZSFYeqRCqlOOeKoJYMkw==
-
uuid@^9.0.1:
version "9.0.1"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30"
From c50e7b8fa9d775bfa7487c93c29d691a673bb6b5 Mon Sep 17 00:00:00 2001
From: Md Junaed Hossain <169046794+junaed-optimizely@users.noreply.github.com>
Date: Mon, 6 Jan 2025 16:31:03 +0600
Subject: [PATCH 22/23] Junaed/fssdk 10980 optimizely onready always returns
false (#302)
---
src/client.spec.ts | 19 +++++++++++++++++++
src/client.ts | 4 ++++
2 files changed, 23 insertions(+)
diff --git a/src/client.spec.ts b/src/client.spec.ts
index 5f92f580..6aa2b821 100644
--- a/src/client.spec.ts
+++ b/src/client.spec.ts
@@ -315,6 +315,25 @@ describe('ReactSDKClient', () => {
expect(instance.getUserContext()).toBe(null);
});
+ it('if user id is not present, and ODP is explicitly off, user promise will be pending', async () => {
+ jest.spyOn(mockInnerClient, 'onReady').mockResolvedValue({ success: true });
+
+ instance = createInstance({
+ ...config,
+ odpOptions: {
+ disabled: true,
+ },
+ });
+
+ await instance.setUser(DefaultUser);
+ expect(instance.isReady()).toBe(false);
+
+ await instance.setUser({ id: 'user123' });
+ await instance.onReady();
+
+ expect(instance.isReady()).toBe(true);
+ });
+
it('can be called with no/default user set', async () => {
jest.spyOn(mockOptimizelyUserContext, 'getUserId').mockReturnValue(validVuid);
diff --git a/src/client.ts b/src/client.ts
index b7430219..468f4f41 100644
--- a/src/client.ts
+++ b/src/client.ts
@@ -382,6 +382,10 @@ class OptimizelyReactSDKClient implements ReactSDKClient {
}
public async setUser(userInfo: UserInfo): Promise {
+ // If user id is not present and ODP is explicitly off, user promise will be pending until setUser is called again with proper user id
+ if (userInfo.id === null && this.odpExplicitlyOff) {
+ return;
+ }
this.user = {
id: userInfo.id || DefaultUser.id,
attributes: userInfo.attributes || DefaultUser.attributes,
From a169d5d5685fcc75fbe112d8575d07c39e7640d7 Mon Sep 17 00:00:00 2001
From: Md Junaed Hossain <169046794+junaed-optimizely@users.noreply.github.com>
Date: Thu, 15 May 2025 19:48:24 +0600
Subject: [PATCH 23/23] prep for release (#305)
---
CHANGELOG.md | 4 ++++
package.json | 2 +-
src/client.spec.ts | 2 +-
src/client.ts | 2 +-
4 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 27d524e5..cab740d7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog
+## [3.2.4] - May 15, 2025
+### Bug fixes
+- `client.onReady()` always returns false when ODP is off and user id is null bug fix.([#302](https://github.com/optimizely/react-sdk/pull/285))
+
## [3.2.3] - Nov 22, 2024
### Bug fixes
diff --git a/package.json b/package.json
index 3dac6489..593026bd 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@optimizely/react-sdk",
- "version": "3.2.3",
+ "version": "3.2.4",
"description": "React SDK for Optimizely Feature Experimentation, Optimizely Full Stack (legacy), and Optimizely Rollouts",
"homepage": "https://github.com/optimizely/react-sdk",
"repository": "https://github.com/optimizely/react-sdk",
diff --git a/src/client.spec.ts b/src/client.spec.ts
index 6aa2b821..f1a95fbd 100644
--- a/src/client.spec.ts
+++ b/src/client.spec.ts
@@ -178,7 +178,7 @@ describe('ReactSDKClient', () => {
expect(createInstanceSpy).toHaveBeenCalledWith({
...config,
clientEngine: 'react-sdk',
- clientVersion: '3.2.3',
+ clientVersion: '3.2.4',
});
});
diff --git a/src/client.ts b/src/client.ts
index 468f4f41..fab06be9 100644
--- a/src/client.ts
+++ b/src/client.ts
@@ -47,7 +47,7 @@ export interface OnReadyResult extends ResolveResult {
}
const REACT_SDK_CLIENT_ENGINE = 'react-sdk';
-const REACT_SDK_CLIENT_VERSION = '3.2.3';
+const REACT_SDK_CLIENT_VERSION = '3.2.4';
export const DefaultUser: UserInfo = {
id: null,