You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a base set of attributes that are passed to our OptimizelyProvider upon initialization. A common use case is in a hook to pass the overrideAttributes. Generally we would like to have our base attributes merged with the overrideAttributes. It looks like the OptimizelyProvider uses the .setUser method and then in the hook calls .activate with the third argument of the override attributes. I'm under the impression that this will completely override our base set of attributes.
Currently, if we pass overrides we have to access our base attributes from state or context and manually merge them in the hook. I would be nice if they were passed as context and either the hook merges them internally or we can use the Optimizely context to access the base attributes and perform the merge with overrides.
The text was updated successfully, but these errors were encountered:
Hey @dtothefp, it's been a while. I'm going through old issues and found this one. Do you still need it reviewed?
From what I remember, overrideUserAttributes is meant to completely replace the attribute object, not merge it with the base attributes. If a developer wants to merge them, they can.
Also, merging in the SDK layer could introduce new problem, like not being able to unset base attributes.
And its possible to get existing user attributes by doing the following
import{OptimizelyContext}from'@optimizely/react-sdk'// And then inside the componentconst{ optimizely }=useContext(OptimizelyContext)constexistingAttr=optimizely?.getUserContext()?.getAttributes()||{}
We have a base set of attributes that are passed to our OptimizelyProvider upon initialization. A common use case is in a hook to pass the
overrideAttributes
. Generally we would like to have our base attributes merged with theoverrideAttributes
. It looks like the OptimizelyProvider uses the.setUser
method and then in the hook calls.activate
with the third argument of the override attributes. I'm under the impression that this will completely override our base set of attributes.Currently, if we pass overrides we have to access our base attributes from state or context and manually merge them in the hook. I would be nice if they were passed as context and either the hook merges them internally or we can use the Optimizely context to access the base attributes and perform the merge with overrides.
The text was updated successfully, but these errors were encountered: