updateSession() to attach or refresh session-level metadata on the active session — feature flags, traffic origin, experiment variant, current workflow, etc. Session metadata has upsert semantics within the session: any fields you provide are merged with previously set values, so you can enrich the session progressively as context becomes available.
- React
- JavaScript
- Script Tag
Use the
useMilana() hook:Parameters
Arbitrary key-value pairs to attach to the current session. Keys are strings, values can be
string, number, boolean, null, or nested objects/arrays of the same types. e.g. origin (e.g. "email-notification", "marketing-site"), featureFlags, experimentVariant, currentFlow.Return value
true if the update was applied to the session. false if the session was not active, the network request failed, or the session was not sampled.Timing
updateSession() is safe to call before init() completes — the SDK queues the call and replays it once the session is ready.