Skip to content

Provide a default SessionId value for Unleash context #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
FredrikOseberg opened this issue Apr 22, 2025 · 2 comments · Fixed by #122
Closed

Provide a default SessionId value for Unleash context #119

FredrikOseberg opened this issue Apr 22, 2025 · 2 comments · Fixed by #122
Labels
enhancement New feature or request

Comments

@FredrikOseberg
Copy link
Contributor

Describe the feature request

Stickiness is a core concept in Unleash that deterministically selects the correct variant based on previous input, meaning that if you were already "inside" of a rollout percentage or received a variant, given the same input, you would get the same evaluation result in the next cycle. Stickiness in Unleash defaults to userId or sessionId. If none of these are present it returns a random result.

This SDK does not provide any default settings for sessionId like we introduced in the javascript SDK. This means that if you have rollout based strategies or strategy variants, you might get a different result on each request to the frontend API, resulting in uneccesary 200s and payloads being transmitted over the wire. If no sessionId is provided, we should default it.

Background

No response

Solution suggestions

No response

@gastonfournier
Copy link

I believe this is correct, in node we do it here for rollout and here for variants.

In Java SDK the stickiness is the same provided from Unleash: https://github.com/Unleash/unleash-client-java/blob/fb576bfd7d68cfd27d4a32109a9735a197659f5b/src/main/java/io/getunleash/variant/Variant.java#L67-L70 and it can be nullable...

I wonder if this should be resolved in the backend rather than the frontend. Currently stickiness is not a required field in our response: https://github.com/Unleash/unleash/blob/da05c7be5cefdcc7c8fcfff9d6e7fd8c1a3aa90c/src/lib/openapi/spec/variant-schema.ts#L10 if we have it default to 'default' then we wouldn't need to patch our SDKs

@gastonfournier gastonfournier changed the title Default SessionId Provide a default SessionId value for the Unleash context Apr 22, 2025
@gastonfournier
Copy link

After a quick chat I think what you want here is a default context value for the session id if none is provided. Updated the title but feel free to correct me if you mean something else. My comment was going a different route, possibly a different issue for our backend.

@gastonfournier gastonfournier changed the title Provide a default SessionId value for the Unleash context Provide a default SessionId value for Unleash context Apr 22, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Issues and PRs Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants