:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(logs): tag customized alert destinations on the alert page (#119822)
Jimmy Zhu761b9646c23c
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 754e099a73a4..b16bb9ee1599 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -10191,9 +10191,9 @@ snapshots:scenes-app-data-warehouse-sql-editor--bi-calculated-measure-editor--light:hash: v1.k794b7964.69c71d482b1b19aa18a81b5ba0fc0bb038d8f3bdc9bdb0a7286c9addb4893dc2.LjgKhmcTELX-Cd50ZnnKmKLTGxv3AH0cD5BfLrBKfQ8scenes-app-data-warehouse-sql-editor--bi-catalog-snapshot--dark:- hash: v1.k794b7964.b52b1342405552a434e059a2c6356149b7eec93c55c0add78e4a4ed498a63351.ZlHoXE5McNiADRhSnXPG4ce1qZdMJK65I4b0fgMdjEk+ hash: v1.k794b7964.72fe89e09caa08343acb8f293445fa34d8aab42ffa4d66b1386551d239ab1108.ww2CgbguWaZTWgUH_9sSwcENmYScEBe4-7UcYnYmKRkscenes-app-data-warehouse-sql-editor--bi-catalog-snapshot--light:- hash: v1.k794b7964.ccee947706656e7bc3bc4f1c83610196346351067b2e406e222f6021180a92b7.WJlU-aUOOEEMQN9SppIHk6yIPbTrU9VrCOSME-hQAjQ+ hash: v1.k794b7964.576484bfd9cb020ba4ecdb91c39a863106414c667414f25da3b81955d768ac3a.8VZRtUu8AQomTvaOT-4N81ZDtUhBPOK7ePXzuzJup30scenes-app-data-warehouse-sql-editor--bi-catalog-source--dark:hash: v1.k794b7964.7f7a8be7f10226665eaef97b037b9f5ba1025186e5820fd53a6e012e1f80a2e8.rTSemg-6VGHCgB7ykDZp81WmDqzNBgzalDpTlQ24BrIscenes-app-data-warehouse-sql-editor--bi-catalog-source--light:diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex 62a69f2a5127..0cf84facff81 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -280,6 +280,7 @@ export const FEATURE_FLAGS = {AI_OBSERVABILITY_TRACE_REDESIGN: 'ai-observability-trace-redesign', // owner: #team-ai-observability, gates the redesigned trace view/** Alert edit modal: check history chart + chart/table toggle (table remains when off). */ALERTS_15_MINUTE_INTERVAL: 'alerts-15-minute-interval', // owner: #team-analytics-platform, gates 15-minute insight alert interval+ ALERTS_DESTINATION_CUSTOMIZATION: 'alerts-destination-customization', // owner: #team-logs, gates the custom message tag and edit notice on logs alert destinationsALERTS_INLINE_NOTIFICATIONS: 'alerts-inline-notifications', // owner: @vdekrijgerALERTS_LLM_DETECTOR: 'alerts-llm-detector', // owner: #team-analytics-platform, gates the AI anomaly detector for insight alertsAMPLITUDE_BATCH_IMPORT_OPTIONS: 'amplitude-batch-import-options', // owner: #team-ingestiondiff --git a/products/alerts/backend/facade/destinations.py b/products/alerts/backend/facade/destinations.pyindex 98e2727cb77a..5ec928cf8ce6 100644--- a/products/alerts/backend/facade/destinations.py+++ b/products/alerts/backend/facade/destinations.py@@ -37,7 +37,13 @@ from ..logic import (destinations,insight_alert_destinations,)-from .contracts import AlertInternalEvent, DeliveryPathChoice, DestinationBucket, DestinationEligibility+from .contracts import (+ AlertInternalEvent,+ DeliveryPathChoice,+ DestinationBucket,+ DestinationEligibility,+ DestinationHoldBack,+)ALERT_NOTIFICATION_FLUSH_TIMEOUT_SECONDS: Final = 10.0@@ -253,6 +259,22 @@ def classify_alert_destinations()+def customized_alert_destination_ids(+ *, team_id: int, alert_id: str, allowed_event_ids: Collection[str]+) -> frozenset[UUID]:+ """The destination functions of one alert that send something other than the stock message.++ A refused address is not an edit: such a function still sends the stock message.+ """+ return frozenset(+ eligibility.hog_function_id+ for eligibility in destination_eligibility.classify_alert_destinations(+ team_id=team_id, alert_id=alert_id, allowed_event_ids=allowed_event_ids+ )+ if set(eligibility.hold_backs) - {DestinationHoldBack.REFUSED_ADDRESS}+ )++def unbound_alert_destinations(*, team_id: int, allowed_event_ids: Collection[str], include_disabled: bool = False) -> tuple[UUID, ...]:diff --git a/products/alerts/backend/logic/destination_eligibility.py b/products/alerts/backend/logic/destination_eligibility.pyindex 3b1a92424fb1..fe909dc8c2c8 100644--- a/products/alerts/backend/logic/destination_eligibility.py+++ b/products/alerts/backend/logic/destination_eligibility.py@@ -87,6 +87,8 @@ _ALERT_BATCH_SIZE: Final = 200# Only these receive alert events. Any other function on the same event id reads captured events._RECEIVES_ALERT_EVENTS: Final = {"type": "internal_destination", "filters__source": "internal-events"}+# Compiled code and drafts are large and never classified, so they stay unread.+_UNCLASSIFIED_FIELDS: Final = ("bytecode", "transpiled", "draft")def classify_alert_destinations(@@ -98,6 +100,7 @@ def classify_alert_destinations(team_id=team_id, alert_ids=[alert_id], allowed_event_ids=allowed_event_ids, known_templates_only=False).filter(**_RECEIVES_ALERT_EVENTS)+ .defer(*_UNCLASSIFIED_FIELDS).order_by("created_at", "id"))return _classify(team_id, list(functions), allowed_event_ids)@@ -115,6 +118,7 @@ def classify_destinations_by_alert(team_id=team_id, alert_ids=batch, allowed_event_ids=allowed_event_ids, known_templates_only=False).filter(**_RECEIVES_ALERT_EVENTS)+ .defer(*_UNCLASSIFIED_FIELDS).order_by("created_at", "id"))for function, eligibility in zip(functions, _classify(team_id, functions, allowed_event_ids)):diff --git a/products/alerts/frontend/components/AlertNotificationDestinationEditor.tsx b/products/alerts/frontend/components/AlertNotificationDestinationEditor.tsxindex bb64d4718b55..4b7d542d733a 100644--- a/products/alerts/frontend/components/AlertNotificationDestinationEditor.tsx+++ b/products/alerts/frontend/components/AlertNotificationDestinationEditor.tsx@@ -38,7 +38,7 @@ export interface AlertNotificationDestinationView {key: stringtitle: ReactNodedetail?: ReactNode- tags?: { label: string; type?: LemonTagType }[]+ tags?: { label: string; type?: LemonTagType; tooltip?: string }[]viewAction?: AlertNotificationDestinationIconAction | AlertNotificationDestinationButtonActiononDelete: () => voiddeleting?: boolean@@ -182,9 +182,11 @@ function ExistingDestinations({<div className="flex items-center gap-2 flex-wrap"><span className="text-sm font-medium truncate">{destination.title}</span>{destination.tags?.map((tag) => (- <LemonTag key={tag.label} type={tag.type} size="small">- {tag.label}- </LemonTag>+ <Tooltip key={tag.label} title={tag.tooltip}>+ <LemonTag type={tag.type} size="small">+ {tag.label}+ </LemonTag>+ </Tooltip>))}</div>{destination.detail ? (diff --git a/products/logs/backend/presentation/views/alerts_api.py b/products/logs/backend/presentation/views/alerts_api.pyindex 458048cdfa53..e4bc5b3b2939 100644--- a/products/logs/backend/presentation/views/alerts_api.py+++ b/products/logs/backend/presentation/views/alerts_api.py@@ -37,6 +37,7 @@ from products.alerts.backend.facade.destinations import (build_alert_destination_config,configured_destination_template_ids,create_alert_destination_hog_functions,+ customized_alert_destination_ids,destination_handles_event_kind,destination_template_id,list_alert_destination_groups,@@ -191,6 +192,13 @@ class LogsAlertDestinationConfigSerializer(LogsAlertDestinationResponseSerialize"to after repeated failures still reads as true."))+ message_customized = serializers.BooleanField(+ help_text=(+ "Whether any HogFunction in the group sends something other than the stock message, "+ "such as an edited body, headers, method or code. A customized destination sends exactly "+ "what its HogFunctions build."+ )+ )slack_workspace_id = serializers.IntegerField(required=False)slack_channel_id = serializers.CharField(required=False)webhook_url = serializers.CharField(@@ -897,10 +905,14 @@ class LogsAlertConfigurationDetailSerializer(LogsAlertConfigurationSerializer):alert_id=str(obj.id),allowed_event_ids=LOGS_ALERT_EVENT_IDS,)+ customized = customized_alert_destination_ids(+ team_id=obj.team_id, alert_id=str(obj.id), allowed_event_ids=LOGS_ALERT_EVENT_IDS+ )return [{"hog_function_ids": list(group.hog_function_ids),"enabled": group.fully_enabled,+ "message_customized": not customized.isdisjoint(group.hog_function_ids),**redact_destination_data(group.data),}for group in groupsdiff --git a/products/logs/backend/test/test_alerts_api.py b/products/logs/backend/test/test_alerts_api.pyindex cdaaef033036..52bac2d31355 100644--- a/products/logs/backend/test/test_alerts_api.py+++ b/products/logs/backend/test/test_alerts_api.py@@ -1183,6 +1183,40 @@ class TestLogsAlertAPI(APIBaseTest):assert "password" not in bodyassert "token=secret" not in body+ def test_reading_an_alert_marks_only_the_destination_with_a_customized_function(self) -> None:+ self._sync_destination_templates()+ created = self._create_via_api()+ ids_by_url = {}+ for url in (+ "https://stock.example.com/hook",+ "https://edited.example.com/hook",+ "https://refused.example.com/hook",+ ):+ response = self.client.post(+ self._destinations_url(created["id"]), {"type": "webhook", "webhook_url": url}, format="json"+ )+ assert response.status_code == status.HTTP_201_CREATED, response.json()+ ids_by_url[url] = set(response.json()["hog_function_ids"])+ edited = HogFunction.objects.get(id=sorted(ids_by_url["https://edited.example.com/hook"])[0])+ edited.masking = {"ttl": 3600, "hash": "{event.event}", "threshold": None}+ edited.save(update_fields=["masking"])+ for refused in HogFunction.objects.filter(id__in=ids_by_url["https://refused.example.com/hook"]):+ inputs = refused.inputs or {}+ inputs["url"]["value"] = "http://refused.example.com/hook"+ refused.inputs = inputs+ refused.save(update_fields=["inputs"])++ customized_by_ids = {+ frozenset(destination["hog_function_ids"]): destination["message_customized"]+ for destination in self._read_destinations(created["id"])+ }++ assert customized_by_ids == {+ frozenset(str(i) for i in ids_by_url["https://stock.example.com/hook"]): False,+ frozenset(str(i) for i in ids_by_url["https://edited.example.com/hook"]): True,+ frozenset(str(i) for i in ids_by_url["https://refused.example.com/hook"]): False,+ }+def test_reading_an_alert_redacts_a_malformed_stored_webhook_url(self) -> None:self._sync_destination_templates()created = self._create_via_api()diff --git a/products/logs/frontend/components/LogsAlerting/LogsAlertNotifications.tsx b/products/logs/frontend/components/LogsAlerting/LogsAlertNotifications.tsxindex 43d7dee0af9b..a771fdfec36f 100644--- a/products/logs/frontend/components/LogsAlerting/LogsAlertNotifications.tsx+++ b/products/logs/frontend/components/LogsAlerting/LogsAlertNotifications.tsx@@ -14,6 +14,7 @@ import {import { LOGS_ALERT_NOTIFICATION_TYPE_OPTIONS, logsAlertNotificationLogic } from './logsAlertNotificationLogic'import {+ CUSTOM_MESSAGE_TAG,getHogFunctionEventKind,logsAlertEventKindsFor,LOGS_ALERT_NOTIFICATION_TYPE_PAGERDUTY,@@ -47,6 +48,7 @@ export function LogsAlertNotifications({ alertId }: { alertId?: string }): JSX.Econst {existingHogFunctionsLoading,destinationGroups,+ customizedDestinationKeys,pendingNotifications,integrationsLoading,integrationsFailed,@@ -95,7 +97,12 @@ export function LogsAlertNotifications({ alertId }: { alertId?: string }): JSX.Ereturn {key: group.key,title: resolveGroupLabel(group, slackChannels),- tags: [{ label: group.enabled ? 'Active' : 'Paused', type: group.enabled ? 'success' : 'default' }],+ tags: [+ { label: group.enabled ? 'Active' : 'Paused', type: group.enabled ? 'success' : 'default' },+ ...(customizedDestinationKeys.has(group.key)+ ? [{ label: CUSTOM_MESSAGE_TAG.label, tooltip: CUSTOM_MESSAGE_TAG.tooltip }]+ : []),+ ],viewAction: {kind: 'button',label: 'View',diff --git a/products/logs/frontend/components/LogsAlerting/__tests__/logsAlertNotificationLogic.test.ts b/products/logs/frontend/components/LogsAlerting/__tests__/logsAlertNotificationLogic.test.tsindex deb76f99ff62..2d8acb74178b 100644--- a/products/logs/frontend/components/LogsAlerting/__tests__/logsAlertNotificationLogic.test.ts+++ b/products/logs/frontend/components/LogsAlerting/__tests__/logsAlertNotificationLogic.test.ts@@ -1,12 +1,18 @@import { expectLogic } from 'kea-test-utils'import api from 'lib/api'+import { FEATURE_FLAGS } from 'lib/constants'import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { initKeaTests } from '~/test/init'import { HogFunctionType } from '~/types'-import { logsAlertsDestinationsCreate, logsAlertsDestinationsDeleteCreate } from 'products/logs/frontend/generated/api'+import {+ logsAlertsDestinationsCreate,+ logsAlertsDestinationsDeleteCreate,+ logsAlertsRetrieve,+} from 'products/logs/frontend/generated/api'import { logsAlertNotificationLogic } from '../logsAlertNotificationLogic'import { buildLogsAlertFilterConfig, LogsAlertDestinationGroup } from '../logsAlertUtils'@@ -26,6 +32,7 @@ jest.mock('products/logs/frontend/generated/api', () => ({__esModule: true,logsAlertsDestinationsCreate: jest.fn(),logsAlertsDestinationsDeleteCreate: jest.fn(),+ logsAlertsRetrieve: jest.fn(),}))jest.mock('lib/lemon-ui/LemonToast/LemonToast', () => ({@@ -38,6 +45,7 @@ jest.mock('lib/lemon-ui/LemonToast/LemonToast', () => ({const mockApi = api as jest.Mocked<typeof api>const mockCreate = logsAlertsDestinationsCreate as jest.MockedFunction<typeof logsAlertsDestinationsCreate>const mockDelete = logsAlertsDestinationsDeleteCreate as jest.MockedFunction<typeof logsAlertsDestinationsDeleteCreate>+const mockRetrieve = logsAlertsRetrieve as jest.MockedFunction<typeof logsAlertsRetrieve>const MOCK_HOG_FUNCTION = {id: 'hf-1',@@ -175,6 +183,56 @@ describe('logsAlertNotificationLogic', () => {logic.unmount()})++ it.each([+ { flagOn: true, flagAfterMount: false, expectedKeys: ['slack:C-edited'] },+ { flagOn: true, flagAfterMount: true, expectedKeys: ['slack:C-edited'] },+ { flagOn: false, flagAfterMount: false, expectedKeys: [] },+ ])(+ 'tags only the customized destination when the flag is $flagOn (set after mount: $flagAfterMount)',+ async ({ flagOn, flagAfterMount, expectedKeys }) => {+ const slack = (id: string, channel: string): HogFunctionType =>+ ({+ ...MOCK_HOG_FUNCTION,+ id,+ template_id: 'template-slack',+ inputs: { channel: { value: channel } },+ }) as HogFunctionType+ ;(mockApi.hogFunctions.list as jest.Mock).mockResolvedValue({+ results: [+ slack('hf-stock-1', 'C-stock'),+ slack('hf-stock-2', 'C-stock'),+ slack('hf-edited', 'C-edited'),+ ],+ })+ mockRetrieve.mockResolvedValue({+ destinations: [+ { hog_function_ids: ['hf-stock-1', 'hf-stock-2'], message_customized: false },+ { hog_function_ids: ['hf-edited'], message_customized: true },+ ],+ } as unknown as Awaited<ReturnType<typeof logsAlertsRetrieve>>)+ const flag = FEATURE_FLAGS.ALERTS_DESTINATION_CUSTOMIZATION+ const setFlag = (): void =>+ featureFlagLogic.actions.setFeatureFlags(flagOn ? [flag] : [], { [flag]: flagOn })+ featureFlagLogic.mount()+ if (!flagAfterMount) {+ setFlag()+ }++ const logic = logsAlertNotificationLogic({ alertId: 'alert-1' })+ logic.mount()+ await expectLogic(logic).toFinishAllListeners()+ if (flagAfterMount) {+ setFlag()+ await expectLogic(logic).toFinishAllListeners()+ }++ expect([...logic.values.customizedDestinationKeys]).toEqual(expectedKeys)+ expect(mockRetrieve.mock.calls.length > 0).toBe(flagOn)++ logic.unmount()+ }+ )})describe('createPendingHogFunctions', () => {diff --git a/products/logs/frontend/components/LogsAlerting/logsAlertNotificationLogic.ts b/products/logs/frontend/components/LogsAlerting/logsAlertNotificationLogic.tsindex 8e993025cfc0..988930e91805 100644--- a/products/logs/frontend/components/LogsAlerting/logsAlertNotificationLogic.ts+++ b/products/logs/frontend/components/LogsAlerting/logsAlertNotificationLogic.ts@@ -2,8 +2,10 @@ import { MakeLogicType, actions, afterMount, connect, kea, key, listeners, path,import { loaders } from 'kea-loaders'import api from 'lib/api'+import { FEATURE_FLAGS } from 'lib/constants'import { integrationsLogic } from 'lib/integrations/integrationsLogic'import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'+import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'import { projectLogic } from 'scenes/projectLogic'import { HogFunctionType, IntegrationType } from '~/types'@@ -13,7 +15,11 @@ import {AlertPagerDutyRegion,AlertPagerDutySeverity,} from 'products/alerts/frontend/components/AlertNotificationDestinationEditor'-import { logsAlertsDestinationsCreate, logsAlertsDestinationsDeleteCreate } from 'products/logs/frontend/generated/api'+import {+ logsAlertsDestinationsCreate,+ logsAlertsDestinationsDeleteCreate,+ logsAlertsRetrieve,+} from 'products/logs/frontend/generated/api'import { LogsAlertCreateDestinationApi } from 'products/logs/frontend/generated/api.schemas'import {@@ -63,10 +69,14 @@ export interface LogsAlertNotificationLogicProps {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface logsAlertNotificationLogicValues {+ featureFlags: FeatureFlagsSet // featureFlagLogicintegrationsLoading: boolean // integrationsLogicslackIntegrations: IntegrationType[] | undefined // integrationsLogiccurrentProjectId: number | null // projectLogicaddDisabledReason: string | undefined+ customizedDestinationKeys: Set<string>+ customizedHogFunctionIds: string[]+ customizedHogFunctionIdsLoading: booleandestinationGroups: LogsAlertDestinationGroup[]existingHogFunctions: HogFunctionType[]existingHogFunctionsLoading: boolean@@ -84,6 +94,13 @@ export interface logsAlertNotificationLogicValues {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface logsAlertNotificationLogicActions {+ setFeatureFlags: (+ flags: string[],+ variants: Record<string, boolean | string>+ ) => {+ flags: string[]+ variants: Record<string, boolean | string>+ } // featureFlagLogicloadIntegrations: (_?: any) => any // integrationsLogicloadIntegrationsFailure: (error: string,@@ -117,6 +134,21 @@ export interface logsAlertNotificationLogicActions {destinationsChanged: () => {value: true}+ loadCustomizedHogFunctionIds: (alertId?: string) => string+ loadCustomizedHogFunctionIdsFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ }+ loadCustomizedHogFunctionIdsSuccess: (+ customizedHogFunctionIds: string[],+ payload?: string+ ) => {+ customizedHogFunctionIds: string[]+ payload?: string+ }loadExistingHogFunctions: (alertId?: string) => stringloadExistingHogFunctionsFailure: (error: string,@@ -172,6 +204,11 @@ export interface logsAlertNotificationLogicMeta {pagerDutyRoutingKey: string) => string | undefineddestinationGroups: (existingHogFunctions: HogFunctionType[]) => LogsAlertDestinationGroup[]+ customizedDestinationKeys: (+ destinationGroups: LogsAlertDestinationGroup[],+ customizedHogFunctionIds: string[],+ featureFlags: FeatureFlagsSet+ ) => Set<string>}}@@ -188,8 +225,20 @@ export const logsAlertNotificationLogic = kea<logsAlertNotificationLogicType>([key(({ alertId }) => alertId ?? 'new'),connect({- values: [projectLogic, ['currentProjectId'], integrationsLogic, ['integrationsLoading', 'slackIntegrations']],- actions: [integrationsLogic, ['loadIntegrations', 'loadIntegrationsFailure', 'loadIntegrationsSuccess']],+ values: [+ projectLogic,+ ['currentProjectId'],+ integrationsLogic,+ ['integrationsLoading', 'slackIntegrations'],+ featureFlagLogic,+ ['featureFlags'],+ ],+ actions: [+ integrationsLogic,+ ['loadIntegrations', 'loadIntegrationsFailure', 'loadIntegrationsSuccess'],+ featureFlagLogic,+ ['setFeatureFlags'],+ ],}),actions({@@ -265,7 +314,22 @@ export const logsAlertNotificationLogic = kea<logsAlertNotificationLogicType>([],}),- loaders(({ props }) => ({+ loaders(({ props, values }) => ({+ customizedHogFunctionIds: [+ [] as string[],+ {+ loadCustomizedHogFunctionIds: async (alertId?: string) => {+ const id = alertId ?? props.alertId+ if (!id) {+ return []+ }+ const alert = await logsAlertsRetrieve(String(values.currentProjectId), id)+ return alert.destinations+ .filter((destination) => destination.message_customized)+ .flatMap((destination) => destination.hog_function_ids)+ },+ },+ ],existingHogFunctions: [[] as HogFunctionType[],{@@ -338,9 +402,38 @@ export const logsAlertNotificationLogic = kea<logsAlertNotificationLogicType>([(hogFunctions: HogFunctionType[]): LogsAlertDestinationGroup[] =>groupLogsAlertDestinations(hogFunctions, () => null),],+ customizedDestinationKeys: [+ (s) => [s.destinationGroups, s.customizedHogFunctionIds, s.featureFlags],+ (+ groups: LogsAlertDestinationGroup[],+ customizedIds: string[],+ featureFlags: FeatureFlagsSet+ ): Set<string> => {+ if (!featureFlags[FEATURE_FLAGS.ALERTS_DESTINATION_CUSTOMIZATION]) {+ return new Set()+ }+ const customized = new Set(customizedIds)+ return new Set(+ groups+ .filter((group) => group.hogFunctions.some((hogFunction) => customized.has(hogFunction.id)))+ .map((group) => group.key)+ )+ },+ ],}),listeners(({ actions, values, props }) => ({+ loadExistingHogFunctions: (alertId) => {+ if (values.featureFlags[FEATURE_FLAGS.ALERTS_DESTINATION_CUSTOMIZATION]) {+ actions.loadCustomizedHogFunctionIds(alertId)+ }+ },+ // Flags that are not persisted arrive after mount, so the first load may have skipped the ids.+ setFeatureFlags: () => {+ if (props.alertId && values.featureFlags[FEATURE_FLAGS.ALERTS_DESTINATION_CUSTOMIZATION]) {+ actions.loadCustomizedHogFunctionIds()+ }+ },addSelectedNotification: () => {if (values.selectedType === LOGS_ALERT_NOTIFICATION_TYPE_SLACK) {if (!values.slackChannelValue || !values.firstSlackIntegration) {diff --git a/products/logs/frontend/components/LogsAlerting/logsAlertUtils.ts b/products/logs/frontend/components/LogsAlerting/logsAlertUtils.tsindex 2225ff78782e..9ddac0fa1fd6 100644--- a/products/logs/frontend/components/LogsAlerting/logsAlertUtils.ts+++ b/products/logs/frontend/components/LogsAlerting/logsAlertUtils.ts@@ -107,6 +107,11 @@ export function dispatchPreEnableCheck(result: PreEnableCheckResult, onConfirm:onConfirm()}+export const CUSTOM_MESSAGE_TAG = {+ label: 'Custom message',+ tooltip: 'This destination was edited, so it sends what you configured instead of the standard alert message.',+}+export const SNOOZE_DURATIONS = [{ label: '30 minutes', minutes: 30 },{ label: '1 hour', minutes: 60 },diff --git a/products/logs/frontend/generated/api.schemas.ts b/products/logs/frontend/generated/api.schemas.tsindex 444a7fa9c12d..3b643ecaa50c 100644--- a/products/logs/frontend/generated/api.schemas.ts+++ b/products/logs/frontend/generated/api.schemas.ts@@ -720,6 +720,8 @@ export interface LogsAlertDestinationConfigApi {type: LogsAlertDestinationTypeEnumApi/** Whether every HogFunction in the group is enabled, so the destination notifies for all alert event kinds. This is the stored setting: a destination PostHog stopped delivering to after repeated failures still reads as true. */enabled: boolean+ /** Whether any HogFunction in the group sends something other than the stock message, such as an edited body, headers, method or code. A customized destination sends exactly what its HogFunctions build. */+ message_customized: booleanslack_workspace_id?: numberslack_channel_id?: string/** Webhook endpoint reduced to scheme and host. The path, query and userinfo carry the secret. */diff --git a/products/logs/frontend/scenes/LogsAlertNotificationDetailScene/LogsAlertNotificationDetailScene.tsx b/products/logs/frontend/scenes/LogsAlertNotificationDetailScene/LogsAlertNotificationDetailScene.tsxindex f8efbccd7d9a..48c9b79d9138 100644--- a/products/logs/frontend/scenes/LogsAlertNotificationDetailScene/LogsAlertNotificationDetailScene.tsx+++ b/products/logs/frontend/scenes/LogsAlertNotificationDetailScene/LogsAlertNotificationDetailScene.tsx@@ -2,8 +2,9 @@ import { useActions, useValues } from 'kea'import { useEffect } from 'react'import { IconExternal, IconTrash } from '@posthog/icons'-import { LemonButton, LemonDialog, LemonSkeleton, LemonSwitch, LemonTag } from '@posthog/lemon-ui'+import { LemonButton, LemonDialog, LemonSkeleton, LemonSwitch, LemonTag, Tooltip } from '@posthog/lemon-ui'+import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'import { slackIntegrationLogic } from 'lib/integrations/slackIntegrationLogic'import { SceneExport } from 'scenes/sceneTypes'import { urls } from 'scenes/urls'@@ -13,6 +14,7 @@ import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'import { HogFunctionType } from '~/types'import {+ CUSTOM_MESSAGE_TAG,getHogFunctionEventKind,LOGS_ALERT_EVENT_KIND_META,logsAlertEventKindsFor,@@ -44,7 +46,9 @@ export function LogsAlertNotificationDetailScene(): JSX.Element {alertId,hogFunctionId,firstSlackIntegration,+ messageCustomized,} = useValues(logsAlertNotificationDetailSceneLogic)+ const customizationEnabled = useFeatureFlag('ALERTS_DESTINATION_CUSTOMIZATION')const { deleteDestination, loadHogFunctions, setHogFunctionEnabled } = useActions(logsAlertNotificationDetailSceneLogic)@@ -127,6 +131,11 @@ export function LogsAlertNotificationDetailScene(): JSX.Element {<LemonTag type={destinationGroup.enabled ? 'success' : 'default'}>{destinationGroup.enabled ? 'Active' : 'Paused'}</LemonTag>+ {customizationEnabled && messageCustomized ? (+ <Tooltip title={CUSTOM_MESSAGE_TAG.tooltip}>+ <LemonTag>{CUSTOM_MESSAGE_TAG.label}</LemonTag>+ </Tooltip>+ ) : null}<LemonButtonsize="small"type="secondary"@@ -160,6 +169,9 @@ export function LogsAlertNotificationDetailScene(): JSX.Element {<p className="text-sm text-muted m-0">These hog functions only run for this alert. Open one to edit the message body, headers, filters, ordestination details for the matching lifecycle event.+ {customizationEnabled+ ? ' Changes apply to notifications sent after you save. If the alert is firing now, its resolve message may still use the earlier version.'+ : null}</p>{loading ? (diff --git a/products/logs/frontend/scenes/LogsAlertNotificationDetailScene/logsAlertNotificationDetailSceneLogic.ts b/products/logs/frontend/scenes/LogsAlertNotificationDetailScene/logsAlertNotificationDetailSceneLogic.tsindex 9b186c9c8bd8..6dbe56dec57b 100644--- a/products/logs/frontend/scenes/LogsAlertNotificationDetailScene/logsAlertNotificationDetailSceneLogic.ts+++ b/products/logs/frontend/scenes/LogsAlertNotificationDetailScene/logsAlertNotificationDetailSceneLogic.ts@@ -20,7 +20,6 @@ import {LogsAlertDestinationGroup,} from 'products/logs/frontend/components/LogsAlerting/logsAlertUtils'import { logsAlertsDestinationsDeleteCreate, logsAlertsRetrieve } from 'products/logs/frontend/generated/api'-import { LogsAlertConfigurationApi } from 'products/logs/frontend/generated/api.schemas'import type { LogsAlertConfigurationDetailApi } from '../../generated/api.schemas'@@ -33,7 +32,7 @@ export interface LogsAlertNotificationDetailSceneLogicProps {export interface logsAlertNotificationDetailSceneLogicValues {slackIntegrations: IntegrationType[] | undefined // integrationsLogiccurrentTeamId: number | null // teamLogic- alert: LogsAlertConfigurationApi | null+ alert: LogsAlertConfigurationDetailApi | nullalertId: stringalertLoading: booleanbreadcrumbs: Breadcrumb[]@@ -45,6 +44,7 @@ export interface logsAlertNotificationDetailSceneLogicValues {hogFunctionsError: string | nullhogFunctionsLoading: booleanisDeleting: boolean+ messageCustomized: booleantogglingHogFunctionIds: string[]}@@ -103,8 +103,12 @@ export interface logsAlertNotificationDetailSceneLogicMeta {hogFunctionId: (arg: any) => stringfirstSlackIntegration: (slackIntegrations: IntegrationType[] | undefined) => IntegrationType | undefineddestinationGroup: (hogFunctions: HogFunctionType[], hogFunctionId: string) => LogsAlertDestinationGroup | null+ messageCustomized: (+ alert: LogsAlertConfigurationDetailApi | null,+ destinationGroup: LogsAlertDestinationGroup | null+ ) => booleanbreadcrumbs: (- alert: LogsAlertConfigurationApi | null,+ alert: LogsAlertConfigurationDetailApi | null,destinationGroup: LogsAlertDestinationGroup | null,alertId: string) => Breadcrumb[]@@ -176,7 +180,7 @@ export const logsAlertNotificationDetailSceneLogic = kea<logsAlertNotificationDeloaders(({ values, props }) => ({alert: [- null as LogsAlertConfigurationApi | null,+ null as LogsAlertConfigurationDetailApi | null,{loadAlert: async () => {if (!values.currentTeamId) {@@ -218,10 +222,20 @@ export const logsAlertNotificationDetailSceneLogic = kea<logsAlertNotificationDereturn groups.find((g) => g.hogFunctions.some((hf) => hf.id === hogFunctionId)) ?? null},],+ messageCustomized: [+ (s) => [s.alert, s.destinationGroup],+ (alert: LogsAlertConfigurationDetailApi | null, group: LogsAlertDestinationGroup | null): boolean => {+ const groupIds = new Set(group?.hogFunctions.map((hogFunction) => hogFunction.id))+ return (alert?.destinations ?? []).some(+ (destination) =>+ destination.message_customized && destination.hog_function_ids.some((id) => groupIds.has(id))+ )+ },+ ],breadcrumbs: [(s) => [s.alert, s.destinationGroup, s.alertId],(- alert: LogsAlertConfigurationApi | null,+ alert: LogsAlertConfigurationDetailApi | null,group: LogsAlertDestinationGroup | null,alertId: string): Breadcrumb[] => [diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 642cf6066b4c..0cd41a07d5a9 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -64307,6 +64307,8 @@ export namespace Schemas {type: LogsAlertDestinationTypeEnum;/** Whether every HogFunction in the group is enabled, so the destination notifies for all alert event kinds. This is the stored setting: a destination PostHog stopped delivering to after repeated failures still reads as true. */enabled: boolean;+ /** Whether any HogFunction in the group sends something other than the stock message, such as an edited body, headers, method or code. A customized destination sends exactly what its HogFunctions build. */+ message_customized: boolean;slack_workspace_id?: number;slack_channel_id?: string;/** Webhook endpoint reduced to scheme and host. The path, query and userinfo carry the secret. */