Skip to content

Commit a30e053

Browse files
authored
fix: Update VariableValuesObject type to handle JSON type variable (#118)
* Update type to handle JSON type variable * Include link to the pr * Update readme * Update VariableValuesObject type
1 parent 57b68da commit a30e053

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## [Unreleased]
99

10+
### Bug fixes
11+
- Update `VariableValuesObject` type to handle JSON type variable ([#118](https://github.com/optimizely/react-sdk/pull/118)).
12+
1013
## [2.6.2] - July 15th, 2021
1114

1215
### Bug fixes

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ The following type definitions are used in the `ReactSDKClient` interface:
318318

319319
- `UserAttributes : { [name: string]: any }`
320320
- `User : { id: string | null, attributes: userAttributes }`
321-
- `VariableValuesObject : { [key: string]: boolean | number | string | null }`
321+
- `VariableValuesObject : { [key: string]: any }`
322322
- `EventTags : { [key: string]: string | number | boolean; }`
323323

324324
`ReactSDKClient` instances have the methods/properties listed below. Note that in general, the API largely matches that of the core `@optimizely/optimizely-sdk` client instance, which is documented on the [Optimizely X Full Stack developer docs site](https://docs.developers.optimizely.com/full-stack/docs). The major exception is that, for most methods, user id & attributes are **_optional_** arguments. `ReactSDKClient` has a current user. This user's id & attributes are automatically applied to all method calls, and overrides can be provided as arguments to these method calls if desired.

src/client.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { OptimizelyDecision, UserInfo, createFailedDecision } from './utils';
2121
const logger = logging.getLogger('ReactSDK');
2222

2323
export type VariableValuesObject = {
24-
[key: string]: boolean | number | string | null;
24+
[key: string]: any;
2525
};
2626

2727
type DisposeFn = () => void;
@@ -475,7 +475,7 @@ class OptimizelyReactSDKClient implements ReactSDKClient {
475475
return {};
476476
}
477477
const userAttributes = user.attributes;
478-
const variableObj: { [key: string]: any } = {};
478+
const variableObj: VariableValuesObject = {};
479479
const optlyConfig = this._client.getOptimizelyConfig();
480480
if (!optlyConfig) {
481481
return {};

0 commit comments

Comments
 (0)