Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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
languagepy
# 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
languagepy
# Correct way, copy and paste at will
if course.self_paced and EXAMPLE_FLAG.is_enabled(course_key):
    # experiment path

...