...
In general, check whether the flag is enabled as late as possible. This is purely for analytics reasons, because we’ll send a segment event once the flag is checked (if a user is actually bucketed). So, for example:
Code Block | ||
---|---|---|
| ||
# Wrong way, don't do this
if EXAMPLE_FLAG.is_enabled(course_key) and course.self_paced:
# experiment path |
That code will always send a segment event, for both instructor paced and self paced courses. But if you reorder it:
Code Block | ||
---|---|---|
| ||
# Correct way, copy and paste at will
if course.self_paced and EXAMPLE_FLAG.is_enabled(course_key):
# experiment path |
...