Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(feature-flags): show notifications tab even without audit logs (#57828)

Gustavo H. Strassburger1f24191fc69b
diff --git a/frontend/src/layout/FeaturePreviews/FeaturePreviews.tsx b/frontend/src/layout/FeaturePreviews/FeaturePreviews.tsx
index b8859ba839e4..8337ad0078d8 100644
--- a/frontend/src/layout/FeaturePreviews/FeaturePreviews.tsx
+++ b/frontend/src/layout/FeaturePreviews/FeaturePreviews.tsx
@@ -5,18 +5,43 @@ import { IconBell, IconCheck } from '@posthog/icons'
import { LemonBanner, LemonButton, LemonInput, LemonSwitch, LemonTextArea, Link } from '@posthog/lemon-ui'
import { BasicCard } from 'lib/components/Cards/BasicCard'
+import { FEATURE_FLAGS } from 'lib/constants'
import { IconLink } from 'lib/lemon-ui/icons'
import { SpinnerOverlay } from 'lib/lemon-ui/Spinner'
import { Label } from 'lib/ui/Label/Label'
+import { userLogic } from 'scenes/userLogic'
+
+import { AvailableFeature } from '~/types'
import { EnrichedEarlyAccessFeature, featurePreviewsLogic } from './featurePreviewsLogic'
+type AvailableFeatureChecker = (feature: AvailableFeature) => boolean
+
+interface FeaturePreviewWarning {
+ /** Returns the warning to display for a feature, or null if none should show. */
+ resolve: (hasAvailableFeature: AvailableFeatureChecker) => React.ReactNode | null
+}
+
+/**
+ * Per-flag warnings shown on the early-access card. Add an entry here to surface a warning
+ * for a specific preview without touching the FeaturePreview component itself.
+ */
+const FEATURE_PREVIEW_WARNINGS: Record<string, FeaturePreviewWarning> = {
+ [FEATURE_FLAGS.FEATURE_FLAG_NOTIFICATIONS]: {
+ resolve: (hasAvailableFeature) =>
+ hasAvailableFeature(AvailableFeature.AUDIT_LOGS)
+ ? null
+ : 'This feature requires the Enterprise plan or the Scale add-on. Enabling the preview will not unlock it on your current plan.',
+ },
+}
+
const hasPosthogJsFailedToLoadFeaturePreviews = (): boolean => !!window.POSTHOG_GLOBAL_ERRORS?.onFeatureFlagsLoadError
// Feature previews can be linked to by using hash in the url
// example external link: https://app.posthog.com/settings/user-feature-previews#llm-analytics
export function FeaturePreviews(): JSX.Element {
const { filteredEarlyAccessFeatures, rawEarlyAccessFeaturesLoading, searchTerm } = useValues(featurePreviewsLogic)
+ const { hasAvailableFeature } = useValues(userLogic)
const { loadEarlyAccessFeatures, setSearchTerm } = useActions(featurePreviewsLogic)
useLayoutEffect(() => loadEarlyAccessFeatures(), [loadEarlyAccessFeatures])
@@ -64,7 +89,10 @@ export function FeaturePreviews(): JSX.Element {
) : (
betaFeatures.map((feature) => (
<div key={feature.flagKey}>
- <FeaturePreview feature={feature} />
+ <FeaturePreview
+ feature={feature}
+ warning={FEATURE_PREVIEW_WARNINGS[feature.flagKey]?.resolve(hasAvailableFeature)}
+ />
</div>
))
)}
@@ -167,7 +195,13 @@ function ConceptPreview({ feature }: { feature: EnrichedEarlyAccessFeature }): J
)
}
-function FeaturePreview({ feature }: { feature: EnrichedEarlyAccessFeature }): JSX.Element {
+interface FeaturePreviewProps {
+ feature: EnrichedEarlyAccessFeature
+ /** Optional warning rendered under the description (e.g. plan/add-on requirements). */
+ warning?: React.ReactNode
+}
+
+function FeaturePreview({ feature, warning }: FeaturePreviewProps): JSX.Element {
const { activeFeedbackFlagKey, activeFeedbackFlagKeyLoading } = useValues(featurePreviewsLogic)
const {
beginEarlyAccessFeatureFeedback,
@@ -205,9 +239,10 @@ function FeaturePreview({ feature }: { feature: EnrichedEarlyAccessFeature }): J
</div>
}
description={
- <p className="m-0 max-w-prose">
- {description || <span className="text-tertiary">No description</span>}
- </p>
+ <div className="flex flex-col gap-2 max-w-prose">
+ <p className="m-0">{description || <span className="text-tertiary">No description</span>}</p>
+ {warning && <LemonBanner type="warning">{warning}</LemonBanner>}
+ </div>
}
actions={
<div className="flex flex-col gap-2">
diff --git a/frontend/src/scenes/feature-flags/FeatureFlags.tsx b/frontend/src/scenes/feature-flags/FeatureFlags.tsx
index f71e3cb1f7f3..8e2ab6515865 100644
--- a/frontend/src/scenes/feature-flags/FeatureFlags.tsx
+++ b/frontend/src/scenes/feature-flags/FeatureFlags.tsx
@@ -49,7 +49,6 @@ import {
AccessControlResourceType,
ActivityScope,
AnyPropertyFilter,
- AvailableFeature,
BaseMathType,
FeatureFlagEvaluationRuntime,
FeatureFlagFilters,
@@ -642,12 +641,9 @@ export function FeatureFlags(): JSX.Element {
const { activeTab } = useValues(featureFlagsLogic)
const { setActiveTab } = useActions(featureFlagsLogic)
const { featureFlags: enabledFeatureFlags } = useValues(enabledFeaturesLogic)
- const { hasAvailableFeature } = useValues(userLogic)
const featureFlagsV2Enabled = !!enabledFeatureFlags[FEATURE_FLAGS.FEATURE_FLAGS_V2]
const newFeatureFlagUrl = featureFlagsV2Enabled ? urls.featureFlagTemplates() : urls.featureFlag('new')
- const showNotificationsTab =
- !!enabledFeatureFlags[FEATURE_FLAGS.FEATURE_FLAG_NOTIFICATIONS] &&
- hasAvailableFeature(AvailableFeature.AUDIT_LOGS)
+ const showNotificationsTab = !!enabledFeatureFlags[FEATURE_FLAGS.FEATURE_FLAG_NOTIFICATIONS]
const showProjectsTab = !!enabledFeatureFlags[FEATURE_FLAGS.FEATURE_FLAGS_ACROSS_PROJECTS_INDEX]
return (