Skip to content

Commit 3aaf5a3

Browse files
authored
Merge pull request #267 from launchdarkly-labs/cko_2025
Cko 2025
2 parents 1667513 + 9faafe7 commit 3aaf5a3

File tree

3 files changed

+108
-18
lines changed

3 files changed

+108
-18
lines changed

Diff for: .github/workflows/demo_provisioning_scripts/DemoBuilder.py

+59-16
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ def create_metric_groups(self):
117117
print("Creating metric groups:")
118118
print(" - Store Purchases Metric Group")
119119
self.metgroup_store_purchases()
120+
print(" - Shorten Collection Page Metric Group")
121+
self.metgroup_shorten_collection_page()
120122
print("Done")
121123
self.metric_groups_created = True
122124

@@ -142,14 +144,14 @@ def create_flags(self):
142144
self.flag_api_guarded_release()
143145
#print(" - C1 - Experiment: AI Models for Chatbot")
144146
#self.flag_exp_chatbot_ai_models()
147+
print(" - D1 - Feature Experiment: Suggested Items Carousel")
148+
self.flag_exp_suggestions_carousel()
145149
print(" - D1 - Funnel Experiment: Promotion Banner")
146150
self.flag_exp_promotion_banner()
147-
print(" - D2 - Feature Experiment: Suggested Items Carousel")
148-
self.flag_exp_suggestions_carousel()
149-
print(" - D3 - Funnel Experiment: New Shorten Collection Page")
150-
self.flag_exp_shorten_collections_page()
151-
print(" - D4 - Feature Experiment: New Search Engine")
151+
print(" - D3 - Feature Experiment: New Search Engine")
152152
self.flag_exp_new_search_engine()
153+
print(" - D4 - Funnel Experiment: New Shorten Collection Page")
154+
self.flag_exp_shorten_collections_page()
153155
print(" - E1 - Migration: Database (Migration Tool)")
154156
self.flag_database_migration()
155157

@@ -358,7 +360,7 @@ def run_ecommerce_shorten_collection_funnel_experiment(self):
358360

359361
def create_ecommerce_shorten_collection_funnel_experiment(self):
360362
metrics = [
361-
self.ldproject.exp_metric("shorten-collection-page-increase-conversation-metric-group", True), #TODO: need to get metric key for metric group for shorten collection
363+
self.ldproject.exp_metric("shorten-collection-page-metric-group", True),
362364
self.ldproject.exp_metric("in-cart-total-price", False)
363365
]
364366
res = self.ldproject.create_experiment(
@@ -444,13 +446,29 @@ def create_togglebank_ai_config_experiment(self):
444446
##################################################
445447
# Create all the experiment holdouts
446448

447-
# def create_and_run_experiments(self):
448-
# self.run_ecommerce_collection_banner_funnel_experiment()
449-
# self.run_ecommerce_upsell_component_feature_experiment()
450-
# self.run_ecommerce_shorten_collection_funnel_experiment()
451-
# self.run_ecommerce_new_search_engine_feature_experiment()
452-
# self.run_togglebank_ai_config_experiment()
453-
449+
def create_and_run_holdout(self):
450+
self.run_q4_increase_incart_price_holdout()
451+
452+
def run_q4_increase_incart_price_holdout(self):
453+
metrics = [
454+
{
455+
"key": "in-cart-total-price",
456+
"isGroup": False,
457+
"primary": True
458+
}
459+
]
460+
res = self.ldproject.create_holdout(
461+
self=self,
462+
holdout_key= "q-4-increase-average-total-in-cart-price",
463+
holdout_name="Q4 Increase Average Total Incart Price",
464+
holdout_env_key="production",
465+
description="This holdout is to see if the new experiments will increase average total cart price and overall revenue.",
466+
metrics= metrics,
467+
primary_metric_key= "in-cart-total-price",
468+
randomization_unit="users",
469+
attributes=["tier"],
470+
prerequisiteflagkey="release-new-search-engine"
471+
)
454472
############################################################################################################
455473

456474
##################################################
@@ -461,7 +479,7 @@ def create_togglebank_ai_config_experiment(self):
461479
##################################################
462480
# Create all the experiment layers
463481

464-
# def create_and_run_experiments(self):
482+
# def create_and_run_layer(self):
465483
# self.run_ecommerce_collection_banner_funnel_experiment()
466484
# self.run_ecommerce_upsell_component_feature_experiment()
467485
# self.run_ecommerce_shorten_collection_funnel_experiment()
@@ -754,6 +772,18 @@ def metric_store_checkout_completed(self):
754772
success_criteria="HigherThanBaseline",
755773
tags=["experiment"]
756774
)
775+
776+
def metric_search_engine(self):
777+
res = self.ldproject.create_metric(
778+
"search-engine-add-to-cart",
779+
"New Search Engine Add To Cart is Clicked",
780+
"search-engine-add-to-cart",
781+
"This metric will track the number of times the new add to cart button within the new search engine is clicked.",
782+
numeric=False,
783+
unit="",
784+
success_criteria="HigherThanBaseline",
785+
tags=["experiment"]
786+
)
757787

758788
############################################################################################################
759789

@@ -989,6 +1019,19 @@ def metgroup_store_purchases(self):
9891019
description="This metric group will track the store purchases",
9901020
)
9911021

1022+
def metgroup_shorten_collection_page(self):
1023+
res = self.ldproject.create_metric_group(
1024+
"shorten-collection-page-metric-group",
1025+
"Shorten Collection Page Metric Group",
1026+
[
1027+
{"key": "item-added", "nameInGroup": "1"},
1028+
{"key": "cart-accessed", "nameInGroup": "2"},
1029+
{"key": "customer-checkout", "nameInGroup": "3"},
1030+
],
1031+
kind="funnel",
1032+
description="This metric group will track the store purchases relating to the new shorten collection page.",
1033+
)
1034+
9921035

9931036
############################################################################################################
9941037

@@ -1169,7 +1212,7 @@ def flag_exp_chatbot_ai_models(self):
11691212
def flag_exp_promotion_banner(self):
11701213
res = self.ldproject.create_flag(
11711214
"storeAttentionCallout",
1172-
"D1 - Funnel Experiment: Promotion Banner",
1215+
"D2 - Funnel Experiment: Promotion Banner",
11731216
"Releasing New Collection Promotion Banner for the Galaxy Marketplace",
11741217
[
11751218
{
@@ -1193,7 +1236,7 @@ def flag_exp_promotion_banner(self):
11931236
def flag_exp_suggestions_carousel(self):
11941237
res = self.ldproject.create_flag(
11951238
"cartSuggestedItems",
1196-
"D2 - Feature Experiment: Suggested Items Carousel",
1239+
"D1 - Feature Experiment: Suggested Items Carousel",
11971240
"Releasing New Suggested Items Carousel Component for the cart component in Galaxy Marketplace",
11981241
[
11991242
{

Diff for: .github/workflows/demo_provisioning_scripts/LDPlatform.py

+45
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,51 @@ def create_experiment(
641641
##################################################
642642
# Create a holdout
643643
##################################################
644+
def create_holdout(
645+
self,
646+
holdout_key,
647+
holdout_name,
648+
holdout_env_key,
649+
description,
650+
metrics,
651+
primary_metric_key,
652+
randomization_unit="users",
653+
attributes=None,
654+
prerequisiteflagkey=""
655+
):
656+
657+
payload = {
658+
"name": holdout_name,
659+
"key": holdout_key,
660+
"description": description,
661+
"randomizationunit": randomization_unit,
662+
"attributes": attributes,
663+
"holdoutamount": "10",
664+
"primarymetrickey": primary_metric_key,
665+
"metrics": metrics,
666+
"prerequisiteflagkey": prerequisiteflagkey
667+
}
668+
669+
headers = {
670+
"Content-Type": "application/json",
671+
"Authorization": self.api_key,
672+
}
673+
674+
response = self.getrequest(
675+
"POST",
676+
"https://app.launchdarkly.com/api/v2/projects/"
677+
+ self.project_key
678+
+ "/environments/"
679+
+ holdout_env_key
680+
+ "/holdouts",
681+
json=payload,
682+
headers=headers,
683+
)
684+
685+
data = json.loads(response.text)
686+
if "message" in data:
687+
print("Error creating holdout: " + data["message"])
688+
return response
644689

645690
##################################################
646691
# Create a layer

Diff for: pages/marketplace.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ export default function Marketplace() {
6060
}
6161

6262
const LDClient = useLDClient();
63-
const { storeAttentionCallout } = useFlags();
6463
const releaseNewSearchEngine = useFlags()["release-new-search-engine"]?.includes("new-search-engine");
65-
6664

6765
const [cart, setCart] = useState<InventoryItem[]>([]);
6866

@@ -81,6 +79,7 @@ export default function Marketplace() {
8179
if (releaseNewSearchEngine) {
8280
addToCart(item);
8381
LDClient?.track("search-engine-add-to-cart", LDClient.getContext());
82+
logLDMetricSent("search-engine-add-to-cart");
8483
toast({
8584
title: `${item.item} has been added to your cart!`,
8685
wrapperStyle: "bg-gradient-experimentation text-white !text-medium font-bold font-sohne",
@@ -98,6 +97,9 @@ export default function Marketplace() {
9897
if (item.vendor === "boominbox") {
9998
setOpenBoominBox(true);
10099
}
100+
101+
LDClient?.track("search-engine-add-to-cart", LDClient.getContext());
102+
logLDMetricSent("search-engine-add-to-cart");
101103
};
102104

103105
const formatResult = (item: InventoryItem) => {

0 commit comments

Comments
 (0)