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.

refactor(alerts): move insight-alerts frontend into products/alerts (#69812)

Matt Pua3b6a3f5798ac
diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts
index 41c086f01a26..66a1a4532a7a 100644
--- a/frontend/src/lib/api.ts
+++ b/frontend/src/lib/api.ts
@@ -228,6 +228,7 @@ import {
WebhookInfo,
} from '~/types'
+import { AlertConfig, AlertSimulationResult, AlertType, AlertTypeWrite } from 'products/alerts/frontend/types'
import type { CustomerJourneyApi } from 'products/customer_analytics/frontend/generated/api.schemas'
import type {
ErrorTrackingRule,
@@ -269,7 +270,6 @@ import type {
import { AgentMode } from '../queries/schema'
import type { AttachedContext, MaxUIContext } from '../scenes/max/maxTypes'
-import { AlertConfig, AlertSimulationResult, AlertType, AlertTypeWrite } from './components/Alerts/types'
import {
ErrorTrackingFingerprint,
ErrorTrackingRelease,
diff --git a/frontend/src/lib/components/ActivityLog/describers.tsx b/frontend/src/lib/components/ActivityLog/describers.tsx
index f612efb879a8..bbdc6fad51b2 100644
--- a/frontend/src/lib/components/ActivityLog/describers.tsx
+++ b/frontend/src/lib/components/ActivityLog/describers.tsx
@@ -4,7 +4,6 @@ import { instanceSettingActivityDescriber } from 'lib/components/ActivityLog/act
import { tagActivityDescriber } from 'lib/components/ActivityLog/activityDescriptions/tagActivityDescriber'
import { ActivityLogItem, Describer, defaultDescriber } from 'lib/components/ActivityLog/humanizeActivity'
import { actionActivityDescriber } from 'scenes/actions/actionActivityDescriber'
-import { alertConfigurationActivityDescriber } from 'scenes/alerts/activityDescriptions'
import { annotationActivityDescriber } from 'scenes/annotations/activityDescriptions'
import { userActivityDescriber } from 'scenes/authentication/shared/activityDescriptions'
import { cohortActivityDescriber } from 'scenes/cohorts/activityDescriptions'
@@ -38,6 +37,7 @@ import { teamActivityDescriber } from 'scenes/team-activity/teamActivityDescribe
import { ActivityScope } from '~/types'
+import { alertConfigurationActivityDescriber } from 'products/alerts/frontend/components/activityDescriptions'
import { ticketActivityDescriber } from 'products/conversations/frontend/activityDescriber'
import { externalDataSourceActivityDescriber } from 'products/data_warehouse/frontend/shared/components/activityDescriptions'
import { endpointActivityDescriber } from 'products/endpoints/frontend/activityDescriber'
diff --git a/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsx b/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsx
index e6bfcbd957ef..76765ed28fe7 100644
--- a/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsx
+++ b/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsx
@@ -5,8 +5,6 @@ import React, { useCallback, useEffect, useRef, useState } from 'react'
import { IconInfo, IconThumbsDown, IconThumbsUp } from '@posthog/icons'
import { lemonToast } from '@posthog/lemon-ui'
-import { areAlertsSupportedForInsight, insightAlertsLogic } from 'lib/components/Alerts/insightAlertsLogic'
-import { ManageAlertsModal } from 'lib/components/Alerts/views/ManageAlertsModal'
import { CardMeta } from 'lib/components/Cards/CardMeta'
import { CardMetaRefreshButton } from 'lib/components/Cards/CardMetaRefreshButton'
import { DashboardTileRefreshDataButton } from 'lib/components/Cards/InsightCard/DashboardTileRefreshDataButton'
@@ -56,6 +54,9 @@ import {
QueryBasedInsightModel,
} from '~/types'
+import { areAlertsSupportedForInsight, insightAlertsLogic } from 'products/alerts/frontend/logic/insightAlertsLogic'
+import { ManageAlertsModal } from 'products/alerts/frontend/views/ManageAlertsModal'
+
import { DashboardInsightDisplayOptions } from './DashboardInsightDisplayOptions'
import { dashboardWidgetMenusLogic } from './dashboardWidgetMenusLogic'
import { DashboardWidgetPlacementMenus } from './DashboardWidgetPlacementMenus'
diff --git a/frontend/src/lib/components/Scenes/SceneAlertsButton.tsx b/frontend/src/lib/components/Scenes/SceneAlertsButton.tsx
index 1f3ee4e27523..0f28d941b094 100644
--- a/frontend/src/lib/components/Scenes/SceneAlertsButton.tsx
+++ b/frontend/src/lib/components/Scenes/SceneAlertsButton.tsx
@@ -9,7 +9,8 @@ import { urls } from 'scenes/urls'
import { InsightLogicProps, InsightShortId } from '~/types'
-import { insightAlertsLogic } from '../Alerts/insightAlertsLogic'
+import { insightAlertsLogic } from 'products/alerts/frontend/logic/insightAlertsLogic'
+
import { SceneDataAttrKeyProps } from './utils'
interface SceneAlertsButtonProps extends SceneDataAttrKeyProps {
diff --git a/frontend/src/lib/components/TerraformExporter/alertHclExporter.test.ts b/frontend/src/lib/components/TerraformExporter/alertHclExporter.test.ts
index e186151d89ba..9dc4624dfb4f 100644
--- a/frontend/src/lib/components/TerraformExporter/alertHclExporter.test.ts
+++ b/frontend/src/lib/components/TerraformExporter/alertHclExporter.test.ts
@@ -1,6 +1,6 @@
import { generateAlertHCL } from 'lib/components/TerraformExporter/alertHclExporter'
-import { AlertType } from '~/lib/components/Alerts/types'
+import { AlertType } from 'products/alerts/frontend/types'
const createTestAlert = (props: Record<string, unknown>): Partial<AlertType> => props as Partial<AlertType>
diff --git a/frontend/src/lib/components/TerraformExporter/alertHclExporter.ts b/frontend/src/lib/components/TerraformExporter/alertHclExporter.ts
index 118ec1b12827..346713d1ced3 100644
--- a/frontend/src/lib/components/TerraformExporter/alertHclExporter.ts
+++ b/frontend/src/lib/components/TerraformExporter/alertHclExporter.ts
@@ -1,8 +1,9 @@
import { formatHclValue, sanitizeResourceName } from 'lib/components/TerraformExporter/hclExporterFormattingUtils'
-import { AlertType, isTrendsAlertConfig } from '~/lib/components/Alerts/types'
import { HogFunctionType } from '~/types'
+import { AlertType, isTrendsAlertConfig } from 'products/alerts/frontend/types'
+
import { FieldMapping, HclExportOptions, HclExportResult, ResourceExporter, generateHCL } from './hclExporter'
import { generateHogFunctionHCL } from './hogFunctionHclExporter'
diff --git a/frontend/src/lib/components/TerraformExporter/dashboardHclExporter.ts b/frontend/src/lib/components/TerraformExporter/dashboardHclExporter.ts
index f7058e2d0e87..49a6d19e7b4c 100644
--- a/frontend/src/lib/components/TerraformExporter/dashboardHclExporter.ts
+++ b/frontend/src/lib/components/TerraformExporter/dashboardHclExporter.ts
@@ -4,9 +4,10 @@ import {
sanitizeResourceName,
} from 'lib/components/TerraformExporter/hclExporterFormattingUtils'
-import { AlertType } from '~/lib/components/Alerts/types'
import { DashboardBasicType, DashboardType, HogFunctionType, InsightModel } from '~/types'
+import { AlertType } from 'products/alerts/frontend/types'
+
import { generateDashboardLayoutHCL } from './dashboardLayoutHclExporter'
import { FieldMapping, HclExportOptions, HclExportResult, ResourceExporter, generateHCL } from './hclExporter'
import { generateInsightHCL, INSIGHT_EXPORTER } from './insightHclExporter'
diff --git a/frontend/src/lib/components/TerraformExporter/insightHclExporter.ts b/frontend/src/lib/components/TerraformExporter/insightHclExporter.ts
index 5a5cde25fcf0..c78fbb65a277 100644
--- a/frontend/src/lib/components/TerraformExporter/insightHclExporter.ts
+++ b/frontend/src/lib/components/TerraformExporter/insightHclExporter.ts
@@ -6,9 +6,10 @@ import {
sanitizeResourceName,
} from 'lib/components/TerraformExporter/hclExporterFormattingUtils'
-import { AlertType } from '~/lib/components/Alerts/types'
import { HogFunctionType, InsightModel } from '~/types'
+import { AlertType } from 'products/alerts/frontend/types'
+
import { generateAlertHCL } from './alertHclExporter'
import { FieldMapping, HclExportOptions, HclExportResult, ResourceExporter, generateHCL } from './hclExporter'
diff --git a/frontend/src/lib/components/TerraformExporter/useTerraformExport.ts b/frontend/src/lib/components/TerraformExporter/useTerraformExport.ts
index f18a8190cbeb..2ff8c80322bd 100644
--- a/frontend/src/lib/components/TerraformExporter/useTerraformExport.ts
+++ b/frontend/src/lib/components/TerraformExporter/useTerraformExport.ts
@@ -2,12 +2,13 @@ import { useValues } from 'kea'
import posthog from 'posthog-js'
import { useCallback, useEffect, useRef, useState } from 'react'
-import { buildAlertFilterConfig } from 'lib/utils/alerts'
import { teamLogic } from 'scenes/teamLogic'
-import { AlertType } from '~/lib/components/Alerts/types'
import { DashboardType, HogFunctionType, InsightModel, QueryBasedInsightModel } from '~/types'
+import { buildAlertFilterConfig } from 'products/alerts/frontend/logic/alertNotifications'
+import { AlertType } from 'products/alerts/frontend/types'
+
import api from '../../api'
import { DashboardExportResult, generateDashboardHCL } from './dashboardHclExporter'
import { InsightExportResult, generateInsightHCL } from './insightHclExporter'
diff --git a/frontend/src/products.tsx b/frontend/src/products.tsx
index aae2455f73cc..3579f2d50b76 100644
--- a/frontend/src/products.tsx
+++ b/frontend/src/products.tsx
@@ -4,7 +4,6 @@
import { combineUrl } from 'kea-router'
import posthog from 'posthog-js'
-import { AlertType } from 'lib/components/Alerts/types'
import { FEATURE_FLAGS, INSIGHT_VISUAL_ORDER } from 'lib/constants'
import { toParams } from 'lib/utils/url'
import type { Params } from 'scenes/sceneTypes'
@@ -30,6 +29,8 @@ import {
import { isDataTableNode, isDataVisualizationNode, isHogQLQuery } from '~/queries/utils'
import { ActivityScope } from '~/types'
+import { AlertType } from 'products/alerts/frontend/types'
+
import { AI_OBSERVABILITY_CLUSTER_URL_PATTERN } from '../../products/ai_observability/frontend/clusters/constants'
import type {
SchemaConfigurationSection,
diff --git a/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx b/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx
index 059171ea9ace..aa4f3aaddec8 100644
--- a/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx
@@ -6,7 +6,6 @@ import { useCallback, useRef, useState } from 'react'
import { IconGear } from '@posthog/icons'
import { LemonButton, LemonDivider } from '@posthog/lemon-ui'
-import { alertsToThresholdGoalLines, insightAlertsLogic } from 'lib/components/Alerts/insightAlertsLogic'
import { ExportButton } from 'lib/components/ExportButton/ExportButton'
import { useAttachedLogic } from 'lib/logic/scenes/useAttachedLogic'
import { InsightErrorState, StatelessInsightLoadingState } from 'scenes/insights/EmptyStates'
@@ -28,6 +27,8 @@ import { QueryContext } from '~/queries/types'
import { shouldQueryBeAsync } from '~/queries/utils'
import { ChartDisplayType, ExportContext, ExporterFormat, InsightLogicProps } from '~/types'
+import { alertsToThresholdGoalLines, insightAlertsLogic } from 'products/alerts/frontend/logic/insightAlertsLogic'
+
import { DataNodeLogicProps, dataNodeLogic } from '../DataNode/dataNodeLogic'
import { DateRange } from '../DataNode/DateRange'
import { ElapsedTime } from '../DataNode/ElapsedTime'
diff --git a/frontend/src/scenes/insights/EditorFilters/ShowAlertAnomalyPointsFilter.tsx b/frontend/src/scenes/insights/EditorFilters/ShowAlertAnomalyPointsFilter.tsx
index 767c4036c8e6..862e1685d0f7 100644
--- a/frontend/src/scenes/insights/EditorFilters/ShowAlertAnomalyPointsFilter.tsx
+++ b/frontend/src/scenes/insights/EditorFilters/ShowAlertAnomalyPointsFilter.tsx
@@ -2,9 +2,10 @@ import { useActions, useValues } from 'kea'
import { LemonCheckbox } from '@posthog/lemon-ui'
-import { insightAlertsLogic } from 'lib/components/Alerts/insightAlertsLogic'
import { insightLogic } from 'scenes/insights/insightLogic'
+import { insightAlertsLogic } from 'products/alerts/frontend/logic/insightAlertsLogic'
+
export function ShowAlertAnomalyPointsFilter(): JSX.Element | null {
const { insightProps, insight } = useValues(insightLogic)
const logic = insightAlertsLogic({ insightId: insight.id!, insightLogicProps: insightProps })
diff --git a/frontend/src/scenes/insights/InsightModals.tsx b/frontend/src/scenes/insights/InsightModals.tsx
index 844aba2b585c..6668dff3f524 100644
--- a/frontend/src/scenes/insights/InsightModals.tsx
+++ b/frontend/src/scenes/insights/InsightModals.tsx
@@ -2,9 +2,6 @@ import { useActions, useValues } from 'kea'
import { router } from 'kea-router'
import { AddToDashboardModal } from 'lib/components/AddToDashboard/AddToDashboardModal'
-import { areAlertsSupportedForInsight } from 'lib/components/Alerts/insightAlertsLogic'
-import { EditAlertModal } from 'lib/components/Alerts/views/EditAlertModal'
-import { ManageAlertsModal } from 'lib/components/Alerts/views/ManageAlertsModal'
import { SharingModal } from 'lib/components/Sharing/SharingModal'
import { TerraformExportModal } from 'lib/components/TerraformExporter/TerraformExportModal'
import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
@@ -17,6 +14,9 @@ import { urls } from 'scenes/urls'
import { EndpointQueryNode, HogQLQuery } from '~/queries/schema/schema-general'
import { InsightLogicProps, InsightShortId, ItemMode } from '~/types'
+import { areAlertsSupportedForInsight } from 'products/alerts/frontend/logic/insightAlertsLogic'
+import { EditAlertModal } from 'products/alerts/frontend/views/EditAlertModal'
+import { ManageAlertsModal } from 'products/alerts/frontend/views/ManageAlertsModal'
import { EndpointFromInsightModal } from 'products/endpoints/frontend/EndpointFromInsightModal'
import { SubscriptionsModal } from 'products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal'
diff --git a/frontend/src/scenes/insights/InsightNav/InsightsNav.tsx b/frontend/src/scenes/insights/InsightNav/InsightsNav.tsx
index 71c6616f7a32..9023d071ba33 100644
--- a/frontend/src/scenes/insights/InsightNav/InsightsNav.tsx
+++ b/frontend/src/scenes/insights/InsightNav/InsightsNav.tsx
@@ -1,7 +1,6 @@
import { useActions, useValues } from 'kea'
import posthog from 'posthog-js'
-import { AlertDeletionWarning } from 'lib/components/Alerts/AlertDeletionWarning'
import { LemonTabs } from 'lib/lemon-ui/LemonTabs'
import { Link } from 'lib/lemon-ui/Link'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
@@ -9,6 +8,8 @@ import { insightNavLogic } from 'scenes/insights/InsightNav/insightNavLogic'
import { INSIGHT_TYPE_URLS } from 'scenes/insights/utils'
import { INSIGHT_TYPES_METADATA } from 'scenes/saved-insights/SavedInsights'
+import { AlertDeletionWarning } from 'products/alerts/frontend/components/AlertDeletionWarning'
+
import { insightLogic } from '../insightLogic'
export function InsightsNav(): JSX.Element {
diff --git a/frontend/src/scenes/insights/InsightPageHeader.tsx b/frontend/src/scenes/insights/InsightPageHeader.tsx
index 268fae9044f6..9ae50e8ae773 100644
--- a/frontend/src/scenes/insights/InsightPageHeader.tsx
+++ b/frontend/src/scenes/insights/InsightPageHeader.tsx
@@ -5,7 +5,6 @@ import { useMemo } from 'react'
import { IconPlusSmall } from '@posthog/icons'
import { AccessControlAction } from 'lib/components/AccessControlAction'
-import { areAlertsSupportedForInsight } from 'lib/components/Alerts/insightAlertsLogic'
import { InsightSubscribeProminentButton } from 'lib/components/Scenes/InsightSubscribeProminentButton'
import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
@@ -30,6 +29,8 @@ import {
} from '~/queries/utils'
import { AccessControlLevel, AccessControlResourceType, InsightLogicProps, ItemMode } from '~/types'
+import { areAlertsSupportedForInsight } from 'products/alerts/frontend/logic/insightAlertsLogic'
+
import { InsightSceneMenuBar } from './SidePanel/InsightSceneMenuBar'
import { InsightSidePanelContent } from './SidePanel/InsightSidePanelContent'
import { getInsightIconTypeFromQuery, getOverrideWarningPropsForButton } from './utils'
diff --git a/frontend/src/scenes/insights/insightLogic.tsx b/frontend/src/scenes/insights/insightLogic.tsx
index 484ade0e5540..893cd7f442f5 100644
--- a/frontend/src/scenes/insights/insightLogic.tsx
+++ b/frontend/src/scenes/insights/insightLogic.tsx
@@ -6,7 +6,6 @@ import posthog from 'posthog-js'
import { LemonDialog, LemonInput } from '@posthog/lemon-ui'
import { ApiError } from 'lib/api'
-import { insightAlertsLogic } from 'lib/components/Alerts/insightAlertsLogic'
import { tryShowMCPHint } from 'lib/components/MCPHint/mcpHintLogic'
import { SetupTaskId, globalSetupLogic } from 'lib/components/ProductSetup'
import { FEATURE_FLAGS } from 'lib/constants'
@@ -61,6 +60,8 @@ import {
SetInsightOptions,
} from '~/types'
+import { insightAlertsLogic } from 'products/alerts/frontend/logic/insightAlertsLogic'
+
import { teamLogic } from '../teamLogic'
import { insightDataLogic, isInsightSceneInstance } from './insightDataLogic'
import type { insightLogicType } from './insightLogicType'
diff --git a/frontend/src/scenes/insights/insightSceneLogic.tsx b/frontend/src/scenes/insights/insightSceneLogic.tsx
index 5bb88bdd7292..2479becff3da 100644
--- a/frontend/src/scenes/insights/insightSceneLogic.tsx
+++ b/frontend/src/scenes/insights/insightSceneLogic.tsx
@@ -3,7 +3,6 @@ import { urlToAction } from 'kea-router'
import { objectsEqual } from 'kea-test-utils'
import api from 'lib/api'
-import { AlertType } from 'lib/components/Alerts/types'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { trackedActionToUrl } from 'lib/logic/scenes/trackedActionToUrl'
import { InsightEventSource, eventUsageLogic } from 'lib/utils/eventUsageLogic'
@@ -53,6 +52,7 @@ import {
SidePanelTab,
} from '~/types'
+import { AlertType } from 'products/alerts/frontend/types'
import { PRODUCT_ANALYTICS_DEFAULT_QUERY_TAGS } from 'products/product_analytics/frontend/constants'
import { insightDataLogic } from './insightDataLogic'
diff --git a/frontend/src/scenes/insights/views/LineGraph/LineGraph.tsx b/frontend/src/scenes/insights/views/LineGraph/LineGraph.tsx
index a74aa51d089e..bbc4c70092f2 100644
--- a/frontend/src/scenes/insights/views/LineGraph/LineGraph.tsx
+++ b/frontend/src/scenes/insights/views/LineGraph/LineGraph.tsx
@@ -1,10 +1,11 @@
import { Chart, ChartEvent, ChartType, DeepPartial, InteractionItem, LegendOptions } from 'lib/Chart'
-import { AnomalyPoint } from 'lib/components/Alerts/types'
import { TooltipConfig } from 'scenes/insights/InsightTooltip/insightTooltipUtils'
import { GoalLine, TrendsFilter } from '~/queries/schema/schema-general'
import { GraphDataset, GraphPoint, GraphPointPayload, GraphType } from '~/types'
+import { AnomalyPoint } from 'products/alerts/frontend/types'
+
export function onChartClick(
event: ChartEvent,
chart: Chart,
diff --git a/frontend/src/scenes/saved-insights/SavedInsights.tsx b/frontend/src/scenes/saved-insights/SavedInsights.tsx
index d1c6e25ca301..716d91b7ba17 100644
--- a/frontend/src/scenes/saved-insights/SavedInsights.tsx
+++ b/frontend/src/scenes/saved-insights/SavedInsights.tsx
@@ -36,7 +36,6 @@ import { LemonSelectOptions } from '@posthog/lemon-ui'
import { AccessControlAction } from 'lib/components/AccessControlAction'
import { ActivityLog } from 'lib/components/ActivityLog/ActivityLog'
-import { Alerts } from 'lib/components/Alerts/views/Alerts'
import { BulkUpdateTagsButton } from 'lib/components/BulkActions/BulkUpdateTagsButton'
import { ObjectTags } from 'lib/components/ObjectTags/ObjectTags'
import { Shortcut } from 'lib/components/Shortcuts/Shortcut'
@@ -85,6 +84,8 @@ import {
SavedInsightsTabs,
} from '~/types'
+import { Alerts } from 'products/alerts/frontend/views/Alerts'
+
import { ReloadInsight } from './ReloadInsight'
import { SavedInsightListItem, savedInsightsLogic } from './savedInsightsLogic'
diff --git a/frontend/src/scenes/saved-insights/savedInsightsLogic.ts b/frontend/src/scenes/saved-insights/savedInsightsLogic.ts
index 80d2f2b04217..3e02373abedd 100644
--- a/frontend/src/scenes/saved-insights/savedInsightsLogic.ts
+++ b/frontend/src/scenes/saved-insights/savedInsightsLogic.ts
@@ -3,7 +3,6 @@ import { loaders } from 'kea-loaders'
import { router, urlToAction } from 'kea-router'
import api, { CountedPaginatedResponse } from 'lib/api'
-import { AlertType } from 'lib/components/Alerts/types'
import { dayjs } from 'lib/dayjs'
import { Sorting } from 'lib/lemon-ui/LemonTable'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
@@ -25,6 +24,7 @@ import { insightsModel } from '~/models/insightsModel'
import { getQueryBasedInsightModel } from '~/queries/nodes/InsightViz/utils'
import { Breadcrumb, InsightModel, QueryBasedInsightModel, SavedInsightsTabs } from '~/types'
+import { AlertType } from 'products/alerts/frontend/types'
import {
InsightBulkDeleteResponseApi,
InsightBulkRestoreResponseApi,
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index 54a0c4f1f4cf..8948fe061af8 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -9,7 +9,6 @@ import { LemonTableColumns } from '@posthog/lemon-ui'
import { PaginatedResponse } from 'lib/api'
import { ChartDataset, ChartType, InteractionItem } from 'lib/Chart'
-import { AlertType } from 'lib/components/Alerts/types'
import { CommonFilters, HeatmapFilters, HeatmapFixedPositionMode } from 'lib/components/heatmaps/types'
import { HedgehogActorOptions } from 'lib/components/HedgehogMode/types'
import { SessionRecordingTriggerGroupsConfig, UrlTriggerConfig } from 'lib/components/IngestionControls/types'
@@ -79,6 +78,7 @@ import type {
} from '~/queries/schema/schema-general'
import { QueryContext } from '~/queries/types'
+import { AlertType } from 'products/alerts/frontend/types'
import type { ExperimentFeatureFlagInputApi } from 'products/experiments/frontend/generated/api.schemas'
import type { AIPromptConfigApi } from 'products/subscriptions/frontend/generated/api.schemas'
import { CyclotronInputType } from 'products/workflows/frontend/Workflows/hogflows/steps/types'
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b22021e87534..78a3ab53de87 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -2724,6 +2724,9 @@ importers:
products/alerts:
dependencies:
+ '@posthog/brand':
+ specifier: 'catalog:'
+ version: 0.6.0([email protected])
'@posthog/icons':
specifier: 'catalog:'
@@ -2733,12 +2736,27 @@ importers:
'@types/react':
specifier: 18.3.27
version: 18.3.27
+ chartjs-plugin-annotation:
+ specifier: '*'
+ version: 3.1.0([email protected])
+ fast-deep-equal:
+ specifier: '*'
+ version: 3.1.3
kea:
specifier: 'catalog:'
version: 4.0.0-pre.5([email protected])
kea-forms:
- specifier: '*'
+ specifier: 'catalog:'
+ kea-loaders:
+ specifier: 'catalog:'
+ kea-router:
+ specifier: 'catalog:'
+ kea-subscriptions:
+ specifier: 'catalog:'
posthog-js:
specifier: 'catalog:'
version: 1.399.1
@@ -2748,6 +2766,9 @@ importers:
typescript:
specifier: 6.0.3
version: 6.0.3
+ zod:
+ specifier: '*'
+ version: 4.3.6
devDependencies:
'@storybook/react':
specifier: 'catalog:'
diff --git a/frontend/src/lib/components/Alerts/AlertDeletionWarning.tsx b/products/alerts/frontend/components/AlertDeletionWarning.tsx
similarity index 93%
rename from frontend/src/lib/components/Alerts/AlertDeletionWarning.tsx
rename to products/alerts/frontend/components/AlertDeletionWarning.tsx
index 2394cd5dd7eb..ae735262b6bf 100644
--- a/frontend/src/lib/components/Alerts/AlertDeletionWarning.tsx
+++ b/products/alerts/frontend/components/AlertDeletionWarning.tsx
@@ -3,7 +3,7 @@ import { useValues } from 'kea'
import { LemonBanner } from 'lib/lemon-ui/LemonBanner'
import { insightLogic } from 'scenes/insights/insightLogic'
-import { insightAlertsLogic } from './insightAlertsLogic'
+import { insightAlertsLogic } from '../logic/insightAlertsLogic'
export function AlertDeletionWarning(): JSX.Element | null {
const { insightProps, insight } = useValues(insightLogic)
diff --git a/frontend/src/lib/components/Alerts/AlertsButton.tsx b/products/alerts/frontend/components/AlertsButton.tsx
similarity index 97%
rename from frontend/src/lib/components/Alerts/AlertsButton.tsx
rename to products/alerts/frontend/components/AlertsButton.tsx
index b1097bf016ea..79488a277391 100644
--- a/frontend/src/lib/components/Alerts/AlertsButton.tsx
+++ b/products/alerts/frontend/components/AlertsButton.tsx
@@ -10,7 +10,7 @@ import { urls } from 'scenes/urls'
import { InsightLogicProps, QueryBasedInsightModel } from '~/types'
-import { alertsUnsupportedReason, areAlertsSupportedForInsight, insightAlertsLogic } from './insightAlertsLogic'
+import { alertsUnsupportedReason, areAlertsSupportedForInsight, insightAlertsLogic } from '../logic/insightAlertsLogic'
export type AlertsButtonProps = LemonButtonProps & {
insight: Partial<QueryBasedInsightModel>
diff --git a/frontend/src/lib/components/Alerts/AlertsFiltersBar.tsx b/products/alerts/frontend/components/AlertsFiltersBar.tsx
similarity index 95%
rename from frontend/src/lib/components/Alerts/AlertsFiltersBar.tsx
rename to products/alerts/frontend/components/AlertsFiltersBar.tsx
index 545c8cfcee2c..a738a18a82b1 100644
--- a/frontend/src/lib/components/Alerts/AlertsFiltersBar.tsx
+++ b/products/alerts/frontend/components/AlertsFiltersBar.tsx
@@ -4,7 +4,7 @@ import { LemonInput } from '@posthog/lemon-ui'
import { MemberSelect } from 'lib/components/MemberSelect'
-import { alertsLogic } from './alertsLogic'
+import { alertsLogic } from '../logic/alertsLogic'
export function AlertsFiltersBar(): JSX.Element {
const { filters } = useValues(alertsLogic)
diff --git a/products/alerts/frontend/components/QuietHoursDayTimeline.tsx b/products/alerts/frontend/components/QuietHoursDayTimeline.tsx
index fc8fcfaf0cf2..b3d1f57b0e06 100644
--- a/products/alerts/frontend/components/QuietHoursDayTimeline.tsx
+++ b/products/alerts/frontend/components/QuietHoursDayTimeline.tsx
@@ -1,8 +1,8 @@
import {
blockedAndAllowedMinuteIntervalsForQuietHours,
MINUTES_PER_DAY,
-} from 'lib/components/Alerts/scheduleRestrictionValidation'
-import type { BlockedWindow } from 'lib/components/Alerts/types'
+} from 'products/alerts/frontend/logic/scheduleRestrictionValidation'
+import type { BlockedWindow } from 'products/alerts/frontend/types'
type TimelineSegment = { kind: 'blocked' | 'allowed'; from: number; to: number }
diff --git a/products/alerts/frontend/components/QuietHoursFields.stories.tsx b/products/alerts/frontend/components/QuietHoursFields.stories.tsx
index b8a6b2bcd252..7bb9a732d687 100644
--- a/products/alerts/frontend/components/QuietHoursFields.stories.tsx
+++ b/products/alerts/frontend/components/QuietHoursFields.stories.tsx
@@ -1,10 +1,10 @@
import type { Meta, StoryObj } from '@storybook/react'
import { useState } from 'react'
-import type { ScheduleRestriction } from 'lib/components/Alerts/types'
-
import { AlertCalculationInterval } from '~/queries/schema/schema-general'
+import type { ScheduleRestriction } from 'products/alerts/frontend/types'
+
import type { QuietHoursFieldsProps } from './QuietHoursFields'
import { QuietHoursFields } from './QuietHoursFields'
diff --git a/products/alerts/frontend/components/QuietHoursFields.tsx b/products/alerts/frontend/components/QuietHoursFields.tsx
index 741de4d89a63..5685f2308afe 100644
--- a/products/alerts/frontend/components/QuietHoursFields.tsx
+++ b/products/alerts/frontend/components/QuietHoursFields.tsx
@@ -3,13 +3,12 @@ import { useMemo, type FocusEvent } from 'react'
import { IconTrash } from '@posthog/icons'
import { LemonBanner, LemonButton, LemonCheckbox, LemonInput } from '@posthog/lemon-ui'
-import { findQuietHoursIssues, MAX_BLOCKED_WINDOWS } from 'lib/components/Alerts/scheduleRestrictionValidation'
-import type { BlockedWindow, ScheduleRestriction } from 'lib/components/Alerts/types'
-
import { AlertCalculationInterval } from '~/queries/schema/schema-general'
import { isSubDailyAlertInterval } from 'products/alerts/frontend/logic/alertIntervalHelpers'
import { estimateCheckSlotsNext24h } from 'products/alerts/frontend/logic/scheduleRestrictionPreview'
+import { findQuietHoursIssues, MAX_BLOCKED_WINDOWS } from 'products/alerts/frontend/logic/scheduleRestrictionValidation'
+import type { BlockedWindow, ScheduleRestriction } from 'products/alerts/frontend/types'
import { QuietHoursDayTimeline } from './QuietHoursDayTimeline'
@@ -40,7 +39,7 @@ export function QuietHoursFields({
onChange,
}: QuietHoursFieldsProps): JSX.Element {
const enabled = !!scheduleRestriction?.blocked_windows?.length
- const windows = scheduleRestriction?.blocked_windows ?? []
+ const windows = useMemo(() => scheduleRestriction?.blocked_windows ?? [], [scheduleRestriction?.blocked_windows])
const setWindows = (nextWindows: BlockedWindow[]): void => {
if (nextWindows.length === 0) {
diff --git a/frontend/src/lib/components/Alerts/SnoozeButton.tsx b/products/alerts/frontend/components/SnoozeButton.tsx
similarity index 95%
rename from frontend/src/lib/components/Alerts/SnoozeButton.tsx
rename to products/alerts/frontend/components/SnoozeButton.tsx
index df79777cd3a1..c969c12fdf66 100644
--- a/frontend/src/lib/components/Alerts/SnoozeButton.tsx
+++ b/products/alerts/frontend/components/SnoozeButton.tsx
@@ -1,8 +1,7 @@
+import { DateFilter } from 'lib/components/DateFilter/DateFilter'
import { dayjs } from 'lib/dayjs'
import { formatDate } from 'lib/utils/datetime'
-import { DateFilter } from '../DateFilter/DateFilter'
-
const DATETIME_FORMAT = 'MMM D - HH:mm'
interface SnoozeButtonProps {
diff --git a/frontend/src/scenes/alerts/activityDescriptions.tsx b/products/alerts/frontend/components/activityDescriptions.tsx
similarity index 100%
rename from frontend/src/scenes/alerts/activityDescriptions.tsx
rename to products/alerts/frontend/components/activityDescriptions.tsx
diff --git a/products/alerts/frontend/components/editAlertModal/AlertAdvancedOptionsSection.tsx b/products/alerts/frontend/components/editAlertModal/AlertAdvancedOptionsSection.tsx
index 2518c9e1cf6d..795049aeda85 100644
--- a/products/alerts/frontend/components/editAlertModal/AlertAdvancedOptionsSection.tsx
+++ b/products/alerts/frontend/components/editAlertModal/AlertAdvancedOptionsSection.tsx
@@ -3,11 +3,11 @@ import { Group } from 'kea-forms'
import { IconInfo } from '@posthog/icons'
import { LemonCheckbox, LemonCollapse, Tooltip } from '@posthog/lemon-ui'
-import { AlertFormType, ongoingIntervalField } from 'lib/components/Alerts/alertFormLogic'
import { LemonField } from 'lib/lemon-ui/LemonField'
import { AlertCalculationInterval } from '~/queries/schema/schema-general'
+import { AlertFormType, ongoingIntervalField } from 'products/alerts/frontend/logic/alertFormLogic'
import { isSubDailyAlertInterval } from 'products/alerts/frontend/logic/alertIntervalHelpers'
import { QuietHoursFields } from '../QuietHoursFields'
diff --git a/products/alerts/frontend/components/editAlertModal/AlertDefinitionFields.tsx b/products/alerts/frontend/components/editAlertModal/AlertDefinitionFields.tsx
index 2f960cd4f3eb..b84d758dfc44 100644
--- a/products/alerts/frontend/components/editAlertModal/AlertDefinitionFields.tsx
+++ b/products/alerts/frontend/components/editAlertModal/AlertDefinitionFields.tsx
@@ -3,20 +3,21 @@ import { Group } from 'kea-forms'
import { IconInfo } from '@posthog/icons'
import { LemonBanner, LemonSelect, LemonTag, Tooltip } from '@posthog/lemon-ui'
-import { AlertFormType } from 'lib/components/Alerts/alertFormLogic'
-import {
- funnelConfigForOptionKey,
- funnelConfigToOptionKey,
- funnelConversionOptions,
-} from 'lib/components/Alerts/funnelAlertOptions'
-import { FunnelAlertPreview } from 'lib/components/Alerts/funnelAlertPreview'
-import { HogQLAlertPreview } from 'lib/components/Alerts/hogqlAlertPreview'
-import { isFunnelsAlertConfig } from 'lib/components/Alerts/types'
import { LemonField } from 'lib/lemon-ui/LemonField'
import { alphabet } from 'lib/utils/strings'
import { AlertConditionType } from '~/queries/schema/schema-general'
+import { AlertFormType } from 'products/alerts/frontend/logic/alertFormLogic'
+import {
+ funnelConfigForOptionKey,
+ funnelConfigToOptionKey,
+ funnelConversionOptions,
+} from 'products/alerts/frontend/logic/funnelAlertOptions'
+import { FunnelAlertPreview } from 'products/alerts/frontend/logic/funnelAlertPreview'
+import { HogQLAlertPreview } from 'products/alerts/frontend/logic/hogqlAlertPreview'
+import { isFunnelsAlertConfig } from 'products/alerts/frontend/types'
+
import { HogQLAlertPreviewBanner, HogQLAlertPreviewRowsTable } from './HogQLAlertPreview'
const breakdownDisabledReason = (alertMode: 'detector' | 'threshold'): string =>
diff --git a/products/alerts/frontend/components/editAlertModal/AlertDefinitionSection.tsx b/products/alerts/frontend/components/editAlertModal/AlertDefinitionSection.tsx
index c749247ffe01..1e116f4a99ed 100644
--- a/products/alerts/frontend/components/editAlertModal/AlertDefinitionSection.tsx
+++ b/products/alerts/frontend/components/editAlertModal/AlertDefinitionSection.tsx
@@ -11,24 +11,24 @@ import {
Tooltip,
} from '@posthog/lemon-ui'
-import { AlertFormType } from 'lib/components/Alerts/alertFormLogic'
-import { FunnelAlertPreview } from 'lib/components/Alerts/funnelAlertPreview'
-import { HogQLAlertPreview } from 'lib/components/Alerts/hogqlAlertPreview'
-import { fractionToPercentInput, rescaleFunnelBound } from 'lib/components/Alerts/thresholdPercent'
+import { LemonField } from 'lib/lemon-ui/LemonField'
+
+import { AlertConditionType, InsightThresholdType } from '~/queries/schema/schema-general'
+
+import { AlertFormType } from 'products/alerts/frontend/logic/alertFormLogic'
+import { getDefaultSimulationRange } from 'products/alerts/frontend/logic/alertIntervalHelpers'
+import { FunnelAlertPreview } from 'products/alerts/frontend/logic/funnelAlertPreview'
+import { HogQLAlertPreview } from 'products/alerts/frontend/logic/hogqlAlertPreview'
+import { fractionToPercentInput, rescaleFunnelBound } from 'products/alerts/frontend/logic/thresholdPercent'
import {
AlertSimulationResult,
isAnyRowHogQLConfig,
isFunnelsAlertConfig,
isHogQLAlertConfig,
isTrendsAlertConfig,
-} from 'lib/components/Alerts/types'
-import { DetectorSelector, getDefaultWindow } from 'lib/components/Alerts/views/DetectorSelector'
-import { SimulationSummary } from 'lib/components/Alerts/views/SimulationSummary'
-import { LemonField } from 'lib/lemon-ui/LemonField'
-
-import { AlertConditionType, InsightThresholdType } from '~/queries/schema/schema-general'
-
-import { getDefaultSimulationRange } from 'products/alerts/frontend/logic/alertIntervalHelpers'
+} from 'products/alerts/frontend/types'
+import { DetectorSelector, getDefaultWindow } from 'products/alerts/frontend/views/DetectorSelector'
+import { SimulationSummary } from 'products/alerts/frontend/views/SimulationSummary'
import { FunnelsDefinitionFields, HogQLDefinitionFields, TrendsDefinitionFields } from './AlertDefinitionFields'
import { getSimulationRangeOptions } from './editAlertModalUtils'
diff --git a/products/alerts/frontend/components/editAlertModal/AlertIntervalRow.tsx b/products/alerts/frontend/components/editAlertModal/AlertIntervalRow.tsx
index f486d9623873..97a65bb968f1 100644
--- a/products/alerts/frontend/components/editAlertModal/AlertIntervalRow.tsx
+++ b/products/alerts/frontend/components/editAlertModal/AlertIntervalRow.tsx
@@ -3,14 +3,6 @@ import { useValues } from 'kea'
import { IconClock } from '@posthog/icons'
import { LemonSelect, Tooltip } from '@posthog/lemon-ui'
-import { AlertFormType } from 'lib/components/Alerts/alertFormLogic'
-import {
- AlertType,
- isHogQLAlertConfig,
- isTrendsAlertConfig,
- supportsOngoingInterval,
- supportsTimeWindow,
-} from 'lib/components/Alerts/types'
import { TZLabel } from 'lib/components/TZLabel'
import { upgradeModalLogic } from 'lib/components/UpgradeModal/upgradeModalLogic'
import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
@@ -20,10 +12,18 @@ import { userLogic } from 'scenes/userLogic'
import { AlertCalculationInterval } from '~/queries/schema/schema-general'
import { AvailableFeature } from '~/types'
+import { AlertFormType } from 'products/alerts/frontend/logic/alertFormLogic'
import {
cadenceFinerThanInsightInterval,
selectAlertCalculationInterval,
} from 'products/alerts/frontend/logic/alertIntervalHelpers'
+import {
+ AlertType,
+ isHogQLAlertConfig,
+ isTrendsAlertConfig,
+ supportsOngoingInterval,
+ supportsTimeWindow,
+} from 'products/alerts/frontend/types'
import { getAlertIntervalOptions } from './editAlertModalUtils'
diff --git a/products/alerts/frontend/components/editAlertModal/AlertNotificationSection.tsx b/products/alerts/frontend/components/editAlertModal/AlertNotificationSection.tsx
index 580dfa9fdaaf..1a9490434c70 100644
--- a/products/alerts/frontend/components/editAlertModal/AlertNotificationSection.tsx
+++ b/products/alerts/frontend/components/editAlertModal/AlertNotificationSection.tsx
@@ -1,11 +1,12 @@
-import { AlertFormType } from 'lib/components/Alerts/alertFormLogic'
-import { AlertType } from 'lib/components/Alerts/types'
-import { AlertDestinationSelector } from 'lib/components/Alerts/views/AlertDestinationSelector'
-import { InlineAlertNotifications } from 'lib/components/Alerts/views/InlineAlertNotifications'
import { MemberSelectMultiple } from 'lib/components/MemberSelectMultiple'
import { InsightShortId } from '~/types'
+import { AlertFormType } from 'products/alerts/frontend/logic/alertFormLogic'
+import { AlertType } from 'products/alerts/frontend/types'
+import { AlertDestinationSelector } from 'products/alerts/frontend/views/AlertDestinationSelector'
+import { InlineAlertNotifications } from 'products/alerts/frontend/views/InlineAlertNotifications'
+
export interface AlertNotificationSectionProps {
alertForm: AlertFormType
alertId: AlertType['id'] | undefined
diff --git a/products/alerts/frontend/components/editAlertModal/HogQLAlertPreview.tsx b/products/alerts/frontend/components/editAlertModal/HogQLAlertPreview.tsx
index 55dac67f332b..7fe156f572a3 100644
--- a/products/alerts/frontend/components/editAlertModal/HogQLAlertPreview.tsx
+++ b/products/alerts/frontend/components/editAlertModal/HogQLAlertPreview.tsx
@@ -1,15 +1,16 @@
import { LemonBanner, LemonTable, LemonTag } from '@posthog/lemon-ui'
-import {
- HOGQL_ANY_ROW_MAX_ROWS,
- HogQLAlertPreview,
- HogQLAlertPreviewRow,
-} from 'lib/components/Alerts/hogqlAlertPreview'
import { humanFriendlyNumber } from 'lib/utils/numbers'
import { pluralize } from 'lib/utils/strings'
import { AlertConditionType } from '~/queries/schema/schema-general'
+import {
+ HOGQL_ANY_ROW_MAX_ROWS,
+ HogQLAlertPreview,
+ HogQLAlertPreviewRow,
+} from 'products/alerts/frontend/logic/hogqlAlertPreview'
+
const PREVIEW_TABLE_MAX_ROWS = 10
/** Per-row view of what the alert would evaluate: breaching rows first (any-row) or the most
diff --git a/frontend/src/lib/components/Alerts/alertFormLogic.test.ts b/products/alerts/frontend/logic/alertFormLogic.test.ts
similarity index 99%
rename from frontend/src/lib/components/Alerts/alertFormLogic.test.ts
rename to products/alerts/frontend/logic/alertFormLogic.test.ts
index c4bc13d1a622..016576313039 100644
--- a/frontend/src/lib/components/Alerts/alertFormLogic.test.ts
+++ b/products/alerts/frontend/logic/alertFormLogic.test.ts
@@ -21,6 +21,8 @@ import {
import { initKeaTests } from '~/test/init'
import { InsightLogicProps, InsightShortId } from '~/types'
+import { supportsOngoingInterval } from '../types'
+import type { AlertType } from '../types'
import {
alertFormLogic,
canCheckOngoingInterval,
@@ -32,8 +34,6 @@ import { alertNotificationLogic } from './alertNotificationLogic'
import { deriveFunnelAlertPreview } from './funnelAlertPreview'
import { deriveHogQLAlertPreview, HOGQL_ANY_ROW_MAX_ROWS, HOGQL_LAST_ROW_MAX_ROWS } from './hogqlAlertPreview'
import { insightAlertsLogic } from './insightAlertsLogic'
-import { supportsOngoingInterval } from './types'
-import type { AlertType } from './types'
const Insight42 = '42' as InsightShortId
diff --git a/frontend/src/lib/components/Alerts/alertFormLogic.ts b/products/alerts/frontend/logic/alertFormLogic.ts
similarity index 99%
rename from frontend/src/lib/components/Alerts/alertFormLogic.ts
rename to products/alerts/frontend/logic/alertFormLogic.ts
index 31d5f7ba16e3..bfe89944962f 100644
--- a/frontend/src/lib/components/Alerts/alertFormLogic.ts
+++ b/products/alerts/frontend/logic/alertFormLogic.ts
@@ -27,13 +27,6 @@ import {
isSubDailyAlertInterval,
} from 'products/alerts/frontend/logic/alertIntervalHelpers'
-import type { alertFormLogicType } from './alertFormLogicType'
-import { getAlertFormValidationErrors } from './alertFormSchema'
-import { alertLogic } from './alertLogic'
-import { alertNotificationLogic } from './alertNotificationLogic'
-import { deriveFunnelAlertPreview, FunnelAlertPreview } from './funnelAlertPreview'
-import { columnIsNumeric, deriveHogQLAlertPreview, HogQLAlertPreview } from './hogqlAlertPreview'
-import { insightAlertsLogic } from './insightAlertsLogic'
import {
AlertConfig,
AlertSimulationResult,
@@ -44,7 +37,14 @@ import {
isHogQLAlertConfig,
isTrendsAlertConfig,
supportsOngoingInterval,
-} from './types'
+} from '../types'
+import type { alertFormLogicType } from './alertFormLogicType'
+import { getAlertFormValidationErrors } from './alertFormSchema'
+import { alertLogic } from './alertLogic'
+import { alertNotificationLogic } from './alertNotificationLogic'
+import { deriveFunnelAlertPreview, FunnelAlertPreview } from './funnelAlertPreview'
+import { columnIsNumeric, deriveHogQLAlertPreview, HogQLAlertPreview } from './hogqlAlertPreview'
+import { insightAlertsLogic } from './insightAlertsLogic'
export { THRESHOLD_BOUNDS_FORM_ERROR, thresholdAlertHasBounds } from './alertFormSchema'
diff --git a/frontend/src/lib/components/Alerts/alertFormSchema.test.ts b/products/alerts/frontend/logic/alertFormSchema.test.ts
similarity index 100%
rename from frontend/src/lib/components/Alerts/alertFormSchema.test.ts
rename to products/alerts/frontend/logic/alertFormSchema.test.ts
diff --git a/frontend/src/lib/components/Alerts/alertFormSchema.ts b/products/alerts/frontend/logic/alertFormSchema.ts
similarity index 98%
rename from frontend/src/lib/components/Alerts/alertFormSchema.ts
rename to products/alerts/frontend/logic/alertFormSchema.ts
index c23b7d3e5051..a709347f469d 100644
--- a/frontend/src/lib/components/Alerts/alertFormSchema.ts
+++ b/products/alerts/frontend/logic/alertFormSchema.ts
@@ -1,9 +1,9 @@
import type { DeepPartialMap, ValidationErrorType } from 'kea-forms'
import { z } from 'zod'
+import type { AlertType } from '../types'
import type { AlertFormType } from './alertFormLogic'
import { quietHoursFormError } from './scheduleRestrictionValidation'
-import type { AlertType } from './types'
export const THRESHOLD_BOUNDS_FORM_ERROR = 'Enter at least one threshold (less than or more than)'
diff --git a/frontend/src/lib/components/Alerts/alertLogic.ts b/products/alerts/frontend/logic/alertLogic.ts
similarity index 99%
rename from frontend/src/lib/components/Alerts/alertLogic.ts
rename to products/alerts/frontend/logic/alertLogic.ts
index b5238e3f864c..9b490b594187 100644
--- a/frontend/src/lib/components/Alerts/alertLogic.ts
+++ b/products/alerts/frontend/logic/alertLogic.ts
@@ -7,8 +7,8 @@ import { formatDate } from 'lib/utils/datetime'
import { AlertState } from '~/queries/schema/schema-general'
+import type { AlertCheck, AlertType } from '../types'
import type { alertLogicType } from './alertLogicType'
-import type { AlertCheck, AlertType } from './types'
export const CHART_CHECKS_LIMIT = 50
export const TABLE_CHECKS_PAGE_SIZE = 25
diff --git a/frontend/src/lib/components/Alerts/alertNotificationLogic.test.ts b/products/alerts/frontend/logic/alertNotificationLogic.test.ts
similarity index 98%
rename from frontend/src/lib/components/Alerts/alertNotificationLogic.test.ts
rename to products/alerts/frontend/logic/alertNotificationLogic.test.ts
index d8109b93c3f2..1976d9f08b15 100644
--- a/frontend/src/lib/components/Alerts/alertNotificationLogic.test.ts
+++ b/products/alerts/frontend/logic/alertNotificationLogic.test.ts
@@ -1,14 +1,15 @@
import { expectLogic } from 'kea-test-utils'
import api from 'lib/api'
+
+import { initKeaTests } from '~/test/init'
+import { HogFunctionType } from '~/types'
+
import {
ALERT_NOTIFICATION_TYPE_DISCORD,
ALERT_NOTIFICATION_TYPE_MICROSOFT_TEAMS,
ALERT_NOTIFICATION_TYPE_WEBHOOK,
-} from 'lib/utils/alerts'
-
-import { initKeaTests } from '~/test/init'
-import { HogFunctionType } from '~/types'
+} from 'products/alerts/frontend/logic/alertNotifications'
import { alertNotificationLogic } from './alertNotificationLogic'
diff --git a/frontend/src/lib/components/Alerts/alertNotificationLogic.ts b/products/alerts/frontend/logic/alertNotificationLogic.ts
similarity index 99%
rename from frontend/src/lib/components/Alerts/alertNotificationLogic.ts
rename to products/alerts/frontend/logic/alertNotificationLogic.ts
index a036e7b3d110..0d84cf8ff0f1 100644
--- a/frontend/src/lib/components/Alerts/alertNotificationLogic.ts
+++ b/products/alerts/frontend/logic/alertNotificationLogic.ts
@@ -4,6 +4,11 @@ import { loaders } from 'kea-loaders'
import api from 'lib/api'
import { integrationsLogic } from 'lib/integrations/integrationsLogic'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
+import { deleteWithUndo } from 'lib/utils/deleteWithUndo'
+import { projectLogic } from 'scenes/projectLogic'
+
+import { HogFunctionType, IntegrationType } from '~/types'
+
import {
ALERT_NOTIFICATION_TYPE_DISCORD,
ALERT_NOTIFICATION_TYPE_MICROSOFT_TEAMS,
@@ -13,11 +18,7 @@ import {
PendingAlertNotification,
buildAlertFilterConfig,
buildHogFunctionPayload,
-} from 'lib/utils/alerts'
-import { deleteWithUndo } from 'lib/utils/deleteWithUndo'
-import { projectLogic } from 'scenes/projectLogic'
-
-import { HogFunctionType, IntegrationType } from '~/types'
+} from 'products/alerts/frontend/logic/alertNotifications'
import type { alertNotificationLogicType } from './alertNotificationLogicType'
diff --git a/frontend/src/lib/utils/alerts.test.ts b/products/alerts/frontend/logic/alertNotifications.test.ts
similarity index 99%
rename from frontend/src/lib/utils/alerts.test.ts
rename to products/alerts/frontend/logic/alertNotifications.test.ts
index b9a1b626e549..f2b9fb450633 100644
--- a/frontend/src/lib/utils/alerts.test.ts
+++ b/products/alerts/frontend/logic/alertNotifications.test.ts
@@ -1,6 +1,6 @@
import { PropertyFilterType, PropertyOperator } from '~/types'
-import { PendingAlertNotification, buildAlertFilterConfig, buildHogFunctionPayload } from './alerts'
+import { PendingAlertNotification, buildAlertFilterConfig, buildHogFunctionPayload } from './alertNotifications'
describe('alertUtils', () => {
describe('buildAlertFilterConfig', () => {
diff --git a/frontend/src/lib/utils/alerts.ts b/products/alerts/frontend/logic/alertNotifications.ts
similarity index 100%
rename from frontend/src/lib/utils/alerts.ts
rename to products/alerts/frontend/logic/alertNotifications.ts
diff --git a/frontend/src/lib/components/Alerts/alertPreviewShared.test.ts b/products/alerts/frontend/logic/alertPreviewShared.test.ts
similarity index 100%
rename from frontend/src/lib/components/Alerts/alertPreviewShared.test.ts
rename to products/alerts/frontend/logic/alertPreviewShared.test.ts
diff --git a/frontend/src/lib/components/Alerts/alertPreviewShared.ts b/products/alerts/frontend/logic/alertPreviewShared.ts
similarity index 100%
rename from frontend/src/lib/components/Alerts/alertPreviewShared.ts
rename to products/alerts/frontend/logic/alertPreviewShared.ts
diff --git a/frontend/src/lib/components/Alerts/alertSchedulingStale.test.ts b/products/alerts/frontend/logic/alertSchedulingStale.test.ts
similarity index 100%
rename from frontend/src/lib/components/Alerts/alertSchedulingStale.test.ts
rename to products/alerts/frontend/logic/alertSchedulingStale.test.ts
diff --git a/frontend/src/lib/components/Alerts/alertSchedulingStale.ts b/products/alerts/frontend/logic/alertSchedulingStale.ts
similarity index 96%
rename from frontend/src/lib/components/Alerts/alertSchedulingStale.ts
rename to products/alerts/frontend/logic/alertSchedulingStale.ts
index 0a7e712688ea..a6e48f0feccd 100644
--- a/frontend/src/lib/components/Alerts/alertSchedulingStale.ts
+++ b/products/alerts/frontend/logic/alertSchedulingStale.ts
@@ -2,7 +2,7 @@ import equal from 'fast-deep-equal'
import { AlertCalculationInterval } from '~/queries/schema/schema-general'
-import type { ScheduleRestriction } from './types'
+import type { ScheduleRestriction } from '../types'
export function normalizeScheduleRestrictionForCompare(
sr: ScheduleRestriction | null | undefined
diff --git a/frontend/src/lib/components/Alerts/alertsLogic.ts b/products/alerts/frontend/logic/alertsLogic.ts
similarity index 99%
rename from frontend/src/lib/components/Alerts/alertsLogic.ts
rename to products/alerts/frontend/logic/alertsLogic.ts
index b62ef5b1ea64..220bd8d97548 100644
--- a/frontend/src/lib/components/Alerts/alertsLogic.ts
+++ b/products/alerts/frontend/logic/alertsLogic.ts
@@ -8,9 +8,9 @@ import { objectClean } from 'lib/utils/objects'
import { AlertState } from '~/queries/schema/schema-general'
+import { AlertType } from '../types'
import { AlertLogicProps } from './alertLogic'
import type { alertsLogicType } from './alertsLogicType'
-import { AlertType } from './types'
export interface AlertsLogicProps extends AlertLogicProps {}
diff --git a/frontend/src/lib/components/Alerts/funnelAlertOptions.test.ts b/products/alerts/frontend/logic/funnelAlertOptions.test.ts
similarity index 100%
rename from frontend/src/lib/components/Alerts/funnelAlertOptions.test.ts
rename to products/alerts/frontend/logic/funnelAlertOptions.test.ts
diff --git a/frontend/src/lib/components/Alerts/funnelAlertOptions.ts b/products/alerts/frontend/logic/funnelAlertOptions.ts
similarity index 100%
rename from frontend/src/lib/components/Alerts/funnelAlertOptions.ts
rename to products/alerts/frontend/logic/funnelAlertOptions.ts
diff --git a/frontend/src/lib/components/Alerts/funnelAlertPreview.ts b/products/alerts/frontend/logic/funnelAlertPreview.ts
similarity index 99%
rename from frontend/src/lib/components/Alerts/funnelAlertPreview.ts
rename to products/alerts/frontend/logic/funnelAlertPreview.ts
index 38772e391004..0f0b692d571d 100644
--- a/frontend/src/lib/components/Alerts/funnelAlertPreview.ts
+++ b/products/alerts/frontend/logic/funnelAlertPreview.ts
@@ -1,7 +1,7 @@
import { AlertConditionType, InsightsThresholdBounds, InsightThresholdType } from '~/queries/schema/schema-general'
+import { AlertConfig, isFunnelsAlertConfig } from '../types'
import { hasThresholdBounds, valueBreachesBounds } from './alertPreviewShared'
-import { AlertConfig, isFunnelsAlertConfig } from './types'
export interface FunnelAlertPreviewValue {
label: string | null // breakdown value; null for a non-breakdown funnel
diff --git a/frontend/src/lib/components/Alerts/hogqlAlertPreview.ts b/products/alerts/frontend/logic/hogqlAlertPreview.ts
similarity index 99%
rename from frontend/src/lib/components/Alerts/hogqlAlertPreview.ts
rename to products/alerts/frontend/logic/hogqlAlertPreview.ts
index 2d4575670f4b..3671f833bf0d 100644
--- a/frontend/src/lib/components/Alerts/hogqlAlertPreview.ts
+++ b/products/alerts/frontend/logic/hogqlAlertPreview.ts
@@ -1,7 +1,7 @@
import { InsightsThresholdBounds } from '~/queries/schema/schema-general'
+import { AlertConfig, isHogQLAlertConfig } from '../types'
import { hasThresholdBounds, valueBreachesBounds } from './alertPreviewShared'
-import { AlertConfig, isHogQLAlertConfig } from './types'
/** Mirror of the backend's ANY_ROW_MAX_ROWS (products/alerts/backend/evaluation/hogql.py) — keep
* the two in sync. Advisory only; the backend extractor is the evaluation-time authority. */
diff --git a/frontend/src/lib/components/Alerts/insightAlertsLogic.test.ts b/products/alerts/frontend/logic/insightAlertsLogic.test.ts
similarity index 99%
rename from frontend/src/lib/components/Alerts/insightAlertsLogic.test.ts
rename to products/alerts/frontend/logic/insightAlertsLogic.test.ts
index 4755d629ffe2..1ee3319ef2a6 100644
--- a/frontend/src/lib/components/Alerts/insightAlertsLogic.test.ts
+++ b/products/alerts/frontend/logic/insightAlertsLogic.test.ts
@@ -9,8 +9,8 @@ import { NodeKind } from '~/queries/schema/schema-general'
import { initKeaTests } from '~/test/init'
import { InsightLogicProps, InsightShortId } from '~/types'
+import type { AlertType } from '../types'
import { alertsUnsupportedReason, areAlertsSupportedForInsight, insightAlertsLogic } from './insightAlertsLogic'
-import type { AlertType } from './types'
const Insight42 = '42' as InsightShortId
diff --git a/frontend/src/lib/components/Alerts/insightAlertsLogic.ts b/products/alerts/frontend/logic/insightAlertsLogic.ts
similarity index 99%
rename from frontend/src/lib/components/Alerts/insightAlertsLogic.ts
rename to products/alerts/frontend/logic/insightAlertsLogic.ts
index 682e3c7a56aa..ff13d5192898 100644
--- a/frontend/src/lib/components/Alerts/insightAlertsLogic.ts
+++ b/products/alerts/frontend/logic/insightAlertsLogic.ts
@@ -17,8 +17,8 @@ import {
} from '~/queries/utils'
import { FunnelVizType, InsightLogicProps } from '~/types'
+import { AlertType, AnomalyPoint, isTrendsAlertConfig } from '../types'
import type { insightAlertsLogicType } from './insightAlertsLogicType'
-import { AlertType, AnomalyPoint, isTrendsAlertConfig } from './types'
export interface InsightAlertsLogicProps {
insightId: number
diff --git a/products/alerts/frontend/logic/scheduleRestrictionPreview.ts b/products/alerts/frontend/logic/scheduleRestrictionPreview.ts
index 89758ff20914..32ea0e2b1af9 100644
--- a/products/alerts/frontend/logic/scheduleRestrictionPreview.ts
+++ b/products/alerts/frontend/logic/scheduleRestrictionPreview.ts
@@ -1,6 +1,7 @@
-import type { BlockedWindow } from 'lib/components/Alerts/types'
import { dayjs } from 'lib/dayjs'
+import type { BlockedWindow } from 'products/alerts/frontend/types'
+
type ParsedWindow = { start: number; end: number; overnight: boolean }
function parseHHMM(value: string): number {
diff --git a/frontend/src/lib/components/Alerts/scheduleRestrictionValidation.test.ts b/products/alerts/frontend/logic/scheduleRestrictionValidation.test.ts
similarity index 100%
rename from frontend/src/lib/components/Alerts/scheduleRestrictionValidation.test.ts
rename to products/alerts/frontend/logic/scheduleRestrictionValidation.test.ts
diff --git a/frontend/src/lib/components/Alerts/scheduleRestrictionValidation.ts b/products/alerts/frontend/logic/scheduleRestrictionValidation.ts
similarity index 99%
rename from frontend/src/lib/components/Alerts/scheduleRestrictionValidation.ts
rename to products/alerts/frontend/logic/scheduleRestrictionValidation.ts
index 5758c1e659fd..aa00fad9ae5f 100644
--- a/frontend/src/lib/components/Alerts/scheduleRestrictionValidation.ts
+++ b/products/alerts/frontend/logic/scheduleRestrictionValidation.ts
@@ -1,4 +1,4 @@
-import type { BlockedWindow, ScheduleRestriction } from './types'
+import type { BlockedWindow, ScheduleRestriction } from '../types'
export const MAX_BLOCKED_WINDOWS = 5
export const MIN_BLOCKED_WINDOW_MINUTES = 30
diff --git a/frontend/src/lib/components/Alerts/thresholdPercent.test.ts b/products/alerts/frontend/logic/thresholdPercent.test.ts
similarity index 100%
rename from frontend/src/lib/components/Alerts/thresholdPercent.test.ts
rename to products/alerts/frontend/logic/thresholdPercent.test.ts
diff --git a/frontend/src/lib/components/Alerts/thresholdPercent.ts b/products/alerts/frontend/logic/thresholdPercent.ts
similarity index 100%
rename from frontend/src/lib/components/Alerts/thresholdPercent.ts
rename to products/alerts/frontend/logic/thresholdPercent.ts
diff --git a/frontend/src/lib/components/Alerts/types.test.ts b/products/alerts/frontend/types.test.ts
similarity index 100%
rename from frontend/src/lib/components/Alerts/types.test.ts
rename to products/alerts/frontend/types.test.ts
diff --git a/frontend/src/lib/components/Alerts/types.ts b/products/alerts/frontend/types.ts
similarity index 100%
rename from frontend/src/lib/components/Alerts/types.ts
rename to products/alerts/frontend/types.ts
diff --git a/frontend/src/lib/components/Alerts/views/AlertDestinationSelector.tsx b/products/alerts/frontend/views/AlertDestinationSelector.tsx
similarity index 90%
rename from frontend/src/lib/components/Alerts/views/AlertDestinationSelector.tsx
rename to products/alerts/frontend/views/AlertDestinationSelector.tsx
index fd4dabb92424..024031d0c066 100644
--- a/frontend/src/lib/components/Alerts/views/AlertDestinationSelector.tsx
+++ b/products/alerts/frontend/views/AlertDestinationSelector.tsx
@@ -1,10 +1,11 @@
import { INSIGHT_ALERT_FIRING_SUB_TEMPLATE_ID } from 'lib/constants'
-import { buildAlertFilterConfig } from 'lib/utils/alerts'
import { LinkedHogFunctions } from 'scenes/hog-functions/list/LinkedHogFunctions'
import { urls } from 'scenes/urls'
import { InsightShortId } from '~/types'
+import { buildAlertFilterConfig } from 'products/alerts/frontend/logic/alertNotifications'
+
export interface AlertDestinationSelectorProps {
alertId: string
insightShortId: InsightShortId
diff --git a/frontend/src/lib/components/Alerts/views/AlertHistoryChart.stories.tsx b/products/alerts/frontend/views/AlertHistoryChart.stories.tsx
similarity index 99%
rename from frontend/src/lib/components/Alerts/views/AlertHistoryChart.stories.tsx
rename to products/alerts/frontend/views/AlertHistoryChart.stories.tsx
index e5e18ca1685b..75d3fba8bb10 100644
--- a/frontend/src/lib/components/Alerts/views/AlertHistoryChart.stories.tsx
+++ b/products/alerts/frontend/views/AlertHistoryChart.stories.tsx
@@ -11,7 +11,7 @@ import {
import type { QueryBasedInsightModel } from '~/types'
import type { UserBasicType } from '~/types'
-import { CHART_CHECKS_LIMIT } from '../alertLogic'
+import { CHART_CHECKS_LIMIT } from '../logic/alertLogic'
import type { AlertType } from '../types'
import { AlertHistoryChart, type AlertHistoryChartPoint } from './AlertHistoryChart'
diff --git a/frontend/src/lib/components/Alerts/views/AlertHistoryChart.tsx b/products/alerts/frontend/views/AlertHistoryChart.tsx
similarity index 99%
rename from frontend/src/lib/components/Alerts/views/AlertHistoryChart.tsx
rename to products/alerts/frontend/views/AlertHistoryChart.tsx
index 08f15326638f..af38d9f992ec 100644
--- a/frontend/src/lib/components/Alerts/views/AlertHistoryChart.tsx
+++ b/products/alerts/frontend/views/AlertHistoryChart.tsx
@@ -8,7 +8,7 @@ import { pluralize } from 'lib/utils/strings'
import { InsightThresholdType } from '~/queries/schema/schema-general'
-import type { AlertHistoryChartPoint } from '../alertLogic'
+import type { AlertHistoryChartPoint } from '../logic/alertLogic'
import type { AlertType } from '../types'
export type { AlertHistoryChartPoint }
diff --git a/frontend/src/lib/components/Alerts/views/AlertHistorySection.tsx b/products/alerts/frontend/views/AlertHistorySection.tsx
similarity index 98%
rename from frontend/src/lib/components/Alerts/views/AlertHistorySection.tsx
rename to products/alerts/frontend/views/AlertHistorySection.tsx
index f12e3ff8ea6c..11d0eef6b98b 100644
--- a/frontend/src/lib/components/Alerts/views/AlertHistorySection.tsx
+++ b/products/alerts/frontend/views/AlertHistorySection.tsx
@@ -14,8 +14,6 @@ import {
} from '@posthog/lemon-ui'
import type { LemonTableColumn } from '@posthog/lemon-ui'
-import { AlertHistoryChart } from 'lib/components/Alerts/views/AlertHistoryChart'
-import { AlertStateIndicator } from 'lib/components/Alerts/views/ManageAlertsModal'
import { EmptyMessage } from 'lib/components/EmptyMessage/EmptyMessage'
import { TZLabel } from 'lib/components/TZLabel'
import { dayjs } from 'lib/dayjs'
@@ -23,7 +21,10 @@ import { IconOpenInNew } from 'lib/lemon-ui/icons'
import { formatDate } from 'lib/utils/datetime'
import { humanFriendlyNumber } from 'lib/utils/numbers'
-import { alertLogic, CHART_CHECKS_LIMIT, TABLE_CHECKS_PAGE_SIZE } from '../alertLogic'
+import { AlertHistoryChart } from 'products/alerts/frontend/views/AlertHistoryChart'
+import { AlertStateIndicator } from 'products/alerts/frontend/views/ManageAlertsModal'
+
+import { alertLogic, CHART_CHECKS_LIMIT, TABLE_CHECKS_PAGE_SIZE } from '../logic/alertLogic'
import { isAnyRowHogQLConfig } from '../types'
import type { AlertCheck, AlertType, InvestigationVerdict } from '../types'
diff --git a/frontend/src/lib/components/Alerts/views/Alerts.tsx b/products/alerts/frontend/views/Alerts.tsx
similarity index 97%
rename from frontend/src/lib/components/Alerts/views/Alerts.tsx
rename to products/alerts/frontend/views/Alerts.tsx
index 5ce7662f0115..856028739688 100644
--- a/frontend/src/lib/components/Alerts/views/Alerts.tsx
+++ b/products/alerts/frontend/views/Alerts.tsx
@@ -13,13 +13,13 @@ import { LemonTableLink } from 'lib/lemon-ui/LemonTable/LemonTableLink'
import { urls } from 'scenes/urls'
import { ProductKey } from '~/queries/schema/schema-general'
+import { AlertState } from '~/queries/schema/schema-general'
import { alertIntervalDisplayLabel } from 'products/alerts/frontend/logic/alertIntervalHelpers'
-import { AlertState } from '../../../../queries/schema/schema-general'
-import { alertLogic } from '../alertLogic'
-import { AlertsFiltersBar } from '../AlertsFiltersBar'
-import { alertsLogic } from '../alertsLogic'
+import { AlertsFiltersBar } from '../components/AlertsFiltersBar'
+import { alertLogic } from '../logic/alertLogic'
+import { alertsLogic } from '../logic/alertsLogic'
import { AlertType } from '../types'
import { EditAlertModal } from './EditAlertModal'
import { AlertStateIndicator } from './ManageAlertsModal'
diff --git a/frontend/src/lib/components/Alerts/views/DetectorSelector.tsx b/products/alerts/frontend/views/DetectorSelector.tsx
similarity index 100%
rename from frontend/src/lib/components/Alerts/views/DetectorSelector.tsx
rename to products/alerts/frontend/views/DetectorSelector.tsx
diff --git a/frontend/src/lib/components/Alerts/views/EditAlertModal.tsx b/products/alerts/frontend/views/EditAlertModal.tsx
similarity index 97%
rename from frontend/src/lib/components/Alerts/views/EditAlertModal.tsx
rename to products/alerts/frontend/views/EditAlertModal.tsx
index 2bbb157ba802..05934657e74d 100644
--- a/frontend/src/lib/components/Alerts/views/EditAlertModal.tsx
+++ b/products/alerts/frontend/views/EditAlertModal.tsx
@@ -28,12 +28,12 @@ import { AlertIntervalRow } from 'products/alerts/frontend/components/editAlertM
import { AlertNotificationSection } from 'products/alerts/frontend/components/editAlertModal/AlertNotificationSection'
import { isSubDailyAlertInterval } from 'products/alerts/frontend/logic/alertIntervalHelpers'
-import { alertFormLogic, canCheckOngoingInterval } from '../alertFormLogic'
-import { alertLogic } from '../alertLogic'
-import { alertNotificationLogic } from '../alertNotificationLogic'
-import { isNextPlannedEvaluationStale } from '../alertSchedulingStale'
-import { insightAlertsLogic } from '../insightAlertsLogic'
-import { SnoozeButton } from '../SnoozeButton'
+import { SnoozeButton } from '../components/SnoozeButton'
+import { alertFormLogic, canCheckOngoingInterval } from '../logic/alertFormLogic'
+import { alertLogic } from '../logic/alertLogic'
+import { alertNotificationLogic } from '../logic/alertNotificationLogic'
+import { isNextPlannedEvaluationStale } from '../logic/alertSchedulingStale'
+import { insightAlertsLogic } from '../logic/insightAlertsLogic'
import { supportsAnomalyDetection, supportsOngoingInterval } from '../types'
import type { AlertType } from '../types'
import { AlertHistorySection, AlertHistorySectionSkeleton } from './AlertHistorySection'
diff --git a/frontend/src/lib/components/Alerts/views/InlineAlertNotifications.tsx b/products/alerts/frontend/views/InlineAlertNotifications.tsx
similarity index 99%
rename from frontend/src/lib/components/Alerts/views/InlineAlertNotifications.tsx
rename to products/alerts/frontend/views/InlineAlertNotifications.tsx
index c23229a015ea..e44e73faff7c 100644
--- a/frontend/src/lib/components/Alerts/views/InlineAlertNotifications.tsx
+++ b/products/alerts/frontend/views/InlineAlertNotifications.tsx
@@ -6,18 +6,19 @@ import { LemonButton, LemonInput, LemonSelect, LemonSkeleton, LemonTag } from '@
import { SlackChannelPicker, SlackNotConfiguredBanner } from 'lib/integrations/SlackIntegrationHelpers'
import { slackIntegrationLogic } from 'lib/integrations/slackIntegrationLogic'
+import { urls } from 'scenes/urls'
+
+import { HogFunctionType, SlackChannelType } from '~/types'
+
import {
ALERT_NOTIFICATION_TYPE_DISCORD,
ALERT_NOTIFICATION_TYPE_MICROSOFT_TEAMS,
ALERT_NOTIFICATION_TYPE_SLACK,
ALERT_NOTIFICATION_TYPE_WEBHOOK,
PendingAlertNotification,
-} from 'lib/utils/alerts'
-import { urls } from 'scenes/urls'
-
-import { HogFunctionType, SlackChannelType } from '~/types'
+} from 'products/alerts/frontend/logic/alertNotifications'
-import { ALERT_NOTIFICATION_TYPE_OPTIONS, alertNotificationLogic } from '../alertNotificationLogic'
+import { ALERT_NOTIFICATION_TYPE_OPTIONS, alertNotificationLogic } from '../logic/alertNotificationLogic'
function resolveSlackChannelName(channelValue: string, slackChannels: SlackChannelType[]): string | null {
const channelId = channelValue.split('|')[0]
diff --git a/frontend/src/lib/components/Alerts/views/ManageAlertsModal.tsx b/products/alerts/frontend/views/ManageAlertsModal.tsx
similarity index 99%
rename from frontend/src/lib/components/Alerts/views/ManageAlertsModal.tsx
rename to products/alerts/frontend/views/ManageAlertsModal.tsx
index 4e286294d095..000b6568aa30 100644
--- a/frontend/src/lib/components/Alerts/views/ManageAlertsModal.tsx
+++ b/products/alerts/frontend/views/ManageAlertsModal.tsx
@@ -15,7 +15,7 @@ import { urls } from 'scenes/urls'
import { AlertState, InsightThresholdType } from '~/queries/schema/schema-general'
import { InsightShortId } from '~/types'
-import { InsightAlertsLogicProps, alertsUnsupportedReason, insightAlertsLogic } from '../insightAlertsLogic'
+import { InsightAlertsLogicProps, alertsUnsupportedReason, insightAlertsLogic } from '../logic/insightAlertsLogic'
import { AlertType } from '../types'
export function AlertStateIndicator({ alert }: { alert: AlertType }): JSX.Element {
diff --git a/frontend/src/lib/components/Alerts/views/SimulationSummary.tsx b/products/alerts/frontend/views/SimulationSummary.tsx
similarity index 100%
rename from frontend/src/lib/components/Alerts/views/SimulationSummary.tsx
rename to products/alerts/frontend/views/SimulationSummary.tsx
diff --git a/products/alerts/package.json b/products/alerts/package.json
index d005c8c1ff7d..8b845ec1ca61 100644
--- a/products/alerts/package.json
+++ b/products/alerts/package.json
@@ -5,6 +5,10 @@
},
"dependencies": {
"kea": "catalog:",
+ "kea-forms": "catalog:",
+ "kea-loaders": "catalog:",
+ "kea-router": "catalog:",
+ "kea-subscriptions": "catalog:",
"posthog-js": "catalog:"
},
"devDependencies": {
@@ -12,11 +16,14 @@
"kea-test-utils": "catalog:"
},
"peerDependencies": {
+ "@posthog/brand": "catalog:",
"@posthog/icons": "catalog:",
"@posthog/lemon-ui": "*",
"@types/react": "*",
- "kea-forms": "*",
+ "chartjs-plugin-annotation": "*",
+ "fast-deep-equal": "*",
"react": "*",
- "typescript": "catalog:*"
+ "typescript": "catalog:*",
+ "zod": "*"
}
}
diff --git a/products/product_analytics/frontend/insights/trends/shared/TrendsAlertOverlays.tsx b/products/product_analytics/frontend/insights/trends/shared/TrendsAlertOverlays.tsx
index bb5ab5e9ab75..c26808d26f96 100644
--- a/products/product_analytics/frontend/insights/trends/shared/TrendsAlertOverlays.tsx
+++ b/products/product_analytics/frontend/insights/trends/shared/TrendsAlertOverlays.tsx
@@ -3,11 +3,12 @@ import React, { useMemo } from 'react'
import { AnomalyPointsLayer, ReferenceLines } from '@posthog/quill-charts'
-import { insightAlertsLogic } from 'lib/components/Alerts/insightAlertsLogic'
import type { IndexedTrendResult } from 'scenes/trends/types'
import type { InsightLogicProps } from '~/types'
+import { insightAlertsLogic } from 'products/alerts/frontend/logic/insightAlertsLogic'
+
import { buildAnomalyMarkers } from './anomalyPointsAdapter'
import { alertThresholdsToReferenceLines } from './goalLinesAdapter'
diff --git a/products/product_analytics/frontend/insights/trends/shared/anomalyPointsAdapter.test.ts b/products/product_analytics/frontend/insights/trends/shared/anomalyPointsAdapter.test.ts
index 19e6ca5da499..3492d07d1409 100644
--- a/products/product_analytics/frontend/insights/trends/shared/anomalyPointsAdapter.test.ts
+++ b/products/product_analytics/frontend/insights/trends/shared/anomalyPointsAdapter.test.ts
@@ -1,8 +1,9 @@
-import type { AnomalyPoint } from 'lib/components/Alerts/types'
import type { IndexedTrendResult } from 'scenes/trends/types'
import { EntityTypes } from '~/types'
+import type { AnomalyPoint } from 'products/alerts/frontend/types'
+
import { buildAnomalyMarkers } from './anomalyPointsAdapter'
function makeResult(overrides: Partial<IndexedTrendResult> = {}): IndexedTrendResult {
diff --git a/products/product_analytics/frontend/insights/trends/shared/anomalyPointsAdapter.ts b/products/product_analytics/frontend/insights/trends/shared/anomalyPointsAdapter.ts
index 875dabf2a10d..67f574ed47c5 100644
--- a/products/product_analytics/frontend/insights/trends/shared/anomalyPointsAdapter.ts
+++ b/products/product_analytics/frontend/insights/trends/shared/anomalyPointsAdapter.ts
@@ -1,8 +1,9 @@
import type { AnomalyMarker as BaseAnomalyMarker } from '@posthog/quill-charts'
-import type { AnomalyPoint } from 'lib/components/Alerts/types'
import type { IndexedTrendResult } from 'scenes/trends/types'
+import type { AnomalyPoint } from 'products/alerts/frontend/types'
+
export interface AnomalyMarker extends BaseAnomalyMarker {
/** Originating alert anomaly score (0..1) if available. */
score: number | null
diff --git a/products/product_analytics/manifest.tsx b/products/product_analytics/manifest.tsx
index f750260280f7..9cbc69ac7d6c 100644
--- a/products/product_analytics/manifest.tsx
+++ b/products/product_analytics/manifest.tsx
@@ -1,6 +1,5 @@
import { combineUrl } from 'kea-router'
-import { AlertType } from 'lib/components/Alerts/types'
import { FEATURE_FLAGS, INSIGHT_VISUAL_ORDER } from 'lib/constants'
import { urls } from 'scenes/urls'
@@ -18,6 +17,8 @@ import {
} from '~/queries/schema/schema-general'
import { isDataTableNode, isDataVisualizationNode, isHogQLQuery } from '~/queries/utils'
+import { AlertType } from 'products/alerts/frontend/types'
+
import {
DashboardType,
FileSystemIconColor,