SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
feat(alert-channel-integrations): incidentio frontend (#12645)
Nikhil Mantri297d3dd44be0
diff --git a/frontend/public/locales/en-GB/channels.json b/frontend/public/locales/en-GB/channels.jsonindex 9043f73bb5..51595bdd10 100644--- a/frontend/public/locales/en-GB/channels.json+++ b/frontend/public/locales/en-GB/channels.json@@ -75,6 +75,23 @@"field_jsmops_tags": "Tags","placeholder_jsmops_tags": "Type a tag and press Enter","help_jsmops_tags": "Tags added to every alert.",+ "incidentio_tip": "Create an HTTP alert source in incident.io (On-call \u2192 Alert routing \u2192 Sources) and paste its URL and token below.",+ "incidentio_tip_link": "Learn how",+ "field_incidentio_url": "Alert source URL",+ "help_incidentio_url": "The alert events URL from the source's setup page, e.g. https://api.incident.io/v2/alert_events/http/<source_config_id>.",+ "field_incidentio_token": "Token",+ "help_incidentio_token": "The alert source's secret token, from the same setup page.",+ "field_incidentio_title": "Title",+ "help_incidentio_title": "Template for the alert title. Kept stable while the alert fires \u2014 incident.io ignores content updates on repeat events.",+ "field_incidentio_description": "Description",+ "help_incidentio_description": "Template for the alert description. Markdown, rendered natively by incident.io.",+ "incidentio_required_fields": "Alert source URL and token are required",+ "incidentio_url_invalid": "URL must be an incident.io alert events URL (https://api.incident.io/v2/alert_events/http/<source_config_id>)",+ "field_incidentio_metadata": "Additional metadata",+ "help_incidentio_metadata": "Key-value pairs added to every alert's metadata, on top of the alert's labels (these win on a key clash). Values may use templates, e.g. {{ .CommonLabels.severity }}.",+ "placeholder_incidentio_metadata_key": "Key",+ "placeholder_incidentio_metadata_value": "Value",+ "button_incidentio_add_metadata": "Add metadata","field_slack_recipient": "Recipient","field_slack_title": "Title",diff --git a/frontend/public/locales/en/channels.json b/frontend/public/locales/en/channels.jsonindex 915d877090..ec3b3ce5e3 100644--- a/frontend/public/locales/en/channels.json+++ b/frontend/public/locales/en/channels.json@@ -75,6 +75,23 @@"field_jsmops_tags": "Tags","placeholder_jsmops_tags": "Type a tag and press Enter","help_jsmops_tags": "Tags added to every alert.",+ "incidentio_tip": "Create an HTTP alert source in incident.io (On-call \u2192 Alert routing \u2192 Sources) and paste its URL and token below.",+ "incidentio_tip_link": "Learn how",+ "field_incidentio_url": "Alert source URL",+ "help_incidentio_url": "The alert events URL from the source's setup page, e.g. https://api.incident.io/v2/alert_events/http/<source_config_id>.",+ "field_incidentio_token": "Token",+ "help_incidentio_token": "The alert source's secret token, from the same setup page.",+ "field_incidentio_title": "Title",+ "help_incidentio_title": "Template for the alert title. Kept stable while the alert fires \u2014 incident.io ignores content updates on repeat events.",+ "field_incidentio_description": "Description",+ "help_incidentio_description": "Template for the alert description. Markdown, rendered natively by incident.io.",+ "incidentio_required_fields": "Alert source URL and token are required",+ "incidentio_url_invalid": "URL must be an incident.io alert events URL (https://api.incident.io/v2/alert_events/http/<source_config_id>)",+ "field_incidentio_metadata": "Additional metadata",+ "help_incidentio_metadata": "Key-value pairs added to every alert's metadata, on top of the alert's labels (these win on a key clash). Values may use templates, e.g. {{ .CommonLabels.severity }}.",+ "placeholder_incidentio_metadata_key": "Key",+ "placeholder_incidentio_metadata_value": "Value",+ "button_incidentio_add_metadata": "Add metadata","field_slack_recipient": "Recipient","field_slack_title": "Title","field_slack_description": "Description",diff --git a/frontend/src/container/AllAlertChannels/__tests__/CreateAlertChannel.test.tsx b/frontend/src/container/AllAlertChannels/__tests__/CreateAlertChannel.test.tsxindex a24a3a3868..6c57706d67 100644--- a/frontend/src/container/AllAlertChannels/__tests__/CreateAlertChannel.test.tsx+++ b/frontend/src/container/AllAlertChannels/__tests__/CreateAlertChannel.test.tsx@@ -2,6 +2,7 @@ import CreateAlertChannels from 'container/CreateAlertChannels';import { ChannelType } from 'container/CreateAlertChannels/config';import {GoogleChatInitialConfig,+ IncidentIOInitialConfig,JiraInitialConfig,JsmOpsInitialConfig,} from 'container/CreateAlertChannels/defaults';@@ -737,6 +738,122 @@ describe('Create Alert Channel', () => {});});});+ describe('incident.io', () => {+ const incidentIOURL =+ 'https://api.incident.io/v2/alert_events/http/01M0D1JNVBGBGVTWX053EM12XV';++ beforeEach(() => {+ render(<CreateAlertChannels preType={ChannelType.IncidentIO} />);+ });++ it('Should display the URL and token fields with the docs tip', () => {+ testLabelInputAndHelpValue({+ labelText: 'field_incidentio_url',+ testId: 'incidentio-url-textbox',+ });+ testLabelInputAndHelpValue({+ labelText: 'field_incidentio_token',+ testId: 'incidentio-token-textbox',+ });+ expect(screen.getByTestId('incidentio-tip')).toBeInTheDocument();+ expect(+ screen.getByRole('link', { name: 'incidentio_tip_link' }),+ ).toHaveAttribute(+ 'href',+ 'https://signoz.io/docs/alerts-management/notification-channel/incidentio/',+ );+ });++ it('Should block save when the URL or token is missing', async () => {+ const user = userEvent.setup();+ await user.type(+ screen.getByTestId('channel-name-textbox'),+ 'incidentio-channel',+ );++ await user.click(screen.getByTestId('save-channel-button'));++ await waitFor(() =>+ expect(errorNotification).toHaveBeenCalledWith({+ message: 'Error',+ description: 'incidentio_required_fields',+ }),+ );+ });++ it('Should display an error when the URL is not an alert events URL', async () => {+ const user = userEvent.setup();+ await user.type(+ screen.getByTestId('channel-name-textbox'),+ 'incidentio-channel',+ );+ await user.type(+ screen.getByTestId('incidentio-url-textbox'),+ 'https://api.incident.io/v2/incidents',+ );+ await user.type(screen.getByTestId('incidentio-token-textbox'), 'tok-abc');++ await user.click(screen.getByTestId('save-channel-button'));++ await waitFor(() =>+ expect(errorNotification).toHaveBeenCalledWith({+ message: 'Error',+ description: 'incidentio_url_invalid',+ }),+ );+ }, 15000);++ it('Should send an incidentio_configs payload with prefilled defaults', async () => {+ let requestBody: unknown;+ server.use(+ rest.post('http://localhost/api/v1/channels', async (req, res, ctx) => {+ requestBody = await req.json();+ return res(+ ctx.status(201),+ ctx.json({ status: 'success', data: 'channel created' }),+ );+ }),+ );++ const user = userEvent.setup();+ await user.type(+ screen.getByTestId('channel-name-textbox'),+ 'incidentio-channel',+ );+ await user.type(+ screen.getByTestId('incidentio-url-textbox'),+ incidentIOURL,+ );+ await user.type(screen.getByTestId('incidentio-token-textbox'), 'tok-abc');++ await user.click(screen.getByTestId('incidentio-metadata-add'));+ await user.type(screen.getByTestId('incidentio-metadata-key-0'), 'team');+ await user.type(screen.getByTestId('incidentio-metadata-value-0'), 'core');++ await user.click(screen.getByTestId('save-channel-button'));++ await waitFor(() =>+ expect(successNotification).toHaveBeenCalledWith({+ message: 'Success',+ description: 'channel_creation_done',+ }),+ );++ expect(requestBody).toStrictEqual({+ name: 'incidentio-channel',+ incidentio_configs: [+ {+ url: incidentIOURL,+ token: 'tok-abc',+ send_resolved: true,+ title: IncidentIOInitialConfig.title,+ description: IncidentIOInitialConfig.description,+ metadata: { team: 'core' },+ },+ ],+ });+ }, 15000);+ });describe('Changing the channel type', () => {async function selectType(user: ReturnType<typeof userEvent.setup>,diff --git a/frontend/src/container/AllAlertChannels/__tests__/EditAlertChannelSave.test.tsx b/frontend/src/container/AllAlertChannels/__tests__/EditAlertChannelSave.test.tsxindex fe4326ea05..fe05a54a0c 100644--- a/frontend/src/container/AllAlertChannels/__tests__/EditAlertChannelSave.test.tsx+++ b/frontend/src/container/AllAlertChannels/__tests__/EditAlertChannelSave.test.tsx@@ -90,6 +90,40 @@ describe('EditAlertChannels save', () => {await waitFor(() => expect(edit.calls).toHaveLength(1));});+ it('sends an incidentio_configs payload when editing an incident.io channel', async () => {+ const edit = mockEditChannel();+ render(+ <EditAlertChannels+ channelId="4"+ initialValue={{+ type: 'incidentio',+ name: 'incidentio-channel',+ url: 'https://api.incident.io/v2/alert_events/http/01M0D1JNVBGBGVTWX053EM12XV',+ token: 'tok-abc',+ send_resolved: true,+ metadata: { env: 'prod' },+ }}+ />,+ );++ const user = userEvent.setup();+ await user.click(screen.getByTestId('save-channel-button'));++ await waitFor(() => expect(edit.calls).toHaveLength(1));+ expect(edit.calls[0].id).toBe('4');+ expect(edit.calls[0].body).toStrictEqual({+ name: 'incidentio-channel',+ incidentio_configs: [+ {+ url: 'https://api.incident.io/v2/alert_events/http/01M0D1JNVBGBGVTWX053EM12XV',+ token: 'tok-abc',+ send_resolved: true,+ metadata: { env: 'prod' },+ },+ ],+ });+ });+it('persists send_resolved toggle in the edit request', async () => {const edit = mockEditChannel();render(diff --git a/frontend/src/container/CreateAlertChannels/config.ts b/frontend/src/container/CreateAlertChannels/config.tsindex ce8a443f1b..67d5e5e6fb 100644--- a/frontend/src/container/CreateAlertChannels/config.ts+++ b/frontend/src/container/CreateAlertChannels/config.ts@@ -107,6 +107,7 @@ export enum ChannelType {GoogleChat = 'googlechat',Jira = 'jira',JsmOps = 'jsmops',+ IncidentIO = 'incidentio',}// LabelFilterStatement will be used for preparing filter conditions / matchers@@ -159,6 +160,22 @@ export interface JiraChannel extends Channel {reopen_duration?: string;}+// IncidentIOChannel configures the incident.io alert channel, backed by an+// incident.io HTTP alert source (Alert Events V2 API).+export interface IncidentIOChannel extends Channel {+ // per-source alert events URL, e.g.+ // https://api.incident.io/v2/alert_events/http/<source_config_id>+ url: string;+ // the alert source's secret token+ token: string;+ // alert title template+ title?: string;+ // alert body template (markdown, rendered natively by incident.io)+ description?: string;+ // extra metadata pairs merged over the alert's labels (channel wins on clash)+ metadata?: Record<string, string>;+}+// JsmOpsChannel configures the Jira Service Management Ops alert channel// (ex-Opsgenie alert API). Auth is the JSM integration API key.export interface JsmOpsChannel extends Channel {diff --git a/frontend/src/container/CreateAlertChannels/defaults.ts b/frontend/src/container/CreateAlertChannels/defaults.tsindex e15fe36e1e..dda8238e63 100644--- a/frontend/src/container/CreateAlertChannels/defaults.ts+++ b/frontend/src/container/CreateAlertChannels/defaults.ts@@ -2,6 +2,7 @@ import {ChannelType,EmailChannel,GoogleChatChannel,+ IncidentIOChannel,JiraChannel,JsmOpsChannel,MsTeamsChannel,@@ -144,6 +145,29 @@ export const JsmOpsInitialConfig: Partial<JsmOpsChannel> = {tags: ['signoz-alert'],};+// mirrors DefaultIncidentIOTitleTemplate / DefaultIncidentIODescriptionTemplate+// in pkg/types/alertmanagertypes/incidentio.go, applied by the backend when+// title / description are left empty. send_resolved is seeded on so incident.io+// alerts resolve with the rule (the backend cannot default it).+export const IncidentIOInitialConfig: Partial<IncidentIOChannel> = {+ send_resolved: true,+ title: `[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ .CommonLabels.alertname }}`,+ description: `{{ range .Alerts -}}+**Alert:** {{ .Labels.alertname }}{{ if .Labels.severity }} ({{ .Labels.severity }}){{ end }}++{{ if .Annotations.summary }}**Summary:** {{ .Annotations.summary }}++{{ end }}{{ if .Annotations.description }}**Description:** {{ .Annotations.description }}++{{ end }}{{ if .GeneratorURL }}[View in SigNoz]({{ .GeneratorURL }})++{{ end }}{{ if .Annotations.related_logs }}[View related logs]({{ .Annotations.related_logs }})++{{ end }}{{ if .Annotations.related_traces }}[View related traces]({{ .Annotations.related_traces }})++{{ end }}{{ end }}`,+};+export const EmailInitialConfig: Partial<EmailChannel> = {send_resolved: true,html: `<!--@@ -553,7 +577,8 @@ export const ChannelInitialConfig: Record<EmailChannel &GoogleChatChannel &JiraChannel &- JsmOpsChannel+ JsmOpsChannel &+ IncidentIOChannel>> = {[ChannelType.Slack]: SlackInitialConfig,@@ -561,6 +586,7 @@ export const ChannelInitialConfig: Record<[ChannelType.GoogleChat]: GoogleChatInitialConfig,[ChannelType.Jira]: JiraInitialConfig,[ChannelType.JsmOps]: JsmOpsInitialConfig,+ [ChannelType.IncidentIO]: IncidentIOInitialConfig,[ChannelType.Pagerduty]: PagerInitialConfig,[ChannelType.Opsgenie]: OpsgenieInitialConfig,[ChannelType.Email]: EmailInitialConfig,diff --git a/frontend/src/container/CreateAlertChannels/index.tsx b/frontend/src/container/CreateAlertChannels/index.tsxindex 11a1f6c6a7..2e9691b187 100644--- a/frontend/src/container/CreateAlertChannels/index.tsx+++ b/frontend/src/container/CreateAlertChannels/index.tsx@@ -32,6 +32,7 @@ import {ChannelType,EmailChannel,GoogleChatChannel,+ IncidentIOChannel,JiraChannel,JsmOpsChannel,MsTeamsChannel,@@ -45,9 +46,11 @@ import { ChannelInitialConfig } from './defaults';import {isChannelType,isValidGoogleChatWebhookURL,+ isValidIncidentIOURL,isValidJiraReopenDuration,isValidJiraSiteURL,prepareGoogleChatRequest,+ prepareIncidentIORequest,prepareJiraRequest,prepareJsmOpsRequest,} from './utils';@@ -77,7 +80,8 @@ function CreateAlertChannels({EmailChannel &GoogleChatChannel &JiraChannel &- JsmOpsChannel+ JsmOpsChannel &+ IncidentIOChannel>>(() => ({send_resolved: true,@@ -550,6 +554,56 @@ function CreateAlertChannels({showErrorModal,]);+ const validateIncidentIOConfig = useCallback((): boolean => {+ if (!selectedConfig.url || !selectedConfig.token) {+ notifications.error({+ message: 'Error',+ description: t('incidentio_required_fields'),+ });+ return false;+ }++ if (!isValidIncidentIOURL(selectedConfig.url)) {+ notifications.error({+ message: 'Error',+ description: t('incidentio_url_invalid'),+ });+ return false;+ }++ return true;+ }, [selectedConfig.url, selectedConfig.token, notifications, t]);++ const onIncidentIOHandler = useCallback(async () => {+ if (!validateIncidentIOConfig()) {+ return { status: 'failed', statusMessage: t('channel_creation_failed') };+ }++ setSavingState(true);++ try {+ await createChannel({ data: prepareIncidentIORequest(selectedConfig) });+ notifications.success({+ message: 'Success',+ description: t('channel_creation_done'),+ });+ history.replace(ROUTES.ALL_CHANNELS);+ return { status: 'success', statusMessage: t('channel_creation_done') };+ } catch (error) {+ showErrorModal(toAPIError(error as ErrorType<RenderErrorResponseDTO>));+ return { status: 'failed', statusMessage: t('channel_creation_failed') };+ } finally {+ setSavingState(false);+ }+ }, [+ validateIncidentIOConfig,+ createChannel,+ selectedConfig,+ notifications,+ t,+ showErrorModal,+ ]);+const onSaveHandler = useCallback(async (value: ChannelType) => {if (!selectedConfig.name) {@@ -570,6 +624,7 @@ function CreateAlertChannels({[ChannelType.GoogleChat]: onGoogleChatHandler,[ChannelType.Jira]: onJiraHandler,[ChannelType.JsmOps]: onJsmOpsHandler,+ [ChannelType.IncidentIO]: onIncidentIOHandler,};if (isChannelType(value)) {@@ -604,6 +659,7 @@ function CreateAlertChannels({onGoogleChatHandler,onJiraHandler,onJsmOpsHandler,+ onIncidentIOHandler,notifications,t,],@@ -662,6 +718,13 @@ function CreateAlertChannels({}await testChannel({ data: prepareJsmOpsRequest(selectedConfig) });break;+ case ChannelType.IncidentIO:+ if (!validateIncidentIOConfig()) {+ setTestingState(false);+ return;+ }+ await testChannel({ data: prepareIncidentIORequest(selectedConfig) });+ break;default:notifications.error({message: 'Error',@@ -712,6 +775,7 @@ function CreateAlertChannels({validateGoogleChatConfig,validateJiraConfig,validateJsmOpsConfig,+ validateIncidentIOConfig,testChannel,notifications,],diff --git a/frontend/src/container/CreateAlertChannels/utils.ts b/frontend/src/container/CreateAlertChannels/utils.tsindex ce096963c2..f570aa465e 100644--- a/frontend/src/container/CreateAlertChannels/utils.ts+++ b/frontend/src/container/CreateAlertChannels/utils.ts@@ -1,4 +1,5 @@import {+ AlertmanagertypesIncidentIOReceiverConfigDTO,AlertmanagertypesJiraReceiverConfigDTO,AlertmanagertypesJSMOpsReceiverConfigDTO,AlertmanagertypesPostableChannelDTO,@@ -9,6 +10,7 @@ import {import {ChannelType,GoogleChatChannel,+ IncidentIOChannel,JiraChannel,JsmOpsChannel,} from './config';@@ -168,3 +170,50 @@ export const prepareJsmOpsRequest = (jsmops_configs: [jsmops],};};++const INCIDENTIO_EVENTS_PATH_PREFIX = '/v2/alert_events/http/';++// the backend enforces the same rule, this is only for a nicer error experience+export const isValidIncidentIOURL = (url: string): boolean => {+ try {+ const { protocol, pathname } = new URL(url);+ const idx = pathname.indexOf(INCIDENTIO_EVENTS_PATH_PREFIX);+ return (+ protocol === 'https:' &&+ idx !== -1 &&+ pathname.length > idx + INCIDENTIO_EVENTS_PATH_PREFIX.length+ );+ } catch {+ return false;+ }+};++// create, update and test all send the same body shape. Optional fields are+// omitted when empty so the backend applies its defaults.+export const prepareIncidentIORequest = (+ config: Partial<IncidentIOChannel>,+): AlertmanagertypesPostableChannelDTO => {+ const incidentio: AlertmanagertypesIncidentIOReceiverConfigDTO = {+ url: config.url || '',+ token: config.token || '',+ send_resolved: config.send_resolved || false,+ };++ if (config.title) {+ incidentio.title = config.title;+ }+ if (config.description) {+ incidentio.description = config.description;+ }+ const metadata = Object.fromEntries(+ Object.entries(config.metadata || {}).filter(([key]) => key.trim() !== ''),+ );+ if (Object.keys(metadata).length > 0) {+ incidentio.metadata = metadata;+ }++ return {+ name: config.name || '',+ incidentio_configs: [incidentio],+ };+};diff --git a/frontend/src/container/EditAlertChannels/index.tsx b/frontend/src/container/EditAlertChannels/index.tsxindex 607b8320ab..922f57b2f3 100644--- a/frontend/src/container/EditAlertChannels/index.tsx+++ b/frontend/src/container/EditAlertChannels/index.tsx@@ -25,6 +25,7 @@ import {ChannelType,EmailChannel,GoogleChatChannel,+ IncidentIOChannel,JiraChannel,JsmOpsChannel,MsTeamsChannel,@@ -36,9 +37,11 @@ import {} from 'container/CreateAlertChannels/config';import {isValidGoogleChatWebhookURL,+ isValidIncidentIOURL,isValidJiraReopenDuration,isValidJiraSiteURL,prepareGoogleChatRequest,+ prepareIncidentIORequest,prepareJiraRequest,prepareJsmOpsRequest,} from 'container/CreateAlertChannels/utils';@@ -66,7 +69,8 @@ function EditAlertChannels({EmailChannel &GoogleChatChannel &JiraChannel &- JsmOpsChannel+ JsmOpsChannel &+ IncidentIOChannel>>({...initialValue,@@ -578,6 +582,61 @@ function EditAlertChannels({t,]);+ const validateIncidentIOConfig = useCallback((): string => {+ if (!selectedConfig.url || !selectedConfig.token) {+ return t('incidentio_required_fields');+ }++ if (!isValidIncidentIOURL(selectedConfig.url)) {+ return t('incidentio_url_invalid');+ }++ return '';+ }, [selectedConfig, t]);++ const onIncidentIOEditHandler = useCallback(async () => {+ const validationError = validateIncidentIOConfig();++ if (validationError !== '') {+ notifications.error({+ message: 'Error',+ description: validationError,+ });+ return { status: 'failed', statusMessage: validationError };+ }++ setSavingState(true);++ try {+ await updateChannel({+ pathParams: { id },+ data: prepareIncidentIORequest(selectedConfig),+ });+ notifications.success({+ message: 'Success',+ description: t('channel_edit_done'),+ });+ history.replace(ROUTES.ALL_CHANNELS);+ return { status: 'success', statusMessage: t('channel_edit_done') };+ } catch (error) {+ const apiError = notifyError(error);+ return {+ status: 'failed',+ statusMessage: apiError.getErrorMessage() || t('channel_edit_failed'),+ };+ } finally {+ setSavingState(false);+ }+ }, [+ validateIncidentIOConfig,+ updateChannel,+ id,+ selectedConfig,+ notifications,+ notifyError,+ t,+ ]);+const onSaveHandler = useCallback(async (value: ChannelType) => {let result;@@ -599,6 +658,8 @@ function EditAlertChannels({result = await onJiraEditHandler();} else if (value === ChannelType.JsmOps) {result = await onJsmOpsEditHandler();+ } else if (value === ChannelType.IncidentIO) {+ result = await onIncidentIOEditHandler();}logEvent('Alert Channel: Save channel', {type: value,@@ -620,6 +681,7 @@ function EditAlertChannels({onGoogleChatEditHandler,onJiraEditHandler,onJsmOpsEditHandler,+ onIncidentIOEditHandler,],);@@ -701,6 +763,19 @@ function EditAlertChannels({await testChannel({ data: prepareJsmOpsRequest(selectedConfig) });break;}+ case ChannelType.IncidentIO: {+ const validationError = validateIncidentIOConfig();+ if (validationError !== '') {+ notifications.error({+ message: 'Error',+ description: validationError,+ });+ setTestingState(false);+ return;+ }+ await testChannel({ data: prepareIncidentIORequest(selectedConfig) });+ break;+ }default:notifications.error({message: 'Error',@@ -740,6 +815,7 @@ function EditAlertChannels({validateGoogleChatConfig,validateJiraConfig,validateJsmOpsConfig,+ validateIncidentIOConfig,testChannel,prepareWebhookRequest,preparePagerRequest,diff --git a/frontend/src/container/FormAlertChannels/Settings/IncidentIo.tsx b/frontend/src/container/FormAlertChannels/Settings/IncidentIo.tsxnew file mode 100644index 0000000000..143ab8f3ea--- /dev/null+++ b/frontend/src/container/FormAlertChannels/Settings/IncidentIo.tsx@@ -0,0 +1,172 @@+import { Dispatch, SetStateAction, useState } from 'react';+import { useTranslation } from 'react-i18next';+import { Minus, Plus } from '@signozhq/icons';+import { Button, Form, Input } from 'antd';+import { Typography } from '@signozhq/ui/typography';++import { IncidentIOChannel } from '../../CreateAlertChannels/config';++interface MetadataRow {+ key: string;+ value: string;+}++function IncidentIOSettings({+ setSelectedConfig,+ initialMetadata,+}: IncidentIOProps): JSX.Element {+ const { t } = useTranslation('channels');+ const [metadataRows, setMetadataRows] = useState<MetadataRow[]>(() =>+ Object.entries(initialMetadata || {}).map(([key, value]) => ({+ key,+ value,+ })),+ );++ const update = (patch: Partial<IncidentIOChannel>): void =>+ setSelectedConfig((value) => ({ ...value, ...patch }));++ const syncMetadata = (rows: MetadataRow[]): void => {+ setMetadataRows(rows);+ update({+ metadata: Object.fromEntries(+ rows+ .filter((row) => row.key.trim() !== '')+ .map((row) => [row.key, row.value]),+ ),+ });+ };++ return (+ <>+ <Typography.Text+ color="muted"+ size="sm"+ testId="incidentio-tip"+ style={{ display: 'block', marginBottom: 16 }}+ >+ {t('incidentio_tip')}{' '}+ <Typography.Link+ href="https://signoz.io/docs/alerts-management/notification-channel/incidentio/"+ target="_blank"+ rel="noopener noreferrer"+ >+ {t('incidentio_tip_link')}+ </Typography.Link>+ </Typography.Text>++ <Form.Item+ name="url"+ label={t('field_incidentio_url')}+ help={t('help_incidentio_url')}+ required+ >+ <Input+ onChange={(event): void => update({ url: event.target.value })}+ data-testid="incidentio-url-textbox"+ />+ </Form.Item>++ <Form.Item+ name="token"+ label={t('field_incidentio_token')}+ help={t('help_incidentio_token')}+ required+ >+ <Input+ type="password"+ onChange={(event): void => update({ token: event.target.value })}+ data-testid="incidentio-token-textbox"+ />+ </Form.Item>++ <Form.Item+ name="title"+ label={t('field_incidentio_title')}+ help={t('help_incidentio_title')}+ >+ <Input.TextArea+ rows={2}+ onChange={(event): void => update({ title: event.target.value })}+ data-testid="incidentio-title-textarea"+ />+ </Form.Item>++ <Form.Item+ name="description"+ label={t('field_incidentio_description')}+ help={t('help_incidentio_description')}+ >+ <Input.TextArea+ rows={6}+ onChange={(event): void => update({ description: event.target.value })}+ data-testid="incidentio-description-textarea"+ />+ </Form.Item>++ <Form.Item+ label={t('field_incidentio_metadata')}+ help={t('help_incidentio_metadata')}+ >+ {metadataRows.map((row, index) => (+ // rows have no stable identity beyond their position+ // eslint-disable-next-line react/no-array-index-key+ <div key={index} style={{ display: 'flex', gap: 8, marginBottom: 8 }}>+ <Input+ placeholder={t('placeholder_incidentio_metadata_key')}+ value={row.key}+ onChange={(event): void =>+ syncMetadata(+ metadataRows.map((r, i) =>+ i === index ? { ...r, key: event.target.value } : r,+ ),+ )+ }+ data-testid={`incidentio-metadata-key-${index}`}+ />+ <Input+ placeholder={t('placeholder_incidentio_metadata_value')}+ value={row.value}+ onChange={(event): void =>+ syncMetadata(+ metadataRows.map((r, i) =>+ i === index ? { ...r, value: event.target.value } : r,+ ),+ )+ }+ data-testid={`incidentio-metadata-value-${index}`}+ />+ <Button+ icon={<Minus size={14} />}+ onClick={(): void =>+ syncMetadata(metadataRows.filter((_, i) => i !== index))+ }+ data-testid={`incidentio-metadata-remove-${index}`}+ />+ </div>+ ))}+ <Button+ type="dashed"+ icon={<Plus size={14} />}+ onClick={(): void =>+ syncMetadata([...metadataRows, { key: '', value: '' }])+ }+ data-testid="incidentio-metadata-add"+ >+ {t('button_incidentio_add_metadata')}+ </Button>+ </Form.Item>+ </>+ );+}++interface IncidentIOProps {+ setSelectedConfig: Dispatch<SetStateAction<Partial<IncidentIOChannel>>>;+ initialMetadata?: Record<string, string>;+}++IncidentIOSettings.defaultProps = {+ initialMetadata: undefined,+};++export default IncidentIOSettings;diff --git a/frontend/src/container/FormAlertChannels/index.tsx b/frontend/src/container/FormAlertChannels/index.tsxindex ffb7e5d170..c0a2d6d1ee 100644--- a/frontend/src/container/FormAlertChannels/index.tsx+++ b/frontend/src/container/FormAlertChannels/index.tsx@@ -10,6 +10,7 @@ import {ChannelType,EmailChannel,GoogleChatChannel,+ IncidentIOChannel,JiraChannel,JsmOpsChannel,OpsgenieChannel,@@ -21,6 +22,7 @@ import history from 'lib/history';import EmailSettings from './Settings/Email';import GoogleChatSettings from './Settings/GoogleChat';+import IncidentIOSettings from './Settings/IncidentIo';import JiraSettings from './Settings/Jira';import JsmOpsSettings from './Settings/JsmOps';import MsTeamsSettings from './Settings/MsTeams';@@ -61,6 +63,13 @@ function FormAlertChannels({return <JiraSettings setSelectedConfig={setSelectedConfig} />;case ChannelType.JsmOps:return <JsmOpsSettings setSelectedConfig={setSelectedConfig} />;+ case ChannelType.IncidentIO:+ return (+ <IncidentIOSettings+ setSelectedConfig={setSelectedConfig}+ initialMetadata={initialValue?.metadata as Record<string, string>}+ />+ );case ChannelType.Opsgenie:return <OpsgenieSettings setSelectedConfig={setSelectedConfig} />;case ChannelType.Email:@@ -157,6 +166,14 @@ function FormAlertChannels({<Select.Option value="jsmops" key="jsmops" data-testid="select-option">Jira Service Management Ops</Select.Option>++ <Select.Option+ value="incidentio"+ key="incidentio"+ data-testid="select-option"+ >+ incident.io+ </Select.Option></Select></Form.Item>@@ -207,7 +224,8 @@ interface FormAlertChannelsProps {EmailChannel &GoogleChatChannel &JiraChannel &- JsmOpsChannel+ JsmOpsChannel &+ IncidentIOChannel>>>;diff --git a/frontend/src/pages/ChannelsEdit/index.tsx b/frontend/src/pages/ChannelsEdit/index.tsxindex 905c0e36b6..4e415610b0 100644--- a/frontend/src/pages/ChannelsEdit/index.tsx+++ b/frontend/src/pages/ChannelsEdit/index.tsx@@ -11,6 +11,7 @@ import ROUTES from 'constants/routes';import {ChannelType,GoogleChatChannel,+ IncidentIOChannel,JiraChannel,JsmOpsChannel,MsTeamsChannel,@@ -69,7 +70,8 @@ function ChannelsEdit(): JSX.Element {MsTeamsChannel &GoogleChatChannel &JiraChannel &- JsmOpsChannel+ JsmOpsChannel &+ IncidentIOChannel>;} => {let channel: Partial<@@ -79,7 +81,8 @@ function ChannelsEdit(): JSX.Element {MsTeamsChannel &GoogleChatChannel &JiraChannel &- JsmOpsChannel+ JsmOpsChannel &+ IncidentIOChannel> = {name: '',};@@ -135,6 +138,15 @@ function ChannelsEdit(): JSX.Element {};}+ if (value && 'incidentio_configs' in value) {+ const [incidentIOConfig] = value.incidentio_configs;+ channel = incidentIOConfig;+ return {+ type: ChannelType.IncidentIO,+ channel,+ };+ }+if (value && 'jsmops_configs' in value) {const [jsmopsConfig] = value.jsmops_configs;channel = jsmopsConfig;