Skip to content

Docs and dashboard code examples don't cover setContext or transient traits #8076

Description

@adamvialpando

What's missing

The JavaScript client side SDK docs and the "Creating identities and getting their feature settings" example in the dashboard only show identity and traits being set through init options and identify. Neither mentions setContext or updateContext, and neither mentions transient traits at all.

This covers three docs pages (the JavaScript, React and Next.js client side SDK pages under docs.flagsmith.com/integrating-with-flagsmith/sdks/client-side-sdks) and the code example in the dashboard, which renders the same snippet on its JS, React and Next tabs.

Why it matters

Transient traits only work through the context API. With nothing in the docs pointing at setContext, someone who needs a transient trait tries to pass { value, transient: true } through the old traits option or identify. That path sends the object as the raw trait value, so the trait comes through as trait_value "{'value': 'jooish', 'transient': True}" with transient false and the flag gated on it evaluates wrong. setContext sends it correctly. Seen on v12.0.1 and current v12.x.

What to add

Document setContext, updateContext, getContext and the evaluationContext init option as the current way to set identity and traits. Add a transient traits section using the { value, transient: true } shape and the identity level transient flag, both through the context API. Update the JS, React and Next examples in the dashboard to match. Keep the identify and setTraits examples since they still work for plain traits, but note that transient traits need the context API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions