Last active
February 23, 2018 15:55
-
-
Save yetibash/e5f6a9d6e6f7c4b16fedc55c627eef43 to your computer and use it in GitHub Desktop.
This file contains 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
sub abtest_recv { | |
##################### | |
## Courier-Journal | |
##################### | |
if (req.http.x-uscp-property ~ "^courier-?journal$" && req.url.path ~ "^/$" && req.http.x-uscp-site == "desktop") { | |
# If the user has already been assigned to a test variant, we set X-AbVariant. | |
if (req.http.Cookie:abtest120) { | |
set req.http.X-AbVariant = req.http.Cookie:abtest120; | |
# If the user was part of the previous test (113), we grandfather them in accordingly. We do this to avoid | |
# disrupting the user experience for users who have become acclimated to the new list UI. | |
} else if (req.http.Cookie:abtest113) { | |
# The user was part of the previous, singular list variant, so we give them a 50% chance to be assigned | |
# to one of the new test variants. | |
if (req.http.Cookie:abtest113 == "113_list") { | |
if (randombool(50,100)) { | |
set req.http.X-AbVariant = "120_right_rail"; | |
} else { | |
set req.http.X-AbVariant = "120_left_rail"; | |
} | |
# If the user was part of the previous legacy variant, which was 20% of users, we want half of them to be | |
# bucketed into the new legacy variant, giving us the 10/10/10 split across the three variants (30%). | |
} else if (req.http.Cookie:abtest113 == "113_legacy" && randombool(50,100)) { | |
set req.http.X-AbVariant = "120_legacy"; | |
} else { | |
set req.http.X-AbVariant = "120_untested"; | |
} | |
# The user wasn't part of previous test, so we give them a 30% chance to get into the new test. | |
} else if (randombool(30,100)) { | |
if (randombool(66,99)) { | |
# 10% chance to get into the right rail variant. | |
if (randombool(50,100)) { | |
set req.http.X-AbVariant = "120_right_rail"; | |
# 10% chance to get into the left rail variant. | |
} else { | |
set req.http.X-AbVariant = "120_left_rail"; | |
} | |
# 10% chance to get into the legacy variant. | |
} else { | |
set req.http.X-AbVariant = "120_legacy"; | |
} | |
} else { | |
set req.http.X-AbVariant = "120_untested"; | |
} | |
if (req.http.X-AbVariant == "120_right_rail" || req.http.X-AbVariant == "120_left_rail") { | |
set req.http.X-AltUrl = "/home/list_variant_a/"; | |
} | |
if (req.http.X-AbVariant == "120_left_rail") { | |
set req.http.X-flLayoutOptions = "sidebar-left right-images inline-video gallery-mosaic"; | |
} | |
} | |
##################### | |
## Cincinnati | |
##################### | |
if (req.http.x-uscp-property == "cincinnati" && req.url.path ~ "^/$" && req.http.x-uscp-site == "desktop" ) { | |
# If the user has already been assigned to a test variant, we set X-AbVariant. | |
if (req.http.Cookie:abtest121) { | |
set req.http.X-AbVariant = req.http.Cookie:abtest121; | |
# If the user was part of the previous test (115), we grandfather them in accordingly. We do this to avoid | |
# disrupting the user experience for users who have become acclimated to the new list UI. | |
} else if (req.http.Cookie:abtest115) { | |
# The user was part of the previous, singular list variant, so we give them a 50% chance to be assigned | |
# to one of the new test variants. | |
if (req.http.Cookie:abtest115 == "115_list") { | |
if (randombool(50,100)) { | |
set req.http.X-AbVariant = "121_right_rail"; | |
} else { | |
set req.http.X-AbVariant = "121_left_rail"; | |
} | |
# If the user was part of the previous legacy variant, which was 20% of users, we want half of them to be | |
# bucketed into the new legacy variant, giving us the 10/10/10 split across the three variants (30%). | |
} else if (req.http.Cookie:abtest115 == "115_legacy" && randombool(50,100)) { | |
set req.http.X-AbVariant = "121_legacy"; | |
} else { | |
set req.http.X-AbVariant = "121_untested"; | |
} | |
# The user wasn't part of previous test, so we give them a 30% chance to get into the new test. | |
} else if (randombool(30,100)) { | |
if (randombool(66,99)) { | |
# 10% chance to get into the right rail variant. | |
if (randombool(50,100)) { | |
set req.http.X-AbVariant = "121_right_rail"; | |
# 10% chance to get into the left rail variant. | |
} else { | |
set req.http.X-AbVariant = "121_left_rail"; | |
} | |
# 10% chance to get into the legacy variant. | |
} else { | |
set req.http.X-AbVariant = "121_legacy"; | |
} | |
} else { | |
set req.http.X-AbVariant = "121_untested"; | |
} | |
if (req.http.X-AbVariant == "121_right_rail" || req.http.X-AbVariant == "121_left_rail") { | |
set req.http.X-AltUrl = "/home/list_variant_a/"; | |
} | |
if (req.http.X-AbVariant == "121_left_rail") { | |
set req.http.X-flLayoutOptions = "sidebar-left right-images inline-video gallery-mosaic"; | |
} | |
} | |
##################### | |
## Coloradoan | |
##################### | |
if (req.http.x-uscp-property == "coloradoan" && req.http.x-uscp-site == "desktop" ) { | |
if (req.url.path ~ "^/$" || req.url.path ~ "^/([^/]+)/$" || req.url.path ~ "^/([^/]+)/([^/]+)/$") { | |
if (req.http.Cookie:abtest119) { | |
set req.http.X-AbVariant = req.http.Cookie:abtest119; | |
} else if (randombool(50,100)) { | |
set req.http.X-AbVariant = "119_left_rail"; | |
} else { | |
set req.http.X-AbVariant = "119_right_rail"; | |
} | |
if (req.http.X-AbVariant == "119_left_rail") { | |
set req.http.X-flLayoutOptions = "sidebar-left right-images inline-video gallery-mosaic"; | |
} | |
} | |
} | |
} | |
sub abtest_fetch { | |
# Vary on X-AbVariant | |
if (beresp.http.Vary) { | |
set beresp.http.Vary = beresp.http.Vary ", X-AbVariant"; | |
} else { | |
set beresp.http.Vary = "X-AbVariant"; | |
} | |
# Vary on X-AltUrl | |
if (beresp.http.Vary) { | |
set beresp.http.Vary = beresp.http.Vary ", X-AltUrl"; | |
} else { | |
set beresp.http.Vary = "X-AltUrl"; | |
} | |
} | |
sub abtest_deliver { | |
##################### | |
## Courier-Journal | |
##################### | |
if (req.http.x-uscp-property ~ "^courier-?journal$" && req.http.X-AbVariant ~ "^120_" && req.http.x-uscp-site == "desktop") { | |
if (!req.http.Cookie:abtest120) { | |
add resp.http.Set-Cookie = "abtest120=" req.http.X-AbVariant "; path=/; expires=" now + 180d ";"; | |
} | |
add resp.http.X-AbVariant = req.http.X-AbVariant; | |
} | |
##################### | |
## Cincinnati | |
##################### | |
if (req.http.x-uscp-property == "cincinnati" && req.http.X-AbVariant ~ "^121_" && req.http.x-uscp-site == "desktop") { | |
if (!req.http.Cookie:abtest121) { | |
add resp.http.Set-Cookie = "abtest121=" req.http.X-AbVariant "; path=/; expires=" now + 180d ";"; | |
} | |
add resp.http.X-AbVariant = req.http.X-AbVariant; | |
} | |
##################### | |
## Coloradoan | |
##################### | |
if (req.http.x-uscp-property == "coloradoan" && req.http.X-AbVariant && req.http.x-uscp-site == "desktop") { | |
if (req.http.X-AbVariant ~ "^119_" && !req.http.Cookie:abtest119) { | |
add resp.http.Set-Cookie = "abtest119=" req.http.X-AbVariant "; path=/; expires=" now + 180d ";"; | |
} | |
add resp.http.X-AbVariant = req.http.X-AbVariant; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment