Merge pull request #14607 from Budibase/feature-flag-flag

Require a flag to be set to query PostHog for feature flags.
This commit is contained in:
Sam Rose 2024-09-19 11:49:49 +01:00 committed by GitHub
commit 4db1609ca3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 1 deletions

View File

@ -143,6 +143,7 @@ const environment = {
POSTHOG_TOKEN: process.env.POSTHOG_TOKEN,
POSTHOG_PERSONAL_TOKEN: process.env.POSTHOG_PERSONAL_TOKEN,
POSTHOG_API_HOST: process.env.POSTHOG_API_HOST || "https://us.i.posthog.com",
POSTHOG_FEATURE_FLAGS_ENABLED: process.env.POSTHOG_FEATURE_FLAGS_ENABLED,
ENABLE_ANALYTICS: process.env.ENABLE_ANALYTICS,
TENANT_FEATURE_FLAGS: process.env.TENANT_FEATURE_FLAGS,
CLOUDFRONT_CDN: process.env.CLOUDFRONT_CDN,

View File

@ -6,7 +6,12 @@ import tracer from "dd-trace"
let posthog: PostHog | undefined
export function init(opts?: PostHogOptions) {
if (env.POSTHOG_TOKEN && env.POSTHOG_API_HOST && !env.SELF_HOSTED) {
if (
env.POSTHOG_TOKEN &&
env.POSTHOG_API_HOST &&
!env.SELF_HOSTED &&
env.POSTHOG_FEATURE_FLAGS_ENABLED
) {
console.log("initializing posthog client...")
posthog = new PostHog(env.POSTHOG_TOKEN, {
host: env.POSTHOG_API_HOST,

View File

@ -148,6 +148,7 @@ describe("feature flags", () => {
const env: Partial<typeof environment> = {
TENANT_FEATURE_FLAGS: environmentFlags,
SELF_HOSTED: false,
POSTHOG_FEATURE_FLAGS_ENABLED: "true",
}
if (posthogFlags) {