Skip to content

fix: Update VariableValuesObject type to handle JSON type variable #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 29, 2021
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Bug fixes
- Update `VariableValuesObject` type to handle JSON type variable ([#118](https://github.com/optimizely/react-sdk/pull/118)).

## [2.6.2] - July 15th, 2021

### Bug fixes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ The following type definitions are used in the `ReactSDKClient` interface:

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

`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.
Expand Down
4 changes: 2 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { OptimizelyDecision, UserInfo, createFailedDecision } from './utils';
const logger = logging.getLogger('ReactSDK');

export type VariableValuesObject = {
[key: string]: boolean | number | string | null;
[key: string]: any;
};

type DisposeFn = () => void;
Expand Down Expand Up @@ -475,7 +475,7 @@ class OptimizelyReactSDKClient implements ReactSDKClient {
return {};
}
const userAttributes = user.attributes;
const variableObj: { [key: string]: any } = {};
const variableObj: VariableValuesObject = {};
const optlyConfig = this._client.getOptimizelyConfig();
if (!optlyConfig) {
return {};
Expand Down