-
-
Notifications
You must be signed in to change notification settings - Fork 169
Expand file tree
/
Copy pathflags.ts
More file actions
26 lines (22 loc) · 636 Bytes
/
Copy pathflags.ts
File metadata and controls
26 lines (22 loc) · 636 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
import { posthog } from "posthog-js";
export const FEATURE_FLAGS = {
FEATURE_FLAG_TEST: "feature-flag-test",
JOBS: "jobs",
} 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,
): boolean => {
if (!disableDevCheck && isDevEnvironment()) {
return true;
}
return !!posthog.isFeatureEnabled(featureFlag);
};