-
-
Notifications
You must be signed in to change notification settings - Fork 168
Expand file tree
/
Copy pathflags.ts
More file actions
29 lines (25 loc) · 833 Bytes
/
flags.ts
File metadata and controls
29 lines (25 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { posthog } from "posthog-js";
export const FEATURE_FLAGS = {
FEATURE_FLAG_TEST: "feature-flag-test",
COURSE_VIDEO: "course-video",
JOBS: "jobs",
// Add more feature flags as needed
} as const;
export type FeatureFlagName =
(typeof FEATURE_FLAGS)[keyof typeof FEATURE_FLAGS];
export function isDevEnvironment() {
return (
process.env.NODE_ENV === "development" ||
(typeof window !== "undefined" && window.location.hostname === "localhost")
);
}
export const isFlagEnabled = (
featureFlag: FeatureFlagName,
disableDevCheck = false, // Disable dev check to force feature flag to be checked always
) => {
if (!disableDevCheck && isDevEnvironment()) {
console.log("Feature flag check skipped in development environment");
return true;
}
return posthog.isFeatureEnabled(featureFlag);
};