: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
fix(replay-vision): select slack workspace for alerts (#122491)
Tue Haulund1a3a80f9f087
diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerAlertNotifications.tsx b/products/replay_vision/frontend/replay_scanners/components/ScannerAlertNotifications.tsxindex cdf7102a7e91..edb1ef0a59b8 100644--- a/products/replay_vision/frontend/replay_scanners/components/ScannerAlertNotifications.tsx+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerAlertNotifications.tsx@@ -1,7 +1,4 @@import { useActions, useValues } from 'kea'-import { useEffect } from 'react'--import { slackIntegrationLogic } from 'lib/integrations/slackIntegrationLogic'import {AlertNotificationDestinationEditor,@@ -10,17 +7,7 @@ import {} from 'products/alerts/frontend/components/AlertNotificationDestinationEditor'import { VISION_ALERT_NOTIFICATION_TYPE_OPTIONS, scannerAlertNotificationLogic } from '../scannerAlertNotificationLogic'-import { PendingVisionAlertNotification, VISION_ALERT_NOTIFICATION_TYPE_SLACK } from '../scannerAlertUtils'--function pendingDestinationView(notification: PendingVisionAlertNotification): {- title: string- detail?: string-} {- if (notification.type === VISION_ALERT_NOTIFICATION_TYPE_SLACK) {- return { title: 'Slack', detail: `#${notification.slackChannelName ?? 'channel'}` }- }- return { title: 'Webhook', detail: notification.webhookUrl }-}+import { VISION_ALERT_NOTIFICATION_TYPE_SLACK, pendingVisionAlertNotificationView } from '../scannerAlertUtils'export function ScannerAlertNotifications(): JSX.Element {const {@@ -31,7 +18,7 @@ export function ScannerAlertNotifications(): JSX.Element {integrationsLoading,integrationsFailed,slackIntegrations,- firstSlackIntegration,+ selectedSlackIntegration,selectedType,slackChannelValue,webhookUrl,@@ -43,19 +30,12 @@ export function ScannerAlertNotifications(): JSX.Element {removePendingNotification,deleteExistingDestination,setSelectedType,+ setSelectedSlackIntegrationId,setSlackChannelValue,setWebhookUrl,loadIntegrations,} = useActions(scannerAlertNotificationLogic)- const slackLogic = slackIntegrationLogic({ id: firstSlackIntegration?.id ?? 0 })- const { loadAllSlackChannels } = useActions(slackLogic)- useEffect(() => {- if (firstSlackIntegration?.id) {- loadAllSlackChannels()- }- }, [firstSlackIntegration?.id, loadAllSlackChannels])-const existingDestinations: AlertNotificationDestinationView[] = destinationGroups.map((group) => ({key: group.key,title: group.label,@@ -66,7 +46,7 @@ export function ScannerAlertNotifications(): JSX.Element {const pendingDestinations: PendingAlertNotificationDestinationView[] = pendingNotifications.map((notification, index) => ({key: `${notification.type}-${index}`,- ...pendingDestinationView(notification),+ ...pendingVisionAlertNotificationView(notification, slackIntegrations),onRemove: () => removePendingNotification(index),}))@@ -98,7 +78,8 @@ export function ScannerAlertNotifications(): JSX.Element {integrationsFailed,onRetryIntegrations: loadIntegrations,integrations: slackIntegrations,- integration: firstSlackIntegration,+ integration: selectedSlackIntegration,+ onIntegrationChange: setSelectedSlackIntegrationId,channelValue: slackChannelValue,onChannelValueChange: setSlackChannelValue,}}diff --git a/products/replay_vision/frontend/replay_scanners/scannerAlertNotificationLogic.test.ts b/products/replay_vision/frontend/replay_scanners/scannerAlertNotificationLogic.test.tsindex d921e7216409..bd621a315637 100644--- a/products/replay_vision/frontend/replay_scanners/scannerAlertNotificationLogic.test.ts+++ b/products/replay_vision/frontend/replay_scanners/scannerAlertNotificationLogic.test.ts@@ -4,10 +4,12 @@ import api from 'lib/api'import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'import { initKeaTests } from '~/test/init'+import type { IntegrationType } from '~/types'import { visionAlertsDestinationsCreate } from 'products/replay_vision/frontend/generated/api'import { scannerAlertNotificationLogic } from './scannerAlertNotificationLogic'+import { VISION_ALERT_NOTIFICATION_TYPE_SLACK } from './scannerAlertUtils'jest.mock('lib/api', () => {const actual = jest.requireActual('lib/api')@@ -35,32 +37,116 @@ const mockApi = api as jest.Mocked<typeof api>const mockCreate = visionAlertsDestinationsCreate as jest.MockedFunction<typeof visionAlertsDestinationsCreate>describe('scannerAlertNotificationLogic', () => {+ let logic: ReturnType<typeof scannerAlertNotificationLogic.build> | undefined+beforeEach(() => {initKeaTests()jest.clearAllMocks()+ logic = undefined;(mockApi.hogFunctions.list as jest.Mock).mockResolvedValue({ results: [] })})+ afterEach(() => {+ logic?.unmount()+ })++ const makeSlackIntegration = (id: number): IntegrationType => ({+ id,+ kind: 'slack',+ display_name: `Workspace ${id}`,+ icon_url: '',+ config: {},+ created_at: '2026-01-01T00:00:00Z',+ })++ it('stages a notification for the selected Slack workspace', async () => {+ logic = scannerAlertNotificationLogic({})+ logic.mount()+ const firstWorkspace = makeSlackIntegration(1)+ const secondWorkspace = makeSlackIntegration(2)+ logic.actions.loadIntegrationsSuccess([firstWorkspace, secondWorkspace])++ await expectLogic(logic).toMatchValues({+ selectedSlackIntegrationId: 1,+ selectedSlackIntegration: firstWorkspace,+ })++ logic.actions.setSlackChannelValue('C123|#general')+ logic.actions.setSelectedSlackIntegrationId(2)+ await expectLogic(logic).toMatchValues({+ selectedSlackIntegration: secondWorkspace,+ slackChannelValue: null,+ })++ logic.actions.setSlackChannelValue('C456|#alerts')+ logic.actions.addSelectedNotification()++ await expectLogic(logic).toMatchValues({+ pendingNotifications: [+ {+ type: VISION_ALERT_NOTIFICATION_TYPE_SLACK,+ slackWorkspaceId: 2,+ slackChannelId: 'C456',+ slackChannelName: 'alerts',+ },+ ],+ slackChannelValue: null,+ })+ })++ it('keeps staged Slack state on reload only while its workspace is still connected', async () => {+ logic = scannerAlertNotificationLogic({})+ logic.mount()+ const firstWorkspace = makeSlackIntegration(1)+ const secondWorkspace = makeSlackIntegration(2)+ logic.actions.loadIntegrationsSuccess([firstWorkspace, secondWorkspace])+ logic.actions.setSlackChannelValue('C123|#general')++ logic.actions.loadIntegrationsSuccess([firstWorkspace, secondWorkspace])++ await expectLogic(logic).toMatchValues({+ selectedSlackIntegrationId: 1,+ slackChannelValue: 'C123|#general',+ })++ logic.actions.loadIntegrationsSuccess([secondWorkspace])++ await expectLogic(logic).toMatchValues({+ selectedSlackIntegration: secondWorkspace,+ slackChannelValue: null,+ })++ logic.actions.setSlackChannelValue('C456|#alerts')+ logic.actions.addSelectedNotification()+ logic.actions.addPendingNotification({ type: 'webhook', webhookUrl: 'https://example.com/hook' })+ logic.actions.loadIntegrationsSuccess([firstWorkspace])++ await expectLogic(logic).toMatchValues({+ selectedSlackIntegration: firstWorkspace,+ pendingNotifications: [{ type: 'webhook', webhookUrl: 'https://example.com/hook' }],+ })+ })+it.each([['an existing alert creates on add and points at Save to retry', 'alert-1', 'Save the alert to try again'],['a new alert creates on submit and points at reopening', undefined, 'Reopen the alert'],])('%s', async (_name, alertId, expectedToast) => {mockCreate.mockRejectedValueOnce(new Error('API error'))- const logic = scannerAlertNotificationLogic({ alertId })- logic.mount()+ const alertLogic = scannerAlertNotificationLogic({ alertId })+ alertLogic.mount()- await expectLogic(logic, () => {- logic.actions.addPendingNotification({ type: 'webhook', webhookUrl: 'https://example.com/hook' })+ await expectLogic(alertLogic, () => {+ alertLogic.actions.addPendingNotification({ type: 'webhook', webhookUrl: 'https://example.com/hook' })if (!alertId) {- logic.actions.createPendingHogFunctions('alert-1')+ alertLogic.actions.createPendingHogFunctions('alert-1')}}).toFinishAllListeners()expect(mockCreate).toHaveBeenCalledTimes(1)expect(lemonToast.error).toHaveBeenCalledWith(expect.stringContaining(expectedToast))- expect(logic.values.pendingNotifications).toHaveLength(1)+ expect(alertLogic.values.pendingNotifications).toHaveLength(1)- logic.unmount()+ alertLogic.unmount()})})diff --git a/products/replay_vision/frontend/replay_scanners/scannerAlertNotificationLogic.ts b/products/replay_vision/frontend/replay_scanners/scannerAlertNotificationLogic.tsindex 58bd4efc4cb2..ec45ab27fb0e 100644--- a/products/replay_vision/frontend/replay_scanners/scannerAlertNotificationLogic.ts+++ b/products/replay_vision/frontend/replay_scanners/scannerAlertNotificationLogic.ts@@ -40,9 +40,10 @@ export interface scannerAlertNotificationLogicValues {destinationGroups: VisionAlertDestinationGroup[]existingHogFunctions: HogFunctionType[]existingHogFunctionsLoading: boolean- firstSlackIntegration: IntegrationType | undefinedintegrationsFailed: booleanpendingNotifications: PendingVisionAlertNotification[]+ selectedSlackIntegration: IntegrationType | undefined+ selectedSlackIntegrationId: number | nullselectedType: VisionAlertNotificationTypeslackChannelValue: string | nullurlInput: AlertNotificationUrlInput | undefined@@ -102,6 +103,9 @@ export interface scannerAlertNotificationLogicActions {setPendingNotifications: (notifications: PendingVisionAlertNotification[]) => {notifications: PendingVisionAlertNotification[]}+ setSelectedSlackIntegrationId: (selectedSlackIntegrationId: number | null) => {+ selectedSlackIntegrationId: number | null+ }setSelectedType: (selectedType: VisionAlertNotificationType) => {selectedType: VisionAlertNotificationType}@@ -118,15 +122,21 @@ export interface scannerAlertNotificationLogicMeta {key: string__keaTypeGenInternalSelectorTypes: {autoSavesDestinations: (arg: string | undefined) => boolean- firstSlackIntegration: (slackIntegrations: IntegrationType[] | undefined) => IntegrationType | undefined+ selectedSlackIntegration: (+ slackIntegrations: IntegrationType[] | undefined,+ selectedSlackIntegrationId: number | null+ ) => IntegrationType | undefinedurlInput: (selectedType: VisionAlertNotificationType) => AlertNotificationUrlInput | undefinedaddDisabledReason: (selectedType: VisionAlertNotificationType,- firstSlackIntegration: IntegrationType | undefined,+ selectedSlackIntegration: IntegrationType | undefined,slackChannelValue: string | null,webhookUrl: string) => string | undefined- destinationGroups: (existingHogFunctions: HogFunctionType[]) => VisionAlertDestinationGroup[]+ destinationGroups: (+ existingHogFunctions: HogFunctionType[],+ slackIntegrations: IntegrationType[] | undefined+ ) => VisionAlertDestinationGroup[]}}@@ -156,6 +166,9 @@ export const scannerAlertNotificationLogic = kea<scannerAlertNotificationLogicTydeleteExistingDestination: (group: VisionAlertDestinationGroup) => ({ group }),createPendingHogFunctions: (alertId: string) => ({ alertId }),setSelectedType: (selectedType: VisionAlertNotificationType) => ({ selectedType }),+ setSelectedSlackIntegrationId: (selectedSlackIntegrationId: number | null) => ({+ selectedSlackIntegrationId,+ }),setSlackChannelValue: (slackChannelValue: string | null) => ({ slackChannelValue }),setWebhookUrl: (webhookUrl: string) => ({ webhookUrl }),}),@@ -182,6 +195,13 @@ export const scannerAlertNotificationLogic = kea<scannerAlertNotificationLogicTynull as string | null,{setSlackChannelValue: (_, { slackChannelValue }) => slackChannelValue,+ setSelectedSlackIntegrationId: () => null,+ },+ ],+ selectedSlackIntegrationId: [+ null as number | null,+ {+ setSelectedSlackIntegrationId: (_, { selectedSlackIntegrationId }) => selectedSlackIntegrationId,},],webhookUrl: [@@ -223,9 +243,14 @@ export const scannerAlertNotificationLogic = kea<scannerAlertNotificationLogicTy() => [(_, props: ScannerAlertNotificationLogicProps) => props.alertId],(alertId: string | undefined): boolean => !!alertId,],- firstSlackIntegration: [- (s) => [s.slackIntegrations],- (slackIntegrations: IntegrationType[] | undefined): IntegrationType | undefined => slackIntegrations?.[0],+ selectedSlackIntegration: [+ (s) => [s.slackIntegrations, s.selectedSlackIntegrationId],+ (+ slackIntegrations: IntegrationType[] | undefined,+ selectedSlackIntegrationId: number | null+ ): IntegrationType | undefined =>+ slackIntegrations?.find((integration) => integration.id === selectedSlackIntegrationId) ??+ slackIntegrations?.[0],],urlInput: [(s) => [s.selectedType],@@ -235,39 +260,41 @@ export const scannerAlertNotificationLogic = kea<scannerAlertNotificationLogicTy: undefined,],addDisabledReason: [- (s) => [s.selectedType, s.firstSlackIntegration, s.slackChannelValue, s.webhookUrl],+ (s) => [s.selectedType, s.selectedSlackIntegration, s.slackChannelValue, s.webhookUrl],(selectedType: VisionAlertNotificationType,- firstSlackIntegration: IntegrationType | undefined,+ selectedSlackIntegration: IntegrationType | undefined,slackChannelValue: string | null,webhookUrl: string): string | undefined => {if (selectedType !== VISION_ALERT_NOTIFICATION_TYPE_SLACK) {return webhookUrl ? undefined : 'Enter a webhook URL'}- if (!firstSlackIntegration) {+ if (!selectedSlackIntegration) {return 'Connect Slack first'}return slackChannelValue ? undefined : 'Select a Slack channel'},],destinationGroups: [- (s) => [s.existingHogFunctions],- (hogFunctions: HogFunctionType[]): VisionAlertDestinationGroup[] =>- groupVisionAlertDestinations(hogFunctions),+ (s) => [s.existingHogFunctions, s.slackIntegrations],+ (+ hogFunctions: HogFunctionType[],+ slackIntegrations: IntegrationType[] | undefined+ ): VisionAlertDestinationGroup[] => groupVisionAlertDestinations(hogFunctions, slackIntegrations),],}),listeners(({ actions, values, props }) => ({addSelectedNotification: () => {if (values.selectedType === VISION_ALERT_NOTIFICATION_TYPE_SLACK) {- if (!values.slackChannelValue || !values.firstSlackIntegration) {+ if (!values.slackChannelValue || !values.selectedSlackIntegration) {return}const [channelId, channelLabel] = values.slackChannelValue.split('|')actions.addPendingNotification({type: VISION_ALERT_NOTIFICATION_TYPE_SLACK,- slackWorkspaceId: values.firstSlackIntegration.id,+ slackWorkspaceId: values.selectedSlackIntegration.id,slackChannelId: channelId,slackChannelName: channelLabel?.replace('#', '') ?? channelId,})@@ -288,10 +315,25 @@ export const scannerAlertNotificationLogic = kea<scannerAlertNotificationLogicTyactions.createPendingHogFunctions(props.alertId)}},- loadIntegrationsSuccess: () => {- if (!values.firstSlackIntegration) {+ loadIntegrationsSuccess: ({ integrations }) => {+ const availableSlackIntegrations = integrations.filter((integration) => integration.kind === 'slack')+ const availableIds = new Set(availableSlackIntegrations.map((integration) => integration.id))+ if (values.selectedSlackIntegrationId === null || !availableIds.has(values.selectedSlackIntegrationId)) {+ actions.setSelectedSlackIntegrationId(availableSlackIntegrations[0]?.id ?? null)+ }+ if (availableSlackIntegrations.length === 0) {actions.setSelectedType(VISION_ALERT_NOTIFICATION_TYPE_WEBHOOK)}++ // A new alert creates its destinations on submit, so a staged notification for a disconnected workspace would fail then.+ const stillValidPending = values.pendingNotifications.filter(+ (notification) =>+ notification.type !== VISION_ALERT_NOTIFICATION_TYPE_SLACK ||+ availableIds.has(notification.slackWorkspaceId)+ )+ if (stillValidPending.length !== values.pendingNotifications.length) {+ actions.setPendingNotifications(stillValidPending)+ }},deleteExistingDestination: async ({ group }) => {if (!props.alertId) {diff --git a/products/replay_vision/frontend/replay_scanners/scannerAlertUtils.test.ts b/products/replay_vision/frontend/replay_scanners/scannerAlertUtils.test.tsindex 5ef469b6f73a..5a810c8f0c55 100644--- a/products/replay_vision/frontend/replay_scanners/scannerAlertUtils.test.ts+++ b/products/replay_vision/frontend/replay_scanners/scannerAlertUtils.test.ts@@ -1,22 +1,98 @@-import { alertTagOptions } from './scannerAlertUtils'--describe('alertTagOptions', () => {- it('keeps the configured categories first and in configuration order', () => {- expect(alertTagOptions(['checkout', 'onboarding'], ['analytics'])).toEqual([- { key: 'checkout', label: 'checkout' },- { key: 'onboarding', label: 'onboarding' },- { key: 'analytics', label: 'analytics', tooltip: 'Freeform tag seen in observations' },- ])+import { HogFunctionType, IntegrationType } from '~/types'++import {+ PendingVisionAlertNotification,+ VISION_ALERT_NOTIFICATION_TYPE_SLACK,+ alertTagOptions,+ groupVisionAlertDestinations,+ pendingVisionAlertNotificationView,+} from './scannerAlertUtils'++describe('scannerAlertUtils', () => {+ describe('alertTagOptions', () => {+ it('keeps the configured categories first and in configuration order', () => {+ expect(alertTagOptions(['checkout', 'onboarding'], ['analytics'])).toEqual([+ { key: 'checkout', label: 'checkout' },+ { key: 'onboarding', label: 'onboarding' },+ { key: 'analytics', label: 'analytics', tooltip: 'Freeform tag seen in observations' },+ ])+ })++ it('does not repeat a configured category that observations also carried', () => {+ expect(alertTagOptions(['checkout', 'checkout'], ['checkout', 'rage'])).toEqual([+ { key: 'checkout', label: 'checkout' },+ { key: 'rage', label: 'rage', tooltip: 'Freeform tag seen in observations' },+ ])+ })++ it('returns nothing when the scanner has no tags at all', () => {+ expect(alertTagOptions([], [])).toEqual([])+ })+ })++ it('keeps the same Slack channel in different workspaces as separate destinations', () => {+ const slackHogFunction = (id: string, workspaceId: number): HogFunctionType =>+ ({+ id,+ name: `slack-${id}`,+ enabled: true,+ template_id: 'template-slack',+ inputs: {+ slack_workspace: { value: workspaceId },+ channel: { value: 'C123' },+ },+ }) as unknown as HogFunctionType++ const groups = groupVisionAlertDestinations(+ [+ slackHogFunction('hf-workspace-1-firing', 1),+ slackHogFunction('hf-workspace-1-resolved', 1),+ slackHogFunction('hf-workspace-2', 2),+ ],+ undefined+ )++ expect(groups.map(({ key }) => key)).toEqual(['slack:1:C123', 'slack:2:C123'])+ expect(groups.map(({ hogFunctions }) => hogFunctions.length)).toEqual([2, 1])})- it('does not repeat a configured category that observations also carried', () => {- expect(alertTagOptions(['checkout', 'checkout'], ['checkout', 'rage'])).toEqual([- { key: 'checkout', label: 'checkout' },- { key: 'rage', label: 'rage', tooltip: 'Freeform tag seen in observations' },- ])+ it.each([+ ['Replay vision alert — Checkout → Slack alert (firing) → Slack #alerts', 'Workspace two · #alerts'],+ ['Renamed in the CDP UI', 'Workspace two · #channel'],+ ])('labels a saved Slack destination named %s', (name, expectedLabel) => {+ const hogFunction = {+ id: 'hf-workspace-2',+ name,+ enabled: true,+ template_id: 'template-slack',+ inputs: {+ slack_workspace: { value: 2 },+ channel: { value: 'C123' },+ },+ } as unknown as HogFunctionType+ const integrations = [+ { id: 1, display_name: 'Workspace one' },+ { id: 2, display_name: 'Workspace two' },+ ] as IntegrationType[]++ expect(groupVisionAlertDestinations([hogFunction], integrations)[0].label).toBe(expectedLabel)})- it('returns nothing when the scanner has no tags at all', () => {- expect(alertTagOptions([], [])).toEqual([])+ it('includes the Slack workspace name in a pending destination', () => {+ const notification: PendingVisionAlertNotification = {+ type: VISION_ALERT_NOTIFICATION_TYPE_SLACK,+ slackWorkspaceId: 2,+ slackChannelId: 'C123',+ slackChannelName: 'alerts',+ }+ const integrations = [+ { id: 1, display_name: 'Workspace one' },+ { id: 2, display_name: 'Workspace two' },+ ] as IntegrationType[]++ expect(pendingVisionAlertNotificationView(notification, integrations)).toEqual({+ title: 'Slack',+ detail: 'Workspace two · #alerts',+ })})})diff --git a/products/replay_vision/frontend/replay_scanners/scannerAlertUtils.ts b/products/replay_vision/frontend/replay_scanners/scannerAlertUtils.tsindex d04c708dade3..2a785e0d9abd 100644--- a/products/replay_vision/frontend/replay_scanners/scannerAlertUtils.ts+++ b/products/replay_vision/frontend/replay_scanners/scannerAlertUtils.ts@@ -1,6 +1,12 @@import type { LemonInputSelectOption } from 'lib/lemon-ui/LemonInputSelect'-import { CyclotronJobFiltersType, HogFunctionType, PropertyFilterType, PropertyOperator } from '~/types'+import {+ CyclotronJobFiltersType,+ HogFunctionType,+ IntegrationType,+ PropertyFilterType,+ PropertyOperator,+} from '~/types'import type { VisionAlertConfigurationApi } from '../generated/api.schemas'@@ -31,6 +37,32 @@ export type VisionAlertDestinationGroup = {enabled: boolean}+function slackDestinationLabel(+ slackIntegrations: IntegrationType[] | undefined,+ workspaceId: number | undefined,+ channelName: string+): string {+ const workspaceName = slackIntegrations?.find((integration) => integration.id === workspaceId)?.display_name+ return `${workspaceName ?? 'Unknown workspace'} · ${channelName}`+}++export function pendingVisionAlertNotificationView(+ notification: PendingVisionAlertNotification,+ slackIntegrations: IntegrationType[] | undefined+): { title: string; detail?: string } {+ if (notification.type === VISION_ALERT_NOTIFICATION_TYPE_SLACK) {+ return {+ title: 'Slack',+ detail: slackDestinationLabel(+ slackIntegrations,+ notification.slackWorkspaceId,+ `#${notification.slackChannelName ?? 'channel'}`+ ),+ }+ }+ return { title: 'Webhook', detail: notification.webhookUrl }+}+// The alert predicate compares tag strings exactly, so an option's `label` stays the raw tag.// Configured categories come first because they are the vocabulary the classifier picks from;// the tags only seen in observations are freeform ones, and they follow in the order the stats@@ -69,10 +101,14 @@ export function buildVisionAlertFilterConfig(alertId: string): CyclotronJobFilte}}-export function groupVisionAlertDestinations(hogFunctions: HogFunctionType[]): VisionAlertDestinationGroup[] {+export function groupVisionAlertDestinations(+ hogFunctions: HogFunctionType[],+ slackIntegrations: IntegrationType[] | undefined+): VisionAlertDestinationGroup[] {const groups = new Map<string, VisionAlertDestinationGroup>()for (const hf of hogFunctions) {const templateId = hf.template_id ?? hf.template?.id+ const slackWorkspaceValue = hf.inputs?.slack_workspace?.value as number | undefinedconst slackChannelValue = hf.inputs?.channel?.value as string | undefinedconst webhookUrl = hf.inputs?.url?.value as string | undefined@@ -81,8 +117,9 @@ export function groupVisionAlertDestinations(hogFunctions: HogFunctionType[]): Vlet label: stringif (templateId === 'template-slack') {type = VISION_ALERT_NOTIFICATION_TYPE_SLACK- key = `slack:${slackChannelValue ?? hf.id}`- label = 'Slack'+ key = `slack:${slackWorkspaceValue ?? 'unknown'}:${slackChannelValue ?? hf.id}`+ const channelName = hf.name.match(/ → Slack (#\S+)$/)?.[1] ?? '#channel'+ label = slackDestinationLabel(slackIntegrations, slackWorkspaceValue, channelName)} else {type = VISION_ALERT_NOTIFICATION_TYPE_WEBHOOKkey = `webhook:${webhookUrl ?? hf.id}`