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(signals): add alert scope toggle to inbox sources settings (#128974)

posthog[bot]b5603f44f0f5
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 75e53d3a06dc..aa38de114349 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -232,6 +232,7 @@ export const FEATURE_FLAGS = {
SETTINGS_PERSONS_JOIN_MODE: 'settings-persons-join-mode', // owner: #team-analytics-platform
SETTINGS_SESSION_TABLE_VERSION: 'settings-session-table-version', // owner: #team-analytics-platform
SETTINGS_WEB_ANALYTICS_PRE_AGGREGATED_TABLES: 'web-analytics-pre-aggregated-tables', // owner: @lricoy #team-web-analytics
+ SIGNALS_ANALYTICS_ALL_ALERTS: 'signals-analytics-all-alerts', // owner: #team-self-driving, lets the product analytics source send every firing insight alert to the inbox (also checked server-side)
SIGNALS_EXPECTED_IMPACT_DISPLAY: 'signals-expected-impact', // owner: #team-self-driving, person-level display gate for metric follow-up graphs and actions
SIGNALS_INBOX_VALUE_SUMMARY: 'signals-inbox-value-summary', // owner: #team-self-driving
SIGNALS_PR_REFUNDS: 'signals-pr-refunds', // owner: #team-self-driving, gates the inbox PR refund flow (also checked server-side)
diff --git a/products/signals/frontend/inbox/components/config/AgentsRoster.tsx b/products/signals/frontend/inbox/components/config/AgentsRoster.tsx
index 270ee7fe231c..38346bf63a3f 100644
--- a/products/signals/frontend/inbox/components/config/AgentsRoster.tsx
+++ b/products/signals/frontend/inbox/components/config/AgentsRoster.tsx
@@ -15,6 +15,7 @@ import {
import { FlaggedFeature } from 'lib/components/FlaggedFeature'
import { FEATURE_FLAGS } from 'lib/constants'
+import { LemonRadio } from 'lib/lemon-ui/LemonRadio'
import { LemonTagType } from 'lib/lemon-ui/LemonTag/LemonTag'
import type { CISignalsSyncStatusEnumApi } from 'products/engineering_analytics/frontend/generated/api.schemas'
@@ -23,7 +24,13 @@ import { isExternalSignalSource } from '../../externalSignalSources'
import { sourceSteeringIsSet } from '../../logics/sourceSteeringModalLogic'
import { signalSourcesLogic } from '../../signalSourcesLogic'
import type { SourceProductDataStatus, SourceProductStatus } from '../../signalSourcesLogic'
-import { SignalSourceConfig, SignalSourceConfigStatus, SignalSourceType, linearTeamIdsFromConfig } from '../../types'
+import {
+ SignalAlertScope,
+ SignalSourceConfig,
+ SignalSourceConfigStatus,
+ SignalSourceType,
+ linearTeamIdsFromConfig,
+} from '../../types'
import { SourceSpendLabel } from '../spend/SourceSpendLabel'
import { AGENT_ROSTER_GROUPS, AgentRosterDefinition, AgentRosterGroup, AgentRosterSource } from './agentRosterMeta'
import { DataSourceSetupModal } from './DataSourceSetupModal'
@@ -107,6 +114,33 @@ interface SourceFilters {
disabledReason?: string
}
+/** Product analytics only: which firing alerts become signals. */
+interface SourceAlertScope {
+ value: SignalAlertScope
+ onChange: (value: SignalAlertScope) => void
+ /** False before the source was ever turned on, as the choice is stored on its config row. */
+ canChange: boolean
+ disabledReason?: string
+}
+
+// Replaces the source detail while the alert scope control shows, since the default copy only covers investigated alerts.
+const ALERT_SCOPE_SOURCE_DETAIL = 'Fires when an insight alert goes off. Choose which alerts count below.'
+
+const ALERT_SCOPE_OPTIONS: { value: SignalAlertScope; label: string; description: string; dataAttr: string }[] = [
+ {
+ value: SignalAlertScope.InvestigatedOnly,
+ label: 'Investigated alerts only',
+ description: 'Only alerts where you turned on the investigation agent, once the agent confirms the change.',
+ dataAttr: 'signal-source-alert-scope-investigated-only',
+ },
+ {
+ value: SignalAlertScope.AllFiringAlerts,
+ label: 'All firing alerts',
+ description: 'Every insight alert that fires, including alerts without the investigation agent.',
+ dataAttr: 'signal-source-alert-scope-all-firing-alerts',
+ },
+]
+
/** Per-source derived state assembled by `AgentsRoster` from `signalSourcesLogic`. */
interface AgentSourceState {
armed: boolean
@@ -209,6 +243,7 @@ interface ExpansionProps {
onEnableProduct: (product: SourceProductStatus) => void
onToggleEntity: (entityId: string) => void
filters?: SourceFilters
+ alertScope?: SourceAlertScope
/** Opens the steering form. Only set for steerable sources that are on with a persisted config row. */
onSteer?: () => void
onRetryData: () => void
@@ -278,6 +313,7 @@ function Expansion({
onEnableProduct,
onToggleEntity,
filters,
+ alertScope,
onSteer,
onRetryData,
}: ExpansionProps): JSX.Element {
@@ -316,7 +352,7 @@ function Expansion({
{/* Each part is its own element: a page-translation extension detaches a bare text
node, and React then throws when the link next to it appears or disappears. */}
<p className="mb-0 text-xs text-secondary">
- <span>{agent.detail}</span>
+ <span>{alertScope ? ALERT_SCOPE_SOURCE_DETAIL : agent.detail}</span>
{!hasMetaLine && docsLink ? <span> {docsLink}</span> : null}
</p>
@@ -373,6 +409,31 @@ function Expansion({
</LemonButton>
</div>
)}
+ {alertScope && (
+ <div className="flex flex-col gap-1.5 pt-1">
+ <span className="text-xs font-semibold text-default">Alerts that become signals</span>
+ {alertScope.canChange ? (
+ <LemonRadio
+ value={alertScope.value}
+ onChange={alertScope.onChange}
+ aria-label="Alerts that become signals"
+ data-attr="signal-source-alert-scope"
+ radioPosition="top"
+ options={ALERT_SCOPE_OPTIONS.map(({ value, label, description, dataAttr }) => ({
+ value,
+ label,
+ description,
+ disabledReason: alertScope.disabledReason,
+ 'data-attr': dataAttr,
+ }))}
+ />
+ ) : (
+ <span className="text-xs text-secondary">
+ Turn on this source to choose which alerts become signals.
+ </span>
+ )}
+ </div>
+ )}
</div>
{state.entitiesLoading ? (
@@ -462,6 +523,7 @@ interface AgentRowProps {
onToggleEntity: (source: AgentRosterSource, entityId: string) => void
onEnableProduct: (product: SourceProductStatus) => void
filters?: SourceFilters
+ alertScope?: SourceAlertScope
onSteer?: () => void
onRetryData: () => void
}
@@ -477,6 +539,7 @@ const AgentRow = memo(function AgentRow({
onToggleEntity,
onEnableProduct,
filters,
+ alertScope,
onSteer,
onRetryData,
}: AgentRowProps): JSX.Element {
@@ -600,6 +663,7 @@ const AgentRow = memo(function AgentRow({
onEnableProduct={onEnableProduct}
onToggleEntity={(entityId) => onToggleEntity(agent.source, entityId)}
filters={filters}
+ alertScope={alertScope}
onSteer={onSteer}
onRetryData={onRetryData}
/>
@@ -648,6 +712,9 @@ export function AgentsRoster(): JSX.Element {
sourceConfigsLoadFailed,
sourceConfigsLoading,
linearTeamsPicker,
+ analyticsAlertScope,
+ savingAnalyticsAlertScope,
+ featureFlags,
} = useValues(signalSourcesLogic)
const {
loadSources,
@@ -665,6 +732,7 @@ export function AgentsRoster(): JSX.Element {
enableSourceProduct,
loadProductDataEvents,
loadSourceConfigs,
+ setAnalyticsAlertScope,
} = useActions(signalSourcesLogic)
const [expandedSource, setExpandedSource] = useState<AgentRosterSource | null>(null)
// Which modal is open is a view concern; the form and save live in sourceSteeringModalLogic.
@@ -879,6 +947,30 @@ export function AgentsRoster(): JSX.Element {
[toggleScannerSignals, toggleErrorTrackingType]
)
+ const showAlertScope = !!featureFlags[FEATURE_FLAGS.SIGNALS_ANALYTICS_ALL_ALERTS]
+ const alertScope = useMemo((): SourceAlertScope | undefined => {
+ if (!showAlertScope) {
+ return undefined
+ }
+ const blockedReason = stateFor('analytics').blockedReason
+ return {
+ value: analyticsAlertScope,
+ onChange: setAnalyticsAlertScope,
+ canChange: !!anomalyInvestigationConfig && !anomalyInvestigationConfig.id.startsWith('new_'),
+ disabledReason:
+ blockedReason ??
+ (savingAnalyticsAlertScope !== null || isAnomalyInvestigationToggling ? 'Saving' : undefined),
+ }
+ }, [
+ showAlertScope,
+ stateFor,
+ analyticsAlertScope,
+ setAnalyticsAlertScope,
+ anomalyInvestigationConfig,
+ savingAnalyticsAlertScope,
+ isAnomalyInvestigationToggling,
+ ])
+
const renderAgent = useCallback(
(agent: AgentRosterDefinition): JSX.Element => {
const state = stateFor(agent.source)
@@ -921,6 +1013,7 @@ export function AgentsRoster(): JSX.Element {
onToggleEntity={handleToggleEntity}
onEnableProduct={(product) => product.enablement && enableSourceProduct(product.enablement)}
filters={filters}
+ alertScope={agent.source === 'analytics' ? alertScope : undefined}
onSteer={
steeringConfigs
? () => setSteeringTarget({ configs: steeringConfigs, label: agent.label })
@@ -943,6 +1036,7 @@ export function AgentsRoster(): JSX.Element {
handleToggleEntity,
enableSourceProduct,
loadProductDataEvents,
+ alertScope,
]
)
diff --git a/products/signals/frontend/inbox/components/tabs/SourcesTab.stories.tsx b/products/signals/frontend/inbox/components/tabs/SourcesTab.stories.tsx
index c822c6f5029d..befd5d555670 100644
--- a/products/signals/frontend/inbox/components/tabs/SourcesTab.stories.tsx
+++ b/products/signals/frontend/inbox/components/tabs/SourcesTab.stories.tsx
@@ -6,6 +6,7 @@ import userEvent from '@testing-library/user-event'
import { useActions } from 'kea'
import { useEffect } from 'react'
+import { FEATURE_FLAGS } from 'lib/constants'
import { teamLogic } from 'scenes/teamLogic'
import { useStorybookMocks } from '~/mocks/browser'
@@ -440,6 +441,19 @@ export const ErrorTrackingExpanded: Story = {
},
}
+/** Product analytics opened with the all-alerts flag on: the choice between investigated alerts and every firing alert. */
+export const ProductAnalyticsAlertScope: Story = {
+ args: { productAnalyticsArmed: true },
+ parameters: {
+ featureFlags: [FEATURE_FLAGS.SIGNALS_ANALYTICS_ALL_ALERTS],
+ testOptions: { snapshotBrowsers: [] },
+ },
+ play: async ({ canvasElement }) => {
+ const [expandButton] = await within(canvasElement).findAllByLabelText('Expand Product analytics')
+ await userEvent.click(expandButton)
+ },
+}
+
/** Connected tools stay in the roster even when they are off. */
export const ExternalSourcesConnected: Story = {
args: { externalConnections: true },
diff --git a/products/signals/frontend/inbox/inboxAnalytics.ts b/products/signals/frontend/inbox/inboxAnalytics.ts
index b0bb3394710d..0cbb2d9214d5 100644
--- a/products/signals/frontend/inbox/inboxAnalytics.ts
+++ b/products/signals/frontend/inbox/inboxAnalytics.ts
@@ -10,10 +10,13 @@ import type { ReportTaskPurpose } from './components/detail/artefactTypes'
import type { ReportDiscussionIntent } from './inboxTaskKickoffLogic'
import {
InboxReportSectionKey,
+ SignalAlertScope,
SignalReport,
SignalReportActionability,
SignalReportPriority,
SignalRunKind,
+ SignalSourceProduct,
+ SignalSourceType,
} from './types'
import { rankingPillLifts } from './utils/reportOrdering'
import { reportPullRequests } from './utils/reportPullRequests'
@@ -65,6 +68,7 @@ export const INBOX_EVENTS = {
SOURCE_CATALOG_SOURCE_SELECTED: 'Signal source catalog source selected',
SOURCE_STEERING_CHANGED: 'Signal source steering changed',
SOURCE_FILTERS_CHANGED: 'Signal source filters changed',
+ SOURCE_ALERT_SCOPE_CHANGED: 'Signal source alert scope changed',
// Scout-troop management. Names and property shapes match the desktop app one-for-one so both
// clients union in one project; desktop sends no `inbox_client`, so its rows read as null.
SCOUT_FLEET_VIEWED: 'Scout fleet viewed',
@@ -950,6 +954,24 @@ export function captureSignalSourceFiltersChanged(params: {
})
}
+/**
+ * The product analytics source switched between investigated alerts only and all firing alerts.
+ * Fired once the request settles, so `success` separates a saved change from a rejected one.
+ */
+export function captureSignalSourceAlertScopeChanged(params: {
+ alertScope: SignalAlertScope
+ previousAlertScope: SignalAlertScope
+ success: boolean
+}): void {
+ captureInboxEvent(INBOX_EVENTS.SOURCE_ALERT_SCOPE_CHANGED, {
+ source_product: SignalSourceProduct.Analytics,
+ source_type: SignalSourceType.AnomalyInvestigation,
+ alert_scope: params.alertScope,
+ previous_alert_scope: params.previousAlertScope,
+ success: params.success,
+ })
+}
+
/**
* Outcome of a task-kickoff action, fired once the request settles. Pairs with the press event on
* `report_id` + `action_type`. `blocked` means we never issued the request (no AI consent), which is
diff --git a/products/signals/frontend/inbox/signalSourcesLogic.test.ts b/products/signals/frontend/inbox/signalSourcesLogic.test.ts
index a9beefe58e0f..640cc7658133 100644
--- a/products/signals/frontend/inbox/signalSourcesLogic.test.ts
+++ b/products/signals/frontend/inbox/signalSourcesLogic.test.ts
@@ -26,7 +26,7 @@ import { sourcesDataLogic } from 'products/data_warehouse/frontend/shared/logics
import * as signalsApi from '../generated/api'
import type { InboxOnboardingDraftApi, InboxOnboardingStateApi, SignalSourceConfigApi } from '../generated/api.schemas'
import { signalSourcesLogic } from './signalSourcesLogic'
-import { SignalSourceProduct, SignalSourceType } from './types'
+import { SignalAlertScope, SignalSourceProduct, SignalSourceType } from './types'
const githubSchema = (id: string, name: string): ExternalDataSourceSchema => ({
id,
@@ -648,6 +648,42 @@ describe('signalSourcesLogic', () => {
toastError.mockRestore()
})
+ it.each([
+ { outcome: 'saves', fails: false, expectedScope: SignalAlertScope.AllFiringAlerts },
+ { outcome: 'reverts', fails: true, expectedScope: SignalAlertScope.InvestigatedOnly },
+ ])('$outcome the product analytics alert scope', async ({ fails, expectedScope }) => {
+ const analyticsConfig = {
+ ...githubIssuesConfig,
+ id: 'config-analytics',
+ source_product: SignalSourceProduct.Analytics,
+ source_type: SignalSourceType.AnomalyInvestigation,
+ config: { steering: 'Skip weekend dips' },
+ }
+ const updateSourceConfig = jest
+ .spyOn(signalsApi, 'signalsSourceConfigsPartialUpdate')
+ .mockImplementation(async () => {
+ if (fails) {
+ throw { detail: 'Request failed.' }
+ }
+ return {
+ ...analyticsConfig,
+ config: { ...analyticsConfig.config, alert_scope: SignalAlertScope.AllFiringAlerts },
+ } as SignalSourceConfigApi
+ })
+ logic.actions.loadSourceConfigsSuccess([analyticsConfig])
+
+ logic.actions.setAnalyticsAlertScope(SignalAlertScope.AllFiringAlerts)
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(updateSourceConfig).toHaveBeenCalledWith(expect.any(String), 'config-analytics', {
+ config_set: { alert_scope: SignalAlertScope.AllFiringAlerts },
+ })
+ expect(logic.values.analyticsAlertScope).toBe(expectedScope)
+ expect(logic.values.savingAnalyticsAlertScope).toBeNull()
+ expect(logic.values.anomalyInvestigationConfig?.config.steering).toBe('Skip weekend dips')
+ updateSourceConfig.mockRestore()
+ })
+
it('uses only eval reports for the AI observability signal source', async () => {
const createSourceConfig = jest.spyOn(signalsApi, 'signalsSourceConfigsCreate').mockResolvedValue({
id: 'config-evaluation-reports',
diff --git a/products/signals/frontend/inbox/signalSourcesLogic.ts b/products/signals/frontend/inbox/signalSourcesLogic.ts
index b26fd8f73f5c..86fe412bfaf0 100644
--- a/products/signals/frontend/inbox/signalSourcesLogic.ts
+++ b/products/signals/frontend/inbox/signalSourcesLogic.ts
@@ -54,6 +54,7 @@ import { EXTERNAL_SIGNAL_SOURCES, ExternalSignalSource, isExternalSignalSource }
import {
SignalSourceCatalogOrigin,
SignalSourceToggleFailureReason,
+ captureSignalSourceAlertScopeChanged,
captureSignalSourceCatalogOpened,
captureSignalSourceCatalogSourceSelected,
captureSignalSourceConfigsLoadFailed,
@@ -67,7 +68,15 @@ import {
SourceRecommendationInput,
recommendSources,
} from './sourceRecommendations'
-import { SOURCE_STEERING_KEY, SignalSourceConfig, SignalSourceConfigStatus, ToggleSignalSourceParams } from './types'
+import {
+ SOURCE_ALERT_SCOPE_KEY,
+ SOURCE_STEERING_KEY,
+ SignalAlertScope,
+ SignalSourceConfig,
+ SignalSourceConfigStatus,
+ ToggleSignalSourceParams,
+ alertScopeFromConfig,
+} from './types'
/** product_enablement recipe names for products that back a signal source. */
export type SourceProductEnablement = 'session_replay' | 'error_tracking' | 'conversations'
@@ -296,6 +305,7 @@ export interface signalSourcesLogicValues {
dataWarehouseSourcesLoading: boolean // sourcesDataLogic
sourcesLoadError: boolean // sourcesDataLogic
currentTeam: TeamPublicType | TeamType | null // teamLogic
+ analyticsAlertScope: SignalAlertScope
anomalyInvestigationConfig: SignalSourceConfig | null
ciSignalsConfig: CISignalsConfigApi | null
ciSignalsConfigLoading: boolean
@@ -341,6 +351,7 @@ export interface signalSourcesLogicValues {
productStatusBySource: Partial<Record<AgentRosterSource, SourceProductStatus>>
recommendedSources: SourceRecommendation[]
rosterGroups: AgentRosterGroup[]
+ savingAnalyticsAlertScope: SignalAlertScope | null
scannerInventoryKnown: boolean
sourceCatalog: SourceCatalogGroup[]
sourceCategory: string
@@ -506,6 +517,12 @@ export interface signalSourcesLogicActions {
enabled: boolean
}
}
+ setAnalyticsAlertScope: (alertScope: SignalAlertScope) => {
+ alertScope: SignalAlertScope
+ }
+ setAnalyticsAlertScopeComplete: () => {
+ value: true
+ }
setDataWarehouseSourceEnabled: (
source: WarehouseBackedSource,
enabled: boolean
@@ -970,6 +987,10 @@ export interface signalSourcesLogicMeta {
isEvalReportsToggling: (togglingSourceKeys: Set<string>) => boolean
anomalyInvestigationConfig: (sourceConfigs: SignalSourceConfig[] | null) => SignalSourceConfig | null
isAnomalyInvestigationToggling: (togglingSourceKeys: Set<string>) => boolean
+ analyticsAlertScope: (
+ savingAnalyticsAlertScope: SignalAlertScope | null,
+ anomalyInvestigationConfig: SignalSourceConfig | null
+ ) => SignalAlertScope
productStatusBySource: (
currentTeam: TeamPublicType | TeamType | null,
productDataEvents: Set<string> | null,
@@ -1051,6 +1072,8 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([
toggleEvalReports: true,
toggleConversations: true,
toggleAnomalyInvestigation: true,
+ setAnalyticsAlertScope: (alertScope: SignalAlertScope) => ({ alertScope }),
+ setAnalyticsAlertScopeComplete: true,
enableSourceProduct: (enablement: SourceProductEnablement) => ({ enablement }),
enableSourceProductComplete: true,
setErrorTrackingHasIssues: (hasIssues: boolean | null) => ({ hasIssues }),
@@ -1205,6 +1228,14 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([
enableSourceProductComplete: () => null,
},
],
+ // The scope being saved, so the control shows the choice and stays disabled until the save settles.
+ savingAnalyticsAlertScope: [
+ null as SignalAlertScope | null,
+ {
+ setAnalyticsAlertScope: (_, { alertScope }) => alertScope,
+ setAnalyticsAlertScopeComplete: () => null,
+ },
+ ],
productDataEventsFailed: [
false,
{
@@ -1661,6 +1692,14 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([
(keys: Set<string>): boolean =>
keys.has(`${SignalSourceProduct.Analytics}_${SignalSourceType.AnomalyInvestigation}`),
],
+ analyticsAlertScope: [
+ (s) => [s.savingAnalyticsAlertScope, s.anomalyInvestigationConfig],
+ (
+ savingAnalyticsAlertScope: SignalAlertScope | null,
+ anomalyInvestigationConfig: SignalSourceConfig | null
+ ): SignalAlertScope =>
+ savingAnalyticsAlertScope ?? alertScopeFromConfig(anomalyInvestigationConfig?.config),
+ ],
productStatusBySource: [
(s) => [
s.currentTeam,
@@ -2298,6 +2337,42 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([
enabled: desiredEnabled,
})
},
+ setAnalyticsAlertScope: async ({ alertScope }) => {
+ const config = values.anomalyInvestigationConfig
+ const previousAlertScope = alertScopeFromConfig(config?.config)
+ // The write needs a persisted row. The control asks for the source to be turned on first.
+ if (!config || config.id.startsWith('new_') || alertScope === previousAlertScope) {
+ actions.setAnalyticsAlertScopeComplete()
+ return
+ }
+ try {
+ const updated = await signalsSourceConfigsPartialUpdate(
+ String(ApiConfig.getCurrentProjectId()),
+ config.id,
+ { config_set: { [SOURCE_ALERT_SCOPE_KEY]: alertScope } }
+ )
+ // Read the row again: an on/off toggle may have changed it while this save ran.
+ const latest = values.anomalyInvestigationConfig ?? config
+ actions.replaceSourceConfig({
+ ...latest,
+ config: updated.config ?? latest.config,
+ updated_at: updated.updated_at,
+ })
+ captureSignalSourceAlertScopeChanged({ alertScope, previousAlertScope, success: true })
+ lemonToast.success(
+ alertScope === SignalAlertScope.AllFiringAlerts
+ ? 'Product analytics now turns every firing alert into a signal.'
+ : 'Product analytics now turns only investigated alerts into signals.'
+ )
+ } catch (error: any) {
+ captureSignalSourceAlertScopeChanged({ alertScope, previousAlertScope, success: false })
+ lemonToast.error(
+ error?.detail || error?.message || "Couldn't change which alerts become signals. Try again."
+ )
+ } finally {
+ actions.setAnalyticsAlertScopeComplete()
+ }
+ },
enableSourceProduct: async ({ enablement }) => {
try {
await productEnablementCreate(String(teamLogic.values.currentTeamId), {
diff --git a/products/signals/frontend/inbox/types.ts b/products/signals/frontend/inbox/types.ts
index 5d1cf349f04c..e6673e660136 100644
--- a/products/signals/frontend/inbox/types.ts
+++ b/products/signals/frontend/inbox/types.ts
@@ -247,6 +247,21 @@ export function linearTeamIdsFromConfig(config: Record<string, any> | null | und
return Array.isArray(raw) ? raw.filter((id): id is string => typeof id === 'string' && id.length > 0) : []
}
+/** Product analytics source only: which firing insight alerts become signals. */
+export const SOURCE_ALERT_SCOPE_KEY = 'alert_scope'
+
+export enum SignalAlertScope {
+ InvestigatedOnly = 'investigated_only',
+ AllFiringAlerts = 'all_firing_alerts',
+}
+
+// Anything unknown reads as investigated only, matching the backend's fallback.
+export function alertScopeFromConfig(config: Record<string, any> | null | undefined): SignalAlertScope {
+ return config?.[SOURCE_ALERT_SCOPE_KEY] === SignalAlertScope.AllFiringAlerts
+ ? SignalAlertScope.AllFiringAlerts
+ : SignalAlertScope.InvestigatedOnly
+}
+
// ── Inbox IA: page tabs, report sections, scope ──────────────────────────────
/**