Skip to content

Commit

Permalink
chore(root): Clean up self hosted env vars (#6570)
Browse files Browse the repository at this point in the history
  • Loading branch information
SokratisVidros authored Sep 26, 2024
1 parent 76b73f2 commit 3a9828a
Show file tree
Hide file tree
Showing 43 changed files with 77 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ describe('Resource Limiting', () => {
authHeader?: string
) => Promise<Awaited<ReturnType<typeof UserSession.prototype.testAgent.get>>>;

describe('IS_DOCKER_HOSTED is true', () => {
describe('IS_SELF_HOSTED is true', () => {
beforeEach(async () => {
process.env.IS_DOCKER_HOSTED = 'true';
process.env.IS_SELF_HOSTED = 'true';
session = new UserSession();
await session.initialize();

Expand All @@ -31,9 +31,9 @@ describe('Resource Limiting', () => {
});
});

describe('IS_DOCKER_HOSTED is false', () => {
describe('IS_SELF_HOSTED is false', () => {
beforeEach(async () => {
process.env.IS_DOCKER_HOSTED = 'false';
process.env.IS_SELF_HOSTED = 'false';
session = new UserSession();
await session.initialize();

Expand Down
2 changes: 1 addition & 1 deletion apps/web/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ REACT_APP_WS_URL=http://localhost:3002
REACT_APP_WEBHOOK_URL=http://localhost:3003
REACT_APP_NOVU_APP_ID=
REACT_APP_WIDGET_EMBED_PATH=
REACT_APP_DOCKER_HOSTED_ENV=
REACT_APP_IS_SELF_HOSTED=
REACT_APP_INTERCOM_APP_ID=
REACT_APP_SEGMENT_KEY=
REACT_APP_SENTRY_DSN=
Expand Down
2 changes: 1 addition & 1 deletion apps/web/.example.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ REACT_APP_WS_URL=
REACT_APP_WEBHOOK_URL=
REACT_APP_NOVU_APP_ID=
REACT_APP_WIDGET_EMBED_PATH=
REACT_APP_DOCKER_HOSTED_ENV=
REACT_APP_IS_SELF_HOSTED=
REACT_APP_INTERCOM_APP_ID=
REACT_APP_SEGMENT_KEY=
REACT_APP_SENTRY_DSN=
Expand Down
1 change: 0 additions & 1 deletion apps/web/public/env-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ window._env_ = Object.assign(
REACT_APP_ENVIRONMENT: 'dev',
REACT_APP_VERSION: '$npm_package_version',
IS_V2_ENABLED: 'true',
IS_V2_EXPERIENCE_ENABLED: 'true',
},
// Allow overrides of the above defaults
window._env_
Expand Down
2 changes: 1 addition & 1 deletion apps/web/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
</svg>
</div>
<div id="root"></div>
<% if ( process.env.REACT_APP_DOCKER_HOSTED_ENV === 'false' ) { %>
<% if ( process.env.REACT_APP_IS_SELF_HOSTED === 'false' ) { %>
<script
src="https://uptime.betterstack.com/widgets/announcement.js"
data-id="144175"
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/api/hooks/useGetLocalesFromContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { errorMessage } from '@novu/design-system';
import type { IResponseError, IEmailBlock } from '@novu/shared';
import { useMutation } from '@tanstack/react-query';
import { useCallback } from 'react';
import { IS_DOCKER_HOSTED } from '../../config';
import { IS_SELF_HOSTED } from '../../config';

import { getLocalesFromContent } from '../translations';

Expand Down Expand Up @@ -35,7 +35,7 @@ export const useGetLocalesFromContent = () => {

const getLocalesFromContentCallback = useCallback(
async ({ content }: Payload) => {
if (IS_DOCKER_HOSTED) {
if (IS_SELF_HOSTED) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/api/hooks/useWebhookSupportStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useQuery } from '@tanstack/react-query';
import { ChannelTypeEnum } from '@novu/shared';

import { getWebhookSupportStatus } from '../integration';
import { IS_DOCKER_HOSTED, WEBHOOK_URL } from '../../config';
import { IS_SELF_HOSTED, WEBHOOK_URL } from '../../config';
import { useEnvironment } from '../../hooks';
import { useAuth } from '../../hooks/useAuth';

Expand Down Expand Up @@ -31,7 +31,7 @@ export const useWebhookSupportStatus = ({
);

const isWebhookEnabled = !!(
!IS_DOCKER_HOSTED &&
!IS_SELF_HOSTED &&
webhookSupportStatus &&
channel &&
[ChannelTypeEnum.EMAIL, ChannelTypeEnum.SMS].includes(channel)
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/components/layout/components/BridgeStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { Popover } from '@novu/design-system';
import { useDisclosure } from '@mantine/hooks';
import { api } from '../../../api/api.client';
import { useEnvironment } from '../../../hooks';
import { IS_DOCKER_HOSTED } from '../../../config';
import { IS_SELF_HOSTED } from '../../../config';

export function BridgeStatus() {
const [opened, { close, open }] = useDisclosure(false);

const { environment } = useEnvironment();
const isBridgeEnabled = !!environment?.echo?.url && !IS_DOCKER_HOSTED;
const isBridgeEnabled = !!environment?.echo?.url && !IS_SELF_HOSTED;
const { data, error, isInitialLoading } = useQuery<{
status: 'ok' | 'down';
version: string;
Expand All @@ -27,7 +27,7 @@ export function BridgeStatus() {
}
);

if (IS_DOCKER_HOSTED) {
if (IS_SELF_HOSTED) {
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/layout/components/FreeTrialBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { FreeTrialBanner as Component } from '../../../ee/billing';
import { IS_DOCKER_HOSTED } from '../../../config';
import { IS_SELF_HOSTED } from '../../../config';

export function FreeTrialBanner() {
if (IS_DOCKER_HOSTED) {
if (IS_SELF_HOSTED) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { FreeTrialSidebarWidget as Component } from '../../../ee/billing';
import { IS_DOCKER_HOSTED, IS_EE_AUTH_ENABLED } from '../../../config';
import { IS_SELF_HOSTED, IS_EE_AUTH_ENABLED } from '../../../config';

export const FreeTrialSidebarWidget = () => {
if (IS_DOCKER_HOSTED) {
if (IS_SELF_HOSTED) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function PolishingBanner() {
key: 'polishingBannerDismissed',
defaultValue: 'false',
});
const selfHosted = process.env.REACT_APP_DOCKER_HOSTED_ENV === 'true';
const selfHosted = process.env.REACT_APP_IS_SELF_HOSTED === 'true';

if (selfHosted || polishingBannerDismissed === 'true') return null;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { FC } from 'react';
import { IS_DOCKER_HOSTED } from '../../../config';
import { IS_SELF_HOSTED } from '../../../config';
import { UpgradePlanBanner as Component } from '../../../ee/billing';

export function UpgradePlanBanner({ FeatureActivatedBanner }: { FeatureActivatedBanner: FC }) {
if (IS_DOCKER_HOSTED) {
if (IS_SELF_HOSTED) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { ActionIcon, Avatar } from '@mantine/core';
import { colors, Dropdown, IconLogout, IconOutlineGroupAdd, IconSettings, Text, When } from '@novu/design-system';
import { Link } from 'react-router-dom';
import { CONTEXT_PATH, IS_DOCKER_HOSTED, REACT_APP_VERSION } from '../../../../config';
import { CONTEXT_PATH, IS_SELF_HOSTED, REACT_APP_VERSION } from '../../../../config';
import { ROUTES } from '../../../../constants/routes';
import { useAuth } from '../../../../hooks/useAuth';
import { useIsDarkTheme } from '../../../../hooks';
import { ProfileMenuItem } from './ProfileMenuItem';

const FALLBACK_AVATAR = `${CONTEXT_PATH}/static/images/avatar.webp`;

const IS_SELF_HOSTED = IS_DOCKER_HOSTED;

const menuItems = [
{
title: 'Settings',
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/components/layout/components/v2/HeaderNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Tooltip } from '@novu/design-system';
import { css } from '@novu/novui/css';
import { HStack } from '@novu/novui/jsx';
import { FeatureFlagsKeysEnum } from '@novu/shared';
import { IS_EE_AUTH_ENABLED, IS_DOCKER_HOSTED } from '../../../../config';
import { IS_EE_AUTH_ENABLED, IS_SELF_HOSTED } from '../../../../config';
import { useBootIntercom, useFeatureFlag } from '../../../../hooks';
import useThemeChange from '../../../../hooks/useThemeChange';
import { discordInviteUrl } from '../../../../pages/quick-start/consts';
Expand All @@ -21,8 +21,8 @@ export function HeaderNav() {
const { currentUser } = useAuth();
const { bridgeURL } = useStudioState();

const isSelfHosted = IS_DOCKER_HOSTED;
const isV2ExperienceEnabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_V2_EXPERIENCE_ENABLED);
const isSelfHosted = IS_SELF_HOSTED;
const isV2ExperienceEnabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_V2_ENABLED);

const shouldShowNewNovuExperience = isV2ExperienceEnabled && bridgeURL;

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/nav/RootNavMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const RootNavMenu: React.FC = () => {
const { updateOnboardingStatus, showOnboarding, isLoading: isLoadingOnboardingStatus } = useUserOnboardingStatus();
const { readonly: isEnvReadonly, environment } = useEnvironment();
const isV2Enabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_V2_ENABLED);
const isV2ExperienceEnabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_V2_EXPERIENCE_ENABLED);
const isV2ExperienceEnabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_V2_ENABLED);
const [isLocalStudioModalOpen, toggleLocalStudioModalOpen] = useToggle();
const { navigateToLocalStudio } = useNavigateToLocalStudio({ fallbackFn: toggleLocalStudioModalOpen });

Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/components/providers/EnvironmentProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IEnvironment } from '@novu/shared';
import { QueryKeys } from '../../api/query.keys';
import { getEnvironments } from '../../api/environment';
import { createContextAndHook } from './createContextAndHook';
import { IS_DOCKER_HOSTED } from '../../config/index';
import { IS_SELF_HOSTED } from '../../config/index';
import { BaseEnvironmentEnum } from '../../constants/BaseEnvironmentEnum';
import { useAuth } from './AuthProvider';
import { ROUTES } from '../../constants/routes';
Expand Down Expand Up @@ -201,9 +201,9 @@ export function useEnvironment({ bridge }: { bridge?: boolean } = {}) {

return {
...rest,
readOnly: readOnly || (!IS_DOCKER_HOSTED && bridge) || false,
readOnly: readOnly || (!IS_SELF_HOSTED && bridge) || false,
// @deprecated use readOnly instead
readonly: readOnly || (!IS_DOCKER_HOSTED && bridge) || false,
bridge: (!IS_DOCKER_HOSTED && bridge) || false,
readonly: readOnly || (!IS_SELF_HOSTED && bridge) || false,
bridge: (!IS_SELF_HOSTED && bridge) || false,
};
}
4 changes: 2 additions & 2 deletions apps/web/src/components/utils/ProductLead.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CSSProperties, ReactNode, useEffect } from 'react';
import styled from '@emotion/styled';

import { Button, colors, Text, Calendar, Close } from '@novu/design-system';
import { IS_DOCKER_HOSTED } from '../../config';
import { IS_SELF_HOSTED } from '../../config';
import { useAuth } from '../../hooks/useAuth';
import { useSegment } from '../providers/SegmentProvider';
import { When } from './When';
Expand Down Expand Up @@ -46,7 +46,7 @@ export const ProductLead = ({
const segment = useSegment();
const theme = useMantineTheme();
const dark = theme.colorScheme === 'dark';
const isSelfHosted = IS_DOCKER_HOSTED;
const isSelfHosted = IS_SELF_HOSTED;

useEffect(() => {
segment.track('Banner seen - [Product lead]', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import styled from '@emotion/styled';
import { SelectItemProps, Group } from '@mantine/core';
import { Select, ISelectProps, Text } from '@novu/design-system';
import { forwardRef } from 'react';
import { IS_DOCKER_HOSTED } from '../../../../config';
import { IS_SELF_HOSTED } from '../../../../config';
import { FlagIcon } from '../../../../ee/translations';

const rightSectionWidth = 20;
Expand All @@ -23,7 +23,7 @@ export function LocaleSelect({
dropdownPosition?: ISelectProps['dropdownPosition'];
}) {
// Do not render locale select if self-hosted or no locale or only one locale
if (IS_DOCKER_HOSTED || locales.length < 2) {
if (IS_SELF_HOSTED || locales.length < 2) {
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export const WIDGET_EMBED_PATH =
process.env.REACT_APP_WIDGET_EMBED_PATH ||
'http://localhost:4701/embed.umd.min.js';

export const IS_DOCKER_HOSTED =
window._env_.REACT_APP_DOCKER_HOSTED_ENV === 'true' || process.env.REACT_APP_DOCKER_HOSTED_ENV === 'true';
export const IS_SELF_HOSTED =
window._env_.REACT_APP_IS_SELF_HOSTED === 'true' || process.env.REACT_APP_IS_SELF_HOSTED === 'true';

export const REACT_APP_VERSION = process.env.NOVU_VERSION;

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/ee/clerk/components/QuestionnaireForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function updateClerkOrgMetadata(data: UpdateExternalOrganizationDto) {

export function QuestionnaireForm() {
const { isSupported } = useWebContainerSupported();
const isV2Enabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_V2_EXPERIENCE_ENABLED);
const isV2Enabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_V2_ENABLED);
const isPlaygroundOnboardingEnabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_PLAYGROUND_ONBOARDING_ENABLED);
const [loading, setLoading] = useState<boolean>();
const {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/hooks/integrations/useIntegrationLimit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { useQuery } from '@tanstack/react-query';
import { ChannelTypeEnum } from '@novu/shared';

import { getIntegrationLimit } from '../../api/integration';
import { IS_DOCKER_HOSTED } from '../../config/index';
import { IS_SELF_HOSTED } from '../../config/index';

const isLimitFetchingEnabled = !IS_DOCKER_HOSTED;
const isLimitFetchingEnabled = !IS_SELF_HOSTED;

export function useIntegrationLimit(type: ChannelTypeEnum) {
const {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/hooks/useOnboardingExperiment.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ChannelTypeEnum, EmailProviderIdEnum } from '@novu/shared';

import { useIntegrations } from './integrations';
import { IS_DOCKER_HOSTED } from '../config';
import { IS_SELF_HOSTED } from '../config';

export function useOnboardingExperiment() {
const { integrations, loading: areIntegrationsLoading } = useIntegrations();
Expand All @@ -12,6 +12,6 @@ export function useOnboardingExperiment() {
);

return {
isOnboardingExperimentEnabled: !areIntegrationsLoading && !emailIntegrationOtherThanNovu && !IS_DOCKER_HOSTED,
isOnboardingExperimentEnabled: !areIntegrationsLoading && !emailIntegrationOtherThanNovu && !IS_SELF_HOSTED,
};
}
4 changes: 2 additions & 2 deletions apps/web/src/pages/BillingPages.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { IS_DOCKER_HOSTED } from '../config';
import { IS_SELF_HOSTED } from '../config';
import { Routes } from '../ee/billing';

export const BillingRoutes = () => {
if (IS_DOCKER_HOSTED) {
if (IS_SELF_HOSTED) {
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/pages/TranslationPages.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { IS_DOCKER_HOSTED } from '../config';
import { IS_SELF_HOSTED } from '../config';
import { Routes } from '../ee/translations';

export const TranslationRoutes = () => {
if (IS_DOCKER_HOSTED) {
if (IS_SELF_HOSTED) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/pages/auth/components/HubspotSignupForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function HubspotSignupForm() {
const { startVercelSetup } = useVercelIntegration();
const { isFromVercel } = useVercelParams();
const { colorScheme } = useMantineColorScheme();
const isV2Enabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_V2_EXPERIENCE_ENABLED);
const isV2Enabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_V2_ENABLED);

const segment = useSegment();

Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/pages/auth/components/OAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { colors, GitHub, Text } from '@novu/design-system';

import { PropsWithChildren } from 'react';
import { When } from '../../../components/utils/When';
import { IS_DOCKER_HOSTED } from '../../../config';
import { IS_SELF_HOSTED } from '../../../config';
import { buildGithubLink, buildVercelGithubLink } from './gitHubUtils';
import { useVercelParams } from '../../../hooks';

Expand All @@ -23,7 +23,7 @@ export function OAuth({
: buildGithubLink({ invitationToken, isLoginPage });

return (
<When truthy={!IS_DOCKER_HOSTED}>
<When truthy={!IS_SELF_HOSTED}>
<>
<Container>
<OAuthButton
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/pages/auth/components/QuestionnaireForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function QuestionnaireForm() {
const queryClient = useQueryClient();
const { initializeWebContainer } = useContainer();
const { isSupported } = useWebContainerSupported();
const isV2Enabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_V2_EXPERIENCE_ENABLED);
const isV2Enabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_V2_ENABLED);
const isPlaygroundOnboardingEnabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_PLAYGROUND_ONBOARDING_ENABLED);

useEffectOnce(() => {
Expand Down
Loading

0 comments on commit 3a9828a

Please sign in to comment.