From 50da11525c4a44fdcb734b9313cb06ae4d0e2303 Mon Sep 17 00:00:00 2001 From: bigint <69431456+bigint@users.noreply.github.com> Date: Mon, 5 Feb 2024 12:08:13 +0530 Subject: [PATCH 1/5] feat: add is_preview env check --- apps/web/src/lib/isFeatureAvailable.ts | 5 +++++ apps/web/src/lib/isFeatureEnabled.ts | 5 +++++ packages/data/constants.ts | 1 + 3 files changed, 11 insertions(+) diff --git a/apps/web/src/lib/isFeatureAvailable.ts b/apps/web/src/lib/isFeatureAvailable.ts index c3ed7b2e4bc..39a60c2f1f8 100644 --- a/apps/web/src/lib/isFeatureAvailable.ts +++ b/apps/web/src/lib/isFeatureAvailable.ts @@ -1,5 +1,6 @@ import type { FeatureFlag } from '@hey/data/feature-flags'; +import { IS_PREVIEW } from '@hey/data/constants'; import { hydrateFeatureFlags } from 'src/store/persisted/useFeatureFlagsStore'; import getCurrentSession from './getCurrentSession'; @@ -10,6 +11,10 @@ import getCurrentSession from './getCurrentSession'; * @returns Whether the feature is enabled */ const isFeatureAvailable = (key: FeatureFlag | string) => { + if (IS_PREVIEW) { + return true; + } + const { id: sessionProfileId } = getCurrentSession(); const { featureFlags } = hydrateFeatureFlags(); diff --git a/apps/web/src/lib/isFeatureEnabled.ts b/apps/web/src/lib/isFeatureEnabled.ts index ebee40b124b..c7cd5971dd1 100644 --- a/apps/web/src/lib/isFeatureEnabled.ts +++ b/apps/web/src/lib/isFeatureEnabled.ts @@ -1,5 +1,6 @@ import type { KillSwitch } from '@hey/data/feature-flags'; +import { IS_PREVIEW } from '@hey/data/constants'; import { hydrateFeatureFlags } from 'src/store/persisted/useFeatureFlagsStore'; /** @@ -8,6 +9,10 @@ import { hydrateFeatureFlags } from 'src/store/persisted/useFeatureFlagsStore'; * @returns Whether the feature is enabled */ const isFeatureEnabled = (key: KillSwitch | string) => { + if (IS_PREVIEW) { + return true; + } + const { killSwitches } = hydrateFeatureFlags(); if (!killSwitches) { diff --git a/packages/data/constants.ts b/packages/data/constants.ts index 13ab9e4ebaf..a3130fda42f 100644 --- a/packages/data/constants.ts +++ b/packages/data/constants.ts @@ -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'; From 32b860826b496be6fd2ec2e96d6180a8ef8752b2 Mon Sep 17 00:00:00 2001 From: bigint <69431456+bigint@users.noreply.github.com> Date: Mon, 5 Feb 2024 12:10:13 +0530 Subject: [PATCH 2/5] feat: add is_preview env check --- apps/web/src/lib/isFeatureAvailable.ts | 4 ++-- apps/web/src/lib/isFeatureEnabled.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/web/src/lib/isFeatureAvailable.ts b/apps/web/src/lib/isFeatureAvailable.ts index 39a60c2f1f8..395a353beaf 100644 --- a/apps/web/src/lib/isFeatureAvailable.ts +++ b/apps/web/src/lib/isFeatureAvailable.ts @@ -1,6 +1,6 @@ import type { FeatureFlag } from '@hey/data/feature-flags'; -import { IS_PREVIEW } from '@hey/data/constants'; +import { IS_PREVIEW, IS_PRODUCTION } from '@hey/data/constants'; import { hydrateFeatureFlags } from 'src/store/persisted/useFeatureFlagsStore'; import getCurrentSession from './getCurrentSession'; @@ -11,7 +11,7 @@ import getCurrentSession from './getCurrentSession'; * @returns Whether the feature is enabled */ const isFeatureAvailable = (key: FeatureFlag | string) => { - if (IS_PREVIEW) { + if (IS_PREVIEW && !IS_PRODUCTION) { return true; } diff --git a/apps/web/src/lib/isFeatureEnabled.ts b/apps/web/src/lib/isFeatureEnabled.ts index c7cd5971dd1..b9041b9462c 100644 --- a/apps/web/src/lib/isFeatureEnabled.ts +++ b/apps/web/src/lib/isFeatureEnabled.ts @@ -1,6 +1,6 @@ import type { KillSwitch } from '@hey/data/feature-flags'; -import { IS_PREVIEW } from '@hey/data/constants'; +import { IS_PREVIEW, IS_PRODUCTION } from '@hey/data/constants'; import { hydrateFeatureFlags } from 'src/store/persisted/useFeatureFlagsStore'; /** @@ -9,7 +9,7 @@ import { hydrateFeatureFlags } from 'src/store/persisted/useFeatureFlagsStore'; * @returns Whether the feature is enabled */ const isFeatureEnabled = (key: KillSwitch | string) => { - if (IS_PREVIEW) { + if (IS_PREVIEW && !IS_PRODUCTION) { return true; } From 2b29ac6eb1f75535ec518df3151658baaff39e48 Mon Sep 17 00:00:00 2001 From: bigint <69431456+bigint@users.noreply.github.com> Date: Mon, 5 Feb 2024 12:25:37 +0530 Subject: [PATCH 3/5] fix: preview check --- apps/web/src/lib/isFeatureAvailable.ts | 2 +- apps/web/src/lib/isFeatureEnabled.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/web/src/lib/isFeatureAvailable.ts b/apps/web/src/lib/isFeatureAvailable.ts index 395a353beaf..55e6e99f109 100644 --- a/apps/web/src/lib/isFeatureAvailable.ts +++ b/apps/web/src/lib/isFeatureAvailable.ts @@ -11,7 +11,7 @@ import getCurrentSession from './getCurrentSession'; * @returns Whether the feature is enabled */ const isFeatureAvailable = (key: FeatureFlag | string) => { - if (IS_PREVIEW && !IS_PRODUCTION) { + if (!IS_PRODUCTION || IS_PREVIEW) { return true; } diff --git a/apps/web/src/lib/isFeatureEnabled.ts b/apps/web/src/lib/isFeatureEnabled.ts index b9041b9462c..b259e34d517 100644 --- a/apps/web/src/lib/isFeatureEnabled.ts +++ b/apps/web/src/lib/isFeatureEnabled.ts @@ -9,7 +9,7 @@ import { hydrateFeatureFlags } from 'src/store/persisted/useFeatureFlagsStore'; * @returns Whether the feature is enabled */ const isFeatureEnabled = (key: KillSwitch | string) => { - if (IS_PREVIEW && !IS_PRODUCTION) { + if (!IS_PRODUCTION || IS_PREVIEW) { return true; } From 98f64343a654c648d1173cca712caf44146edebb Mon Sep 17 00:00:00 2001 From: bigint <69431456+bigint@users.noreply.github.com> Date: Mon, 5 Feb 2024 12:25:57 +0530 Subject: [PATCH 4/5] fix: preview check for constants.ts --- packages/data/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/data/constants.ts b/packages/data/constants.ts index a3130fda42f..34df54b0080 100644 --- a/packages/data/constants.ts +++ b/packages/data/constants.ts @@ -12,7 +12,7 @@ export const LENS_NETWORK = process.env.NEXT_PUBLIC_LENS_NETWORK || 'mainnet'; export const LENS_API_URL = getEnvConfig().lensApiEndpoint; export const HEY_API_URL = IS_PRODUCTION ? getEnvConfig().heyApiEndpoint - : 'http://localhost:4784'; + : 'http://192.168.0.104:4784'; export const LENSHUB_PROXY = getEnvConfig().lensHubProxyAddress; export const TOKEN_HANDLE_REGISTRY = getEnvConfig().tokenHandleRegistry; export const PUBLICACT_PROXY = getEnvConfig().publicActProxyAddress; From 9b30c68682f3b78b8bbdf0489614eb0de0c98cd7 Mon Sep 17 00:00:00 2001 From: bigint <69431456+bigint@users.noreply.github.com> Date: Mon, 5 Feb 2024 12:28:25 +0530 Subject: [PATCH 5/5] fix: api url --- packages/data/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/data/constants.ts b/packages/data/constants.ts index 34df54b0080..a3130fda42f 100644 --- a/packages/data/constants.ts +++ b/packages/data/constants.ts @@ -12,7 +12,7 @@ export const LENS_NETWORK = process.env.NEXT_PUBLIC_LENS_NETWORK || 'mainnet'; export const LENS_API_URL = getEnvConfig().lensApiEndpoint; export const HEY_API_URL = IS_PRODUCTION ? getEnvConfig().heyApiEndpoint - : 'http://192.168.0.104:4784'; + : 'http://localhost:4784'; export const LENSHUB_PROXY = getEnvConfig().lensHubProxyAddress; export const TOKEN_HANDLE_REGISTRY = getEnvConfig().tokenHandleRegistry; export const PUBLICACT_PROXY = getEnvConfig().publicActProxyAddress;