Handle both V1 and V2 of Cirrus' data structure #5508
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
getExperiments
pretended that it always returned experiment data in the Cirrus V2 format, but in reality, it returned it in V1 format (by taking theFeatures
property from the V2 format if that's what it got). The reason TypeScript didn't warn about this, is becauseresponse.json()
resolves to anany
, and thus we could just assert that to be the expected type even when it wasn't.In this PR, I've updated it to either return the V2 format directly, or, if the
CirrusV2
flag is disabled, return theV1
object wrapped in{ Features: <the V1 object> }
. And I created a new typeExperimentData_V2_Or_V2LikeV1
that reflects that, i.e. that is like the V2 format, expect that theEnrollments
property can beundefined
.Once we remove the
CirrusV2
flag, we can look at where that type is used and update it to justExperimentData
.How to test
Well... I think we can only test this on stage, because I don't think we can run Cirrus locally. But we'll have to make sure to test both with the flag on and off :)
Checklist (Definition of Done)