Store either "someexp" or "-someexp" in cookie, never both. #6762
Merged
lannka merged 4 commits intoampproject:masterfrom Dec 20, 2016
Merged
Store either "someexp" or "-someexp" in cookie, never both. #6762lannka merged 4 commits intoampproject:masterfrom
lannka merged 4 commits intoampproject:masterfrom
Conversation
…o fix the duplicated experiment entries in cookie.
dvoytenko
approved these changes
Dec 20, 2016
src/experiments.js
Outdated
| * @visibleForTesting | ||
| */ | ||
| function getExperimentIds(win) { | ||
| export function getExperimentTogglesFromCookie(win) { |
Contributor
There was a problem hiding this comment.
Lately, I've been directing to keep the original method private to the module, but instead creating a specifically test method, e.g.
function getExperimentTogglesFromCookie(win) {
...
..
..
}
export function getExperimentToglesFromCookieForTesting(win) {
return getExperimentTogglesFromCookie(win);
}
"xForTesting" methods are stripped, so we get a better protection.
erwinmombay
reviewed
Dec 20, 2016
| toggles[experimentId] = true; | ||
| } else { | ||
| experimentIds.splice(experimentIds.indexOf(experimentId), 1); | ||
| toggles[experimentId] = false; |
erwinmombay
approved these changes
Dec 20, 2016
jridgewell
requested changes
Dec 20, 2016
src/experiments.js
Outdated
| toggles[experimentId] = on; | ||
|
|
||
| const cookieToggles = getExperimentTogglesFromCookie(win); | ||
| cookieToggles[experimentId] = on; |
Contributor
There was a problem hiding this comment.
This means opt_transientExperiment stores could be persisted if anything after it persists.
jridgewell
requested changes
Dec 20, 2016
| if (cookieFlag) { | ||
| return true; | ||
| if (cookieToggles[experimentId] !== undefined) { | ||
| return cookieToggles[experimentId]; |
Contributor
There was a problem hiding this comment.
This won't reflect transient experiment toggles, now.
Contributor
Author
There was a problem hiding this comment.
as talked offline, it works fine. I added a test to prove.
jridgewell
approved these changes
Dec 20, 2016
Lith
pushed a commit
to Lith/amphtml
that referenced
this pull request
Dec 22, 2016
…ct#6762) * Store either "someexp" or "-someexp" in cookie, never both. This is to fix the duplicated experiment entries in cookie. * Fixes a bug related to opt_transient . Adds a test for it. * Added one more test for transient. * Export a xforTesting function instead of the original function.
Lith
pushed a commit
to Lith/amphtml
that referenced
this pull request
Dec 22, 2016
…ct#6762) * Store either "someexp" or "-someexp" in cookie, never both. This is to fix the duplicated experiment entries in cookie. * Fixes a bug related to opt_transient . Adds a test for it. * Added one more test for transient. * Export a xforTesting function instead of the original function.
torch2424
pushed a commit
to torch2424/amphtml
that referenced
this pull request
Jan 3, 2017
…ct#6762) * Store either "someexp" or "-someexp" in cookie, never both. This is to fix the duplicated experiment entries in cookie. * Fixes a bug related to opt_transient . Adds a test for it. * Added one more test for transient. * Export a xforTesting function instead of the original function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is to fix the duplicated experiment entries in cookie as mentioned here .
It's done by deserializing the experiment cookie into an object instead of an array:
AMP_EXP=e1,-e2,e3=>