Skip to content

Add Support for Region-Based Feature Flags#10621

Merged
thsparks merged 2 commits intomasterfrom
thsparks/err_help/geo_support
Jun 11, 2025
Merged

Add Support for Region-Based Feature Flags#10621
thsparks merged 2 commits intomasterfrom
thsparks/err_help/geo_support

Conversation

@thsparks
Copy link
Contributor

This adds support for feature flags that can be enabled (or disabled) for specific regions, based on the backend changes here: https://github.com/microsoft/pxt-backend/pull/1117

I've created a more generic "enabledFeatures" section of the AppTheme in pxtarget in an attempt to manage the proliferation of top-level feature switches. If no includeRegions or excludeRegions are specified, then the feature is enabled globally. Otherwise, it will only be enabled if the user's region matches one of the includeRegions and does not match any of the excludeRegions.

For development purposes, I've added a DEV_REGION constant that we can change similar to how we manage DEV_BACKEND, which allows us to fake being in a different region on local builds. (This also simplified things, since our localhost cdn logic is a little weird and didn't actually go to staging.) In my own testing, however, I did ensure it works with an actual staging CDN URL, too.

Upload Target: https://microbit.staging.pxt.io/app/f213b4bfa13132146caf582b2110dae5f61052d3-b71ebd062f

Fixes microsoft/pxt-microbit#6238


try {
const response = await Util.requestAsync(options);
if (response.statusCode !== 200) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that the status code that we get from the backend could be something other than 200 on something that's successful?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something we control, and right now, 200 is the only "success" response we'd expect.

Copy link
Contributor

@srietkerk srietkerk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@thsparks thsparks enabled auto-merge (squash) June 11, 2025 19:54
thsparks added a commit to microsoft/pxt-microbit that referenced this pull request Jun 11, 2025
This sets feature flags for the blocks error list (globally enabled) and the AI Error Help (currently set to US only, though we'll likely want to change that to a different region before shipping).

Support for region-based feature flags is added in microsoft/pxt#10621
@thsparks thsparks merged commit 0c2adff into master Jun 11, 2025
20 checks passed
@thsparks thsparks deleted the thsparks/err_help/geo_support branch June 11, 2025 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error Help: Support for Geo-Based Rollout

3 participants