optimizely / react-sdk

React SDK for Optimizely Feature Experimentation and Optimizely Full Stack (legacy)
https://docs.developers.optimizely.com/experimentation/v4.0.0-full-stack/docs/javascript-react-sdk
Apache License 2.0
89 stars 35 forks source link

[OptimizelyProvider UserAttributes Type Definition mismatch] The type definition for the user attributes does not match the documentation and is limiting types allowed #259

Open victor-optimizely opened 5 months ago

victor-optimizely commented 5 months ago

Is there an existing issue for this?

SDK Version

3.1.0

Current Behavior

The new package has defined the UserAttributeValue to be a limited set of types which contradicts the documentation stating it supports any type. What's happening now is that if you have a custom type being set as an attribute you will receive a typescript error because the type is not supported.

Expected Behavior

The user prop in the OptimizelyProvider should allow any type definition as stated in the documentation instead of the currently defined type:

export type UserAttributeValue = string | number | boolean | null;

⬇️

export type UserAttributeValue = any;

or simply:

export type UserAttributes = {
    [name: string]: UserAttributeValue;
};

⬇️

export type UserAttributes = {
    [name: string]: any;
};

Steps To Reproduce

React Framework

create-react-app

Browsers impacted

No response

Link

No response

Logs

No response

Severity

Blocking development

Workaround/Solution

Solution listed above. Workaround might be to ts-ignore and ensure the attribute is being used.

Recent Change

No response

Conflicts

No response

victor-optimizely commented 5 months ago

It looks like the underlying definition is in the @optrimizely/sdk package so I've duplicated this issue there. Since it would still take an update here not sure if you want to keep it open to follow up (I would).

junaed-optimizely commented 1 month ago

@victor-optimizely, is this ticket still valid?