open-feature / docs.openfeature.dev

OpenFeature Documentation
https://openfeature.dev
Creative Commons Attribution 4.0 International
6 stars 19 forks source link

[DOC] Providing evaluation context - JavaScript example not working #204

Closed sinclairs closed 1 year ago

sinclairs commented 1 year ago

Change in the documentation

Thanks for the effort that's being put in to this. I'm new to OpenFeature, but the docs appear to be incorrect.

I think the examples should be using setContext rather than setting a context property directly e.g.

OpenFeature.context = { myGlobalKey: 'myGlobalValue' } (this line)

would be:

OpenFeature.setContext({ myGlobalKey: 'myGlobalValue' });

If a property should be set directly, then only _context seems to work, note the preceding _.

Also, the api seems to differ between languages setEvaluationContext vs setContext 🤔

toddbaert commented 1 year ago

Thanks for noticing and opening this issue, I think you're right, that particular doc example is out of date! We'll fix this and see if there's any similar references.

Also, the api seems to differ between languages setEvaluationContext vs setContext

Yes, the spec doesn't dictate exact method names, we leave some amount of flexibility to allow for language idioms, etc. I don't think resolving this particular inconsistency would be worth a breaking change in an SDK.

sinclairs commented 1 year ago

Yes, the spec doesn't dictate exact method names, we leave some amount of flexibility to allow for language idioms, etc. I don't think resolving this particular inconsistency would be worth a breaking change in an SDK.

Fair enough. I was just thinking of a scenario where you'd want to use the respective SDKs for the browser and server. Consistent naming would perhaps be beneficial, rather than setContext in the browser, then setEvaluationContext on the server. Just a thought.