Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add is_preview env check #4599

Merged
merged 5 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps/web/src/lib/isFeatureAvailable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { FeatureFlag } from '@hey/data/feature-flags';

import { IS_PREVIEW, IS_PRODUCTION } from '@hey/data/constants';
import { hydrateFeatureFlags } from 'src/store/persisted/useFeatureFlagsStore';

import getCurrentSession from './getCurrentSession';
Expand All @@ -10,6 +11,10 @@ import getCurrentSession from './getCurrentSession';
* @returns Whether the feature is enabled
*/
const isFeatureAvailable = (key: FeatureFlag | string) => {
if (!IS_PRODUCTION || IS_PREVIEW) {
return true;
}

const { id: sessionProfileId } = getCurrentSession();
const { featureFlags } = hydrateFeatureFlags();

Expand Down
5 changes: 5 additions & 0 deletions apps/web/src/lib/isFeatureEnabled.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { KillSwitch } from '@hey/data/feature-flags';

import { IS_PREVIEW, IS_PRODUCTION } from '@hey/data/constants';
import { hydrateFeatureFlags } from 'src/store/persisted/useFeatureFlagsStore';

/**
Expand All @@ -8,6 +9,10 @@ import { hydrateFeatureFlags } from 'src/store/persisted/useFeatureFlagsStore';
* @returns Whether the feature is enabled
*/
const isFeatureEnabled = (key: KillSwitch | string) => {
if (!IS_PRODUCTION || IS_PREVIEW) {
return true;
}

const { killSwitches } = hydrateFeatureFlags();

if (!killSwitches) {
Expand Down
1 change: 1 addition & 0 deletions packages/data/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import getEnvConfig from './utils/getEnvConfig';

// Environments
export const IS_PRODUCTION = process.env.NEXT_PUBLIC_IS_PRODUCTION === 'true';
export const IS_PREVIEW = process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview';

// Lens and Hey Env Config
export const LENS_NETWORK = process.env.NEXT_PUBLIC_LENS_NETWORK || 'mainnet';
Expand Down
Loading