feat(api): enable all feature flags if posthog is not configured#3658
feat(api): enable all feature flags if posthog is not configured#3658
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enables all feature flags by default in non-production environments where PostHog is not configured, removing the need to manually enable features during development and testing.
Changes:
- Created a custom
useFeatureFlagEnabledhook in the dashboard that returnstruefor all flags when PostHog is not configured - Changed default values for feature flag decorators in the API from
falsetotrue - Updated the PostHog initialization log message to clarify when feature flags are disabled
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/dashboard/src/hooks/useFeatureFlagEnabled.ts | New hook that wraps PostHog's feature flag check and returns true when PostHog is not configured |
| apps/dashboard/src/components/Sidebar.tsx | Updated import to use the new custom useFeatureFlagEnabled hook |
| apps/dashboard/src/App.tsx | Updated import to use the new custom useFeatureFlagEnabled hook |
| apps/api/src/sandbox/controllers/sandbox.controller.ts | Changed SANDBOX_RESIZE flag default from false to true |
| apps/api/src/sandbox/controllers/runner.controller.ts | Changed ORGANIZATION_INFRASTRUCTURE flag default from false to true across multiple endpoints |
| apps/api/src/organization/controllers/organization-region.controller.ts | Changed ORGANIZATION_INFRASTRUCTURE flag default from false to true across multiple endpoints |
| apps/api/src/common/providers/openfeature-posthog.provider.ts | Updated log message to clarify that feature flags are disabled when PostHog is not configured |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Toma Puljak <toma.puljak@hotmail.com>
Signed-off-by: Toma Puljak <toma.puljak@hotmail.com>
678be2c to
c675622
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 14 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @UseGuards(OrganizationResourceActionGuard) | ||
| @RequiredOrganizationResourcePermissions([OrganizationResourcePermission.WRITE_RUNNERS]) | ||
| @RequireFlagsEnabled({ flags: [{ flagKey: FeatureFlags.ORGANIZATION_INFRASTRUCTURE, defaultValue: false }] }) | ||
| @RequireFlagsEnabled({ flags: [{ flagKey: FeatureFlags.ORGANIZATION_INFRASTRUCTURE, defaultValue: true }] }) |
There was a problem hiding this comment.
Setting defaultValue: true broadly enables these endpoints on any evaluation failure (not just “PostHog not configured”). To match the PR’s stated intent and avoid accidentally exposing infra endpoints, prefer defaultValue: false and do the “enable all when PostHog isn’t configured” behavior in the flag provider/decorator fallback path.
| @RequireFlagsEnabled({ flags: [{ flagKey: FeatureFlags.ORGANIZATION_INFRASTRUCTURE, defaultValue: true }] }) | |
| @RequireFlagsEnabled({ flags: [{ flagKey: FeatureFlags.ORGANIZATION_INFRASTRUCTURE, defaultValue: false }] }) |
| @UseGuards(OrganizationResourceActionGuard) | ||
| @RequiredOrganizationResourcePermissions([OrganizationResourcePermission.READ_RUNNERS]) | ||
| @RequireFlagsEnabled({ flags: [{ flagKey: FeatureFlags.ORGANIZATION_INFRASTRUCTURE, defaultValue: false }] }) | ||
| @RequireFlagsEnabled({ flags: [{ flagKey: FeatureFlags.ORGANIZATION_INFRASTRUCTURE, defaultValue: true }] }) |
There was a problem hiding this comment.
Setting defaultValue: true broadly enables these endpoints on any evaluation failure (not just “PostHog not configured”). To match the PR’s stated intent and avoid accidentally exposing infra endpoints, prefer defaultValue: false and do the “enable all when PostHog isn’t configured” behavior in the flag provider/decorator fallback path.
| @RequireFlagsEnabled({ flags: [{ flagKey: FeatureFlags.ORGANIZATION_INFRASTRUCTURE, defaultValue: true }] }) | |
| @RequireFlagsEnabled({ flags: [{ flagKey: FeatureFlags.ORGANIZATION_INFRASTRUCTURE, defaultValue: false }] }) |
| @UseGuards(OrganizationResourceActionGuard, RunnerAccessGuard) | ||
| @RequiredOrganizationResourcePermissions([OrganizationResourcePermission.WRITE_RUNNERS]) | ||
| @RequireFlagsEnabled({ flags: [{ flagKey: FeatureFlags.ORGANIZATION_INFRASTRUCTURE, defaultValue: false }] }) | ||
| @RequireFlagsEnabled({ flags: [{ flagKey: FeatureFlags.ORGANIZATION_INFRASTRUCTURE, defaultValue: true }] }) |
There was a problem hiding this comment.
Setting defaultValue: true broadly enables these endpoints on any evaluation failure (not just “PostHog not configured”). To match the PR’s stated intent and avoid accidentally exposing infra endpoints, prefer defaultValue: false and do the “enable all when PostHog isn’t configured” behavior in the flag provider/decorator fallback path.
| @RequireFlagsEnabled({ flags: [{ flagKey: FeatureFlags.ORGANIZATION_INFRASTRUCTURE, defaultValue: true }] }) | |
| @RequireFlagsEnabled({ flags: [{ flagKey: FeatureFlags.ORGANIZATION_INFRASTRUCTURE, defaultValue: false }] }) |
| @UseGuards(RegionAccessGuard) | ||
| @RequiredOrganizationResourcePermissions([OrganizationResourcePermission.WRITE_REGIONS]) | ||
| @RequireFlagsEnabled({ flags: [{ flagKey: FeatureFlags.ORGANIZATION_INFRASTRUCTURE, defaultValue: false }] }) | ||
| @RequireFlagsEnabled({ flags: [{ flagKey: FeatureFlags.ORGANIZATION_INFRASTRUCTURE, defaultValue: true }] }) |
There was a problem hiding this comment.
Same concern as other controllers: defaultValue: true makes these operations enabled on any flag lookup/evaluation failure. If the requirement is limited to “when PostHog isn’t configured,” keep defaults conservative and implement the unconditional enablement only for the “no PostHog” fallback case.
| @RequireFlagsEnabled({ flags: [{ flagKey: FeatureFlags.ORGANIZATION_INFRASTRUCTURE, defaultValue: true }] }) | |
| @RequireFlagsEnabled({ flags: [{ flagKey: FeatureFlags.ORGANIZATION_INFRASTRUCTURE, defaultValue: false }] }) |
| @UseGuards(RegionAccessGuard) | ||
| @RequiredOrganizationResourcePermissions([OrganizationResourcePermission.WRITE_REGIONS]) | ||
| @RequireFlagsEnabled({ flags: [{ flagKey: FeatureFlags.ORGANIZATION_INFRASTRUCTURE, defaultValue: false }] }) | ||
| @RequireFlagsEnabled({ flags: [{ flagKey: FeatureFlags.ORGANIZATION_INFRASTRUCTURE, defaultValue: true }] }) |
There was a problem hiding this comment.
Same concern as other controllers: defaultValue: true makes these operations enabled on any flag lookup/evaluation failure. If the requirement is limited to “when PostHog isn’t configured,” keep defaults conservative and implement the unconditional enablement only for the “no PostHog” fallback case.
| @UseGuards(RegionAccessGuard) | ||
| @RequiredOrganizationResourcePermissions([OrganizationResourcePermission.WRITE_REGIONS]) | ||
| @RequireFlagsEnabled({ flags: [{ flagKey: FeatureFlags.ORGANIZATION_INFRASTRUCTURE, defaultValue: false }] }) | ||
| @RequireFlagsEnabled({ flags: [{ flagKey: FeatureFlags.ORGANIZATION_INFRASTRUCTURE, defaultValue: true }] }) |
There was a problem hiding this comment.
Same concern as other controllers: defaultValue: true makes these operations enabled on any flag lookup/evaluation failure. If the requirement is limited to “when PostHog isn’t configured,” keep defaults conservative and implement the unconditional enablement only for the “no PostHog” fallback case.
| console.error('Failed to initialize PostHog client. Feature flags will use default values.', error) | ||
| } | ||
| } else { | ||
| console.log('PostHog not configured. Feature flags will use default values.') | ||
| } |
There was a problem hiding this comment.
Using console.log/error in API server code can make logs noisy/inconsistent versus the app’s structured logger (e.g., NestJS Logger) and may bypass log formatting/levels. Prefer the project’s logger abstraction here (and consider making the “not configured” message debug/info-level rather than unconditional stdout).
|
Draft until further discussion |
Description
Enables all feature flags in the API and dashboard if posthog is not configured.
In non-prod environments, where posthog is not configured, there's no reason to block features behind feature flags.
Documentation