@@ -274,6 +274,98 @@ def load_env_file():
274
274
print (" - Zero API calls needed: ✅ YES (all evaluated locally)" )
275
275
print (" - Python SDK supports flag dependencies: ✅ YES" )
276
276
277
+ print ("\n " + "-" * 60 )
278
+ print ("PRODUCTION-STYLE MULTIVARIATE DEPENDENCY CHAIN" )
279
+ print ("-" * 60 )
280
+ print ("🔗 Testing complex multivariate flag dependencies..." )
281
+ print (
282
+ " Structure: multivariate-root-flag -> multivariate-intermediate-flag -> multivariate-leaf-flag"
283
+ )
284
+ print ("" )
285
+ print ("📋 Required setup (if flags don't exist):" )
286
+ print (
287
+ " 1. Create 'multivariate-leaf-flag' with fruit variants (pineapple, mango, papaya, kiwi)"
288
+ )
289
+ print (
" - pineapple: email = '[email protected] '" )
290
+ print (
" - mango: email = '[email protected] '" )
291
+ print (
292
+ " 2. Create 'multivariate-intermediate-flag' with color variants (blue, red)"
293
+ )
294
+ print (" - blue: depends on multivariate-leaf-flag = 'pineapple'" )
295
+ print (" - red: depends on multivariate-leaf-flag = 'mango'" )
296
+ print (
297
+ " 3. Create 'multivariate-root-flag' with show variants (breaking-bad, the-wire)"
298
+ )
299
+ print (" - breaking-bad: depends on multivariate-intermediate-flag = 'blue'" )
300
+ print (" - the-wire: depends on multivariate-intermediate-flag = 'red'" )
301
+ print ("" )
302
+
303
+ # Test pineapple -> blue -> breaking-bad chain
304
+ dependent_result3 = posthog .get_feature_flag (
305
+ "multivariate-root-flag" ,
306
+ "regular_user" ,
307
+ person_properties = {
"email" :
"[email protected] " },
308
+ only_evaluate_locally = True ,
309
+ )
310
+ if str (dependent_result3 ) != "breaking-bad" :
311
+ print (
312
+ f" ❌ Something went wrong evaluating 'multivariate-root-flag' with [email protected] . Expected 'breaking-bad', got '{ dependent_result3 } '"
313
+ )
314
+ else :
315
+ print (
"✅ 'multivariate-root-flag' with email [email protected] succeeded" )
316
+
317
+ # Test mango -> red -> the-wire chain
318
+ dependent_result4 = posthog .get_feature_flag (
319
+ "multivariate-root-flag" ,
320
+ "regular_user" ,
321
+ person_properties = {
"email" :
"[email protected] " },
322
+ only_evaluate_locally = True ,
323
+ )
324
+ if str (dependent_result4 ) != "the-wire" :
325
+ print (
326
+ f" ❌ Something went wrong evaluating multivariate-root-flag with [email protected] . Expected 'the-wire', got '{ dependent_result4 } '"
327
+ )
328
+ else :
329
+ print (
"✅ 'multivariate-root-flag' with email [email protected] succeeded" )
330
+
331
+ # Show the complete chain evaluation
332
+ print ("\n 🔍 Complete dependency chain evaluation:" )
333
+ for email , expected_chain in [
334
+ (
"[email protected] " , [
"pineapple" ,
"blue" ,
"breaking-bad" ]),
335
+ (
"[email protected] " , [
"mango" ,
"red" ,
"the-wire" ]),
336
+ ]:
337
+ leaf = posthog .get_feature_flag (
338
+ "multivariate-leaf-flag" ,
339
+ "regular_user" ,
340
+ person_properties = {"email" : email },
341
+ only_evaluate_locally = True ,
342
+ )
343
+ intermediate = posthog .get_feature_flag (
344
+ "multivariate-intermediate-flag" ,
345
+ "regular_user" ,
346
+ person_properties = {"email" : email },
347
+ only_evaluate_locally = True ,
348
+ )
349
+ root = posthog .get_feature_flag (
350
+ "multivariate-root-flag" ,
351
+ "regular_user" ,
352
+ person_properties = {"email" : email },
353
+ only_evaluate_locally = True ,
354
+ )
355
+
356
+ actual_chain = [str (leaf ), str (intermediate ), str (root )]
357
+ chain_success = actual_chain == expected_chain
358
+
359
+ print (f" 📧 { email } :" )
360
+ print (f" Expected: { ' -> ' .join (map (str , expected_chain ))} " )
361
+ print (f" Actual: { ' -> ' .join (map (str , actual_chain ))} " )
362
+ print (f" Status: { '✅ SUCCESS' if chain_success else '❌ FAILED' } " )
363
+
364
+ print ("\n 🎯 Multivariate Chain Summary:" )
365
+ print (" - Complex dependency chains: ✅ SUPPORTED" )
366
+ print (" - Multivariate flag dependencies: ✅ SUPPORTED" )
367
+ print (" - Local evaluation of chains: ✅ WORKING" )
368
+
277
369
elif choice == "5" :
278
370
print ("\n " + "=" * 60 )
279
371
print ("CONTEXT MANAGEMENT AND TAGGING EXAMPLES" )
0 commit comments