launchdarkly / js-client-sdk

LaunchDarkly Client-side SDK for Browser JavaScript
Other
109 stars 62 forks source link

Support passing context to the `variation` call? #280

Open jessicalc opened 1 year ago

jessicalc commented 1 year ago

Is your feature request related to a problem? Please describe. Not a problem per se, but fulfillment of this feature request would make our work much easier :)

Describe the solution you'd like I'd love to see the LDClient's variation call support a context parameter, just like it does in the node-server-sdk: https://launchdarkly.github.io/node-server-sdk/interfaces/_launchdarkly_node_server_sdk_.LDClient.html#variation Is there an ETA on that?

Describe alternatives you've considered We have a multicontext situation on our hands, wherein in most cases, we use the user to evaluate the flag, but in special cases, we need to use a doc context. Unfortunately, without support for passing a context parameter to variation, we're having to call identify to set the doc context, but then we're also having to remember to unset it when we don't need it. It's pretty clunky and prone to human error, and it would be preferable if we could just pass the attributes we want at point in time when we're evaluating the flag.

Additional context Can't think of anything else! Thanks for your kind attention!

louis-launchdarkly commented 1 year ago

Hello @jessicalc, thank you for reaching out with this feature request. Given the way the client-side SDKs are currently designed, this proposed behavior is complicated and costly for the application to do. Do you mind reaching out to us via a Support ticket, and in that ticket providing a link to this GitHub issue so we can ask for more detail about your use case? We want to understand more so we can potentially provide some implementation suggestions and/or workaround.