Feature flags rework (#1474)

This diff tweaks our `debugFlags` framework to support setting different
default value for different environments, makes it easier to define
feature flags, and makes feature flags show up in the debug menu by
default. With this change, feature flags will default to being enabled
in dev and preview environments, but disabled in production.

Specify a feature flag like this:
```ts
const featureFlags = {
      myCoolNewFeature: createFeatureFlag('myCoolNewFeature')
}
```

optionally, pass a second value to control its defaults:
```ts
const featureFlags = {
    featureEnabledInProduction: createFeatureFlag('someFeature', { all: true }),
    customEnabled: createFeatureFlag('otherFeature', {development: true, staging: false, production: false}),
}
```

In code, the value can be read using `featureFlags.myFeature.value`.
Remember to wrap reading it in a reactive context!

### Change Type

- [x] `patch` — Bug Fix

### Test Plan

-

### Release Notes

[internal only change]
This commit is contained in:
alex 2023-05-30 14:06:15 +01:00 committed by GitHub
parent 7578fff2b1
commit 4048064e78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 252 additions and 113 deletions

View file

@ -429,8 +429,8 @@ const DebugSvgCopy = track(function DupSvg({ id }: { id: TLShapeId }) {
)
})
const UiLogger = () => {
const logMessages = useValue(debugFlags.logMessages)
const UiLogger = track(() => {
const logMessages = debugFlags.logMessages.value
return (
<div className="debug__ui-logger">
@ -445,4 +445,4 @@ const UiLogger = () => {
})}
</div>
)
}
})