-
Notifications
You must be signed in to change notification settings - Fork 40
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
fix: #664 Handle URL-encoded cookie values #686
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May rails devs not have this issue again
@kwalker3690 any chance someone with write access could approve and merge this fix in the near future? 🙏 😊 |
Hi @dajinchu, Amplitude Experiment Ruby SDK encodes cookie values with URL encoding first and then base64 the same as Amplitude Browser SDK. I confirmed that they should work well with each other. In your example, it's been url encoded twice rather than not been URL encoded.
|
Hi @dajinchu, @amplitude/[email protected] is released with more logs in the catch block. Please upgrade to the latest version to get the exact error when it breaks. |
@Mercy811 they do, you're right. Here's an example (following the Experiment documentation) : def persist_device_id_in_cookie(cookie_name, device_id, country)
cookies[cookie_name] = {
value: AmplitudeExperiment::AmplitudeCookie.generate(device_id, new_format: true),
domain: ".our-domain.#{country.host_tld}",
httponly: false,
secure: false
}
end Although the base64 returned by
And sure enough, with @amplitude/[email protected] : |
Hi @jeremyallison, cookies are automatically URL encoded by the cookies helper for example, |
@Mercy811 we are actually using Rails I think the most straightforward way to see this issue is the way @dajinchu explained it; the example in the official Amplitude Ruby gem documentation unfortunately cannot set a cookie that the TS Thank you very much for your time and for reopening the PR 🙏 |
Hi @jeremyallison, |
Thank you very much @Mercy811 ! 🙏 |
Summary
Fixes #664
Cookie values are often URL-encoded. In Rails, for example, there is no way to opt out of url-encoding cookies. So this code in the docs does not work.
Checklist