: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(insights): test notification entry point copy (#73610)
Matt Puae9af018d365b
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 1976ccec197f..d47e7b015242 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -4695,9 +4695,9 @@ snapshots:products-alerts-alerts-scene--log-alerts--light:hash: v1.k794b7964.202760c4cc733d6ef4fee0ad7bee733d15f170e87ef01e64d481a954dcf5a0d3.8Wx10_cUTwP4fwGP183w2k8FTU7NsmgyvkPL_6_Eotgproducts-alerts-insight-alerts-modal--with-alerts--dark:- hash: v1.k794b7964.71d299246cda9686b399251f872ee9603fa87c1bfc312559e99317107a16ab84.kQejra_LLghebT-mluFkAg4ukVJOgdt5yRonzhJGZpM+ hash: v1.k794b7964.58e1c24a162fa9e4fa4c8040adc4a298d0d4275a27aa96f7e4a9e84a2cd5e6b8.9JDfMApDsxe7KaTt42TDrSuqjvHOURRf64Bp3lWHCNcproducts-alerts-insight-alerts-modal--with-alerts--light:- hash: v1.k794b7964.e7d980de50b41878a13cbee137b56c8934d04fa4134cb42508031147061c4f58.oVmlPLncyOyUh6_4Yaz80d5t1350ESLPGFSpBux1iOQ+ hash: v1.k794b7964.683e144ddf1b8e0c71b4e5bc29de9bc0d6217c3f14ab1019b2318076159ba6ef.OBRafURjok_FlQXeZMMvJ-zlmrUdK-zX8eHMsyQNakMproducts-alerts-shared-components--advanced-options--dark:hash: v1.k794b7964.3e55fa3a531d4b4f54ad6ea4679723bbac806e94a02edc0dd38e58b8bedf1285.avRzgZ_I6aR1-LlDLhiKIy4RgMi_UJZjHnXi94wcnwYproducts-alerts-shared-components--advanced-options--light:diff --git a/frontend/src/lib/components/Scenes/InsightSubscribeProminentButton.tsx b/frontend/src/lib/components/Scenes/InsightSubscribeProminentButton.tsxindex 0980e270c6be..66c336af36fb 100644--- a/frontend/src/lib/components/Scenes/InsightSubscribeProminentButton.tsx+++ b/frontend/src/lib/components/Scenes/InsightSubscribeProminentButton.tsx@@ -2,10 +2,21 @@ import { useActions, useValues } from 'kea'import { router } from 'kea-router'import posthog from 'posthog-js'-import { IconBell } from '@posthog/icons'+import { IconBell, IconWarning } from '@posthog/icons'+import { FEATURE_FLAGS } from 'lib/constants'import { IconWithCount } from 'lib/lemon-ui/icons/icons'import { LemonButton } from 'lib/lemon-ui/LemonButton'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuGroup,+ DropdownMenuItem,+ DropdownMenuTrigger,+} from 'lib/ui/DropdownMenu/DropdownMenu'+import { urls } from 'scenes/urls'import { userLogic } from 'scenes/userLogic'import { AvailableFeature, InsightShortId } from '~/types'@@ -15,6 +26,20 @@ import { urlForSubscriptions } from 'products/subscriptions/frontend/components/interface InsightSubscribeProminentButtonProps {insightShortId: InsightShortId+ canCreateAlert: boolean+}++function notificationLabelForVariant(variant: boolean | string | undefined): string | null {+ switch (variant) {+ case 'notifications':+ return 'Notifications'+ case 'get-updates':+ return 'Get updates'+ case 'monitor':+ return 'Monitor'+ default:+ return null+ }}function SubscribeIcon({ insightShortId }: { insightShortId: InsightShortId }): JSX.Element {@@ -34,10 +59,88 @@ function SubscribeIcon({ insightShortId }: { insightShortId: InsightShortId }):)}-/**- * Promotes "Subscribe" from the buried side-panel action to a visible header button.- */-export function InsightSubscribeProminentButton({ insightShortId }: InsightSubscribeProminentButtonProps): JSX.Element {+export function InsightSubscribeProminentButton({+ insightShortId,+ canCreateAlert,+}: InsightSubscribeProminentButtonProps): JSX.Element {+ if (!canCreateAlert) {+ return <SubscribeButton insightShortId={insightShortId} />+ }++ return <ExperimentButton insightShortId={insightShortId} />+}++function ExperimentButton({ insightShortId }: { insightShortId: InsightShortId }): JSX.Element {+ const { push } = useActions(router)+ const { featureFlags } = useValues(featureFlagLogic)+ const notificationEntrypointVariant = featureFlags[FEATURE_FLAGS.INSIGHT_NOTIFICATION_ENTRYPOINT]+ const notificationLabel = notificationLabelForVariant(notificationEntrypointVariant)++ if (notificationLabel) {+ return (+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <LemonButton+ type="secondary"+ size="small"+ icon={<IconBell />}+ data-attr="insight-notify-prominent-button"+ >+ {notificationLabel}+ </LemonButton>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end">+ <DropdownMenuGroup>+ <DropdownMenuItem asChild>+ <ButtonPrimitive+ menuItem+ onClick={() => {+ posthog.capture('insight notify prominent button clicked', {+ insight_short_id: insightShortId,+ option: 'alerts',+ header_copy: notificationLabel,+ })+ push(urls.insightAlerts(insightShortId))+ }}+ >+ <IconWarning />+ <span className="flex flex-col">+ <span>Alerts</span>+ <span className="text-secondary text-xs">+ Notify me when the insight meets a condition+ </span>+ </span>+ </ButtonPrimitive>+ </DropdownMenuItem>+ <DropdownMenuItem asChild>+ <ButtonPrimitive+ menuItem+ onClick={() => {+ posthog.capture('insight notify prominent button clicked', {+ insight_short_id: insightShortId,+ option: 'subscriptions',+ header_copy: notificationLabel,+ })+ push(urlForSubscriptions({ insightShortId }))+ }}+ >+ <IconBell />+ <span className="flex flex-col">+ <span>Subscriptions</span>+ <span className="text-secondary text-xs">Send me a recurring report</span>+ </span>+ </ButtonPrimitive>+ </DropdownMenuItem>+ </DropdownMenuGroup>+ </DropdownMenuContent>+ </DropdownMenu>+ )+ }++ return <SubscribeButton insightShortId={insightShortId} />+}++function SubscribeButton({ insightShortId }: { insightShortId: InsightShortId }): JSX.Element {const { push } = useActions(router)return (diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex 2fec33c85a0f..66c0864f8851 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -176,6 +176,7 @@ export const FEATURE_FLAGS = {// UX flags, used to control the UX of the appCMD_K_NAV_EXPERIMENT: 'cmd-k-nav-experiment', // owner: @rafaeelaudibert #team-platform-ux multivariate=control,search-bar,footer-hint,tools-row,footer-callout - surfaces the Cmd+K command menu more prominently in the left nav: search-bar = full-width search field below the nav header, footer-hint = extra Search row in the nav footer, tools-row = Search row after the Tools item in the Project section, footer-callout = dismissible callout card in the nav ad slot for users a few days after signupCREATE_BUTTON_NAV_EXPERIMENT: 'create-button-nav-experiment', // owner: #team-platform-ux multivariate=control,test — adds a Create dropdown to the top of the Browse tab in the left nav+ INSIGHT_NOTIFICATION_ENTRYPOINT: 'insight-notification-entrypoint', // owner: #team-product-analytics multivariate=control,notifications,get-updates,monitor — tests notification-entry-point copy against the prominent Subscribe buttonNEW_INSIGHT_MENU_EXPERIMENT: 'new-insight-menu-experiment', // owner: @thmsobrmlr #team-product-analytics multivariate=control,chips,grouped — experiment on the saved insights "New" menu: control = text list, chips = visual card grid with sub-insight chips, grouped = two-column card grid grouped by questionSTARRED_REORDER: 'starred-reorder', // owner: #team-platform-ux, drag-and-drop reorder of starred shortcuts in the side panelUX_HIDE_PROJECT_NOTICE: 'ux-hide-project-notice', // owner: #team-platform-ux, hides the project notice banner across all scenesdiff --git a/frontend/src/scenes/insights/InsightPageHeader.tsx b/frontend/src/scenes/insights/InsightPageHeader.tsxindex 2117dc30d922..927dd7b8ab10 100644--- a/frontend/src/scenes/insights/InsightPageHeader.tsx+++ b/frontend/src/scenes/insights/InsightPageHeader.tsx@@ -180,7 +180,10 @@ export function InsightPageHeader({ insightLogicProps }: { insightLogicProps: In)}{insightMode !== ItemMode.Edit && isPersistedInsight && (- <InsightSubscribeProminentButton insightShortId={insight.short_id!} />+ <InsightSubscribeProminentButton+ insightShortId={insight.short_id!}+ canCreateAlert={canCreateAlertForInsight}+ />)}{insightMode !== ItemMode.Edit ? (diff --git a/frontend/src/scenes/insights/insightSceneLogic.tsx b/frontend/src/scenes/insights/insightSceneLogic.tsxindex f29da0d39151..41567a89c9d9 100644--- a/frontend/src/scenes/insights/insightSceneLogic.tsx+++ b/frontend/src/scenes/insights/insightSceneLogic.tsx@@ -13,6 +13,7 @@ import {import type { BreakPointFunction } from 'kea'import { urlToAction } from 'kea-router'import { objectsEqual } from 'kea-test-utils'+import posthog from 'posthog-js'import api from 'lib/api'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'@@ -698,7 +699,10 @@ export const insightSceneLogic = kea<insightSceneLogicType>([setInsightMode: sharedListeners.reloadInsightLogic,setSceneState: [sharedListeners.reloadInsightLogic,- ({ sceneSource }) => {+ ({ insightId, insightMode, alertId, sceneSource }) => {+ if (insightMode === ItemMode.Alerts && !alertId) {+ posthog.capture('insight alert modal opened', { insight_short_id: insightId })+ }// Only open here when the scene panel already exists; otherwise Info isn't in// `enabledTabs` yet and SidePanel's fallback reroutes to Max. The fresh-navigation// case is handled by the `setScenePanelIsPresent` listener below.diff --git a/products/alerts/frontend/views/ManageAlertsModal.tsx b/products/alerts/frontend/views/ManageAlertsModal.tsxindex a73bfe417df6..2abd0ee92142 100644--- a/products/alerts/frontend/views/ManageAlertsModal.tsx+++ b/products/alerts/frontend/views/ManageAlertsModal.tsx@@ -146,8 +146,8 @@ export function ManageAlertsModal(props: ManageAlertsModalProps): JSX.Element {</LemonModal.Header><LemonModal.Content><div className="mb-4">- With alerts, PostHog will monitor your insight and notify you when certain conditions are met. We do- not evaluate alerts in real-time, but rather on a schedule (hourly, daily...).+ With alerts, PostHog monitors your insight at a recurring interval and notifies you when conditions+ are met.<br /><Link to={urls.alerts()} target="_blank">View all your alerts here