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(alerts): add label copy experiment to insight alerts button (#62474)

Matt Pua42fc1db38ec8
diff --git a/frontend/src/lib/components/Scenes/SceneAlertsButton.tsx b/frontend/src/lib/components/Scenes/SceneAlertsButton.tsx
index 1f3ee4e27523..8ae5abe3cd97 100644
--- a/frontend/src/lib/components/Scenes/SceneAlertsButton.tsx
+++ b/frontend/src/lib/components/Scenes/SceneAlertsButton.tsx
@@ -1,8 +1,11 @@
import { useActions, useValues } from 'kea'
import { router } from 'kea-router'
+import posthog from 'posthog-js'
import { IconWarning } from '@posthog/icons'
+import { useFeatureFlagVariantKey } from '@posthog/react'
+import { FEATURE_FLAGS } from 'lib/constants'
import { IconWithCount } from 'lib/lemon-ui/icons/icons'
import { ButtonPrimitive, DisabledReasonsObject } from 'lib/ui/Button/ButtonPrimitives'
import { urls } from 'scenes/urls'
@@ -12,6 +15,13 @@ import { InsightLogicProps, InsightShortId } from '~/types'
import { insightAlertsLogic } from '../Alerts/insightAlertsLogic'
import { SceneDataAttrKeyProps } from './utils'
+const ALERTS_LABEL_BY_VARIANT: Record<string, string> = {
+ control: 'Alerts',
+ 'get-notified': 'Get notified',
+ 'monitor-changes': 'Monitor changes',
+ 'set-up-alert': 'Set up alert',
+}
+
interface SceneAlertsButtonProps extends SceneDataAttrKeyProps {
insightId: number
insightShortId: InsightShortId
@@ -31,17 +41,28 @@ export function SceneAlertsButton({
const logic = insightAlertsLogic({ insightId, insightLogicProps })
const { alerts } = useValues(logic)
+ const labelVariant = useFeatureFlagVariantKey(FEATURE_FLAGS.SCENE_ALERTS_LABEL_EXPERIMENT)
+ const resolvedVariant = typeof labelVariant === 'string' ? labelVariant : 'control'
+ const alertsLabel = ALERTS_LABEL_BY_VARIANT[resolvedVariant] ?? 'Alerts'
+
return (
<ButtonPrimitive
menuItem
- onClick={() => push(urls.insightAlerts(insightShortId))}
+ onClick={() => {
+ posthog.capture('scene alerts menu item clicked', {
+ resource_type: dataAttrKey,
+ label_variant: resolvedVariant,
+ label_text: alertsLabel,
+ })
+ push(urls.insightAlerts(insightShortId))
+ }}
data-attr={`${dataAttrKey}-alerts-dropdown-menu-item`}
disabledReasons={disabledReasons}
>
<IconWithCount count={alerts?.length} showZero={false}>
<IconWarning />
</IconWithCount>
- Alerts
+ {alertsLabel}
</ButtonPrimitive>
)
}
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index b97256cc5979..0f5f06c83ed7 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -460,6 +460,7 @@ export const FEATURE_FLAGS = {
REPLAY_VISION: 'replay-vision', // owner: #team-replay
REVENUE_ANALYTICS: 'revenue-analytics', // owner: @rafaeelaudibert #team-customer-analytics
REVENUE_FIELDS_IN_POWER_USERS_TABLE: 'revenue-fields-in-power-users-table', // owner: @arthurdedeus #team-customer-analytics
+ SCENE_ALERTS_LABEL_EXPERIMENT: 'scene-alerts-label-experiment', // owner: @mattp #team-analytics-platform multivariate=control,get-notified,monitor-changes,set-up-alert
SCENE_MENU_BAR: 'scene-menu-bar', // owner: @adamleithp #team-platform-ux, gates the per-scene MenuBar above SceneTitleSection
SCENE_SUBSCRIBE_LABEL_EXPERIMENT: 'scene-subscribe-label-experiment', // owner: @mattp #team-analytics-platform multivariate=control,recurring-updates,scheduled-notifications,scheduled-reports
SCHEDULE_FEATURE_FLAG_VARIANTS_UPDATE: 'schedule-feature-flag-variants-update', // owner: @gustavo #team-feature-flags