diff --git a/apps/app/app/(authenticated)/layout.tsx b/apps/app/app/(authenticated)/layout.tsx index f6f6f047e..fe8de19bb 100644 --- a/apps/app/app/(authenticated)/layout.tsx +++ b/apps/app/app/(authenticated)/layout.tsx @@ -1,8 +1,8 @@ import { env } from '@/env'; import { auth, currentUser } from '@repo/auth/server'; import { SidebarProvider } from '@repo/design-system/components/ui/sidebar'; -import { NotificationsProvider } from '@repo/design-system/providers/notifications'; import { showBetaFeature } from '@repo/feature-flags'; +import { NotificationsProvider } from '@repo/notifications/components/provider'; import { secure } from '@repo/security'; import type { ReactNode } from 'react'; import { PostHogIdentifier } from './components/posthog-identifier'; diff --git a/apps/app/package.json b/apps/app/package.json index 892abd027..859d993ef 100644 --- a/apps/app/package.json +++ b/apps/app/package.json @@ -19,6 +19,7 @@ "@repo/design-system": "workspace:*", "@repo/feature-flags": "workspace:*", "@repo/next-config": "workspace:*", + "@repo/notifications": "workspace:*", "@repo/observability": "workspace:*", "@repo/security": "workspace:*", "@repo/seo": "workspace:*", diff --git a/packages/design-system/providers/notifications.tsx b/packages/design-system/providers/notifications.tsx deleted file mode 100644 index 46bdfadda..000000000 --- a/packages/design-system/providers/notifications.tsx +++ /dev/null @@ -1,26 +0,0 @@ -'use client'; - -import { KnockFeedProvider, KnockProvider } from '@knocklabs/react'; -import type { ReactNode } from 'react'; - -const knockApiKey = process.env.NEXT_PUBLIC_KNOCK_API_KEY; -const knockFeedChannelId = process.env.NEXT_PUBLIC_KNOCK_FEED_CHANNEL_ID; - -if (!knockApiKey) { - throw new Error('NEXT_PUBLIC_KNOCK_API_KEY is not set'); -} - -if (!knockFeedChannelId) { - throw new Error('NEXT_PUBLIC_KNOCK_FEED_CHANNEL_ID is not set'); -} - -export const NotificationsProvider = ({ - children, - userId, -}: { children: ReactNode; userId: string }) => ( - - - {children} - - -); diff --git a/packages/notifications/components/provider.tsx b/packages/notifications/components/provider.tsx new file mode 100644 index 000000000..031e11ee8 --- /dev/null +++ b/packages/notifications/components/provider.tsx @@ -0,0 +1,30 @@ +'use client'; + +import { KnockFeedProvider, KnockProvider } from '@knocklabs/react'; +import type { ReactNode } from 'react'; +import { keys } from '../keys'; + +const knockApiKey = keys().KNOCK_SECRET_API_KEY; +const knockFeedChannelId = keys().KNOCK_FEED_CHANNEL_ID; + +type NotificationsProviderProps = { + children: ReactNode; + userId: string; +}; + +export const NotificationsProvider = ({ + children, + userId, +}: NotificationsProviderProps) => { + if (!knockApiKey || !knockFeedChannelId) { + return children; + } + + return ( + + + {children} + + + ); +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9efa14072..88ad6f198 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -127,6 +127,9 @@ importers: '@repo/next-config': specifier: workspace:* version: link:../../packages/next-config + '@repo/notifications': + specifier: workspace:* + version: link:../../packages/notifications '@repo/observability': specifier: workspace:* version: link:../../packages/observability