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:
commit
4db1609ca3
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue