Skip to content

Commit a2cf1fa

Browse files
committed
Add investigate button to the insight card
1 parent 2b8b8af commit a2cf1fa

File tree

12 files changed

+97
-3
lines changed

12 files changed

+97
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ To set environment variables use .env file
6060
| JAEGER_UI_PATH | string | - | Path to custom Jaeger UI build |
6161
| IS_SANDBOX_ENABLED | boolean | false | Enable Sandbox (demo) mode |
6262
| ARE_INSIGHT_SUGGESTIONS_ENABLED | boolean | false | Enable insight suggestions |
63+
| IS_AGENTIC_ENABLED | boolean | false | Enable Agentic service capabilities |
6364
| GOOGLE_CLIENT_ID | string | - | Google client ID |
6465
| POSTHOG_API_KEY | string | - | PostHog API key |
6566
| POSTHOG_URL | string | - | PostHog URL |

src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/insightCards/common/InsightCard/index.tsx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Fragment, useEffect, useRef, useState } from "react";
22
import { usePrevious } from "../../../../../../../../hooks/usePrevious";
33
import { platform } from "../../../../../../../../platform";
44
import {
5+
useCreateIncidentFromInsightMutation,
56
useMarkInsightReadMutation,
67
useRecheckInsightMutation
78
} from "../../../../../../../../redux/services/digma";
@@ -71,10 +72,13 @@ export const InsightCard = ({
7172
const {
7273
isJaegerEnabled,
7374
areInsightSuggestionsEnabled,
75+
isAgenticEnabled,
7476
isSandboxModeEnabled
7577
} = useConfigSelector();
7678
const cardRef = useRef<HTMLDivElement>(null);
7779
const [showInfo, setShowInfo] = useState(false);
80+
const [createIncidentFromInsight, createIncidentFromInsightResult] =
81+
useCreateIncidentFromInsightMutation();
7882

7983
const isCritical = insight.criticality > HIGH_CRITICALITY_THRESHOLD;
8084

@@ -276,6 +280,28 @@ export const InsightCard = ({
276280
}
277281
};
278282

283+
const handleInvestigateButtonClick = () => {
284+
sendUserActionTrackingEvent(
285+
trackingEvents.INSIGHT_CARD_INVESTIGATE_BUTTON_CLICKED,
286+
{
287+
insightType: insight.type
288+
}
289+
);
290+
291+
void createIncidentFromInsight({
292+
insightId: insight.id
293+
})
294+
.unwrap()
295+
.then((data) => {
296+
const incidentId = data.incidentId;
297+
openURLInDefaultBrowser(`/agentic/incidents/${incidentId}`);
298+
})
299+
.catch(() => {
300+
// eslint-disable-next-line no-console
301+
console.error("Failed to create incident from insight");
302+
});
303+
};
304+
279305
if (viewMode === "compact") {
280306
return (
281307
<IssueCompactCard
@@ -435,6 +461,23 @@ export const InsightCard = ({
435461
label={"Suggestion"}
436462
/>
437463
);
464+
case "investigate":
465+
return (
466+
<s.InvestigateButton
467+
icon={
468+
createIncidentFromInsightResult.isLoading
469+
? () => <s.InvestigateButtonSpinner />
470+
: LightBulbWithScrewIcon
471+
}
472+
onClick={handleInvestigateButtonClick}
473+
isDisabled={createIncidentFromInsightResult.isLoading}
474+
label={
475+
createIncidentFromInsightResult.isLoading
476+
? "Investigating..."
477+
: "Investigate"
478+
}
479+
/>
480+
);
438481

439482
default:
440483
return null;
@@ -495,6 +538,10 @@ export const InsightCard = ({
495538
actions.push("openSuggestion");
496539
}
497540

541+
if (isAgenticEnabled && insight.isDismissible && platform === "Web") {
542+
actions.push("investigate");
543+
}
544+
498545
if (actions.length === 0) {
499546
return;
500547
}

src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/insightCards/common/InsightCard/styles.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import styled, { css } from "styled-components";
22
import { Card } from "../../../../../../../common/v3/Card";
33
import { NewButton } from "../../../../../../../common/v3/NewButton";
44
import { NewIconButton } from "../../../../../../../common/v3/NewIconButton";
5+
import { Spinner } from "../../../../../../../common/v3/Spinner";
56
import type { StyledCardProps } from "./types";
67

78
export const InsightFooter = styled.div`
@@ -68,6 +69,20 @@ export const SuggestionButton = styled(NewButton)`
6869
}
6970
`;
7071

72+
export const InvestigateButton = styled(SuggestionButton)`
73+
&:disabled {
74+
color: ${({ theme }) => theme.colors.v3.icon.white};
75+
76+
span {
77+
color: currentcolor;
78+
}
79+
}
80+
`;
81+
82+
export const InvestigateButtonSpinner = styled(Spinner)`
83+
color: currentcolor;
84+
`;
85+
7186
export const TraceActionButtonIconContainer = styled.div`
7287
display: flex;
7388
align-items: center;

src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/insightCards/common/InsightCard/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,5 @@ export type Action =
5757
| "openTrace"
5858
| "openLiveView"
5959
| "pin"
60-
| "openSuggestion";
60+
| "openSuggestion"
61+
| "investigate";

src/components/Insights/tracking.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export const trackingEvents = addPrefix(
1313
"insight card create ticket link clicked",
1414
INSIGHT_CARD_MARK_AS_READ_BUTTON_CLICKED:
1515
"insight card mark as read button clicked",
16+
INSIGHT_CARD_INVESTIGATE_BUTTON_CLICKED:
17+
"insight card investigate button clicked",
1618
REFRESH_BUTTON_CLICKED: "refresh button clicked",
1719
INSIGHT_CARD_ASSET_LINK_CLICKED: "insight card asset link clicked",
1820
ISSUES_FILTER_PRESET_BUTTON_CLICKED: "issues filter preset button clicked",

src/components/common/App/ConfigContext.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ export const initialState: ConfigContextData = {
3333
userId: isString(window.userId) ? window.userId : "",
3434
isDigmathonGameFinished: window.isDigmathonGameFinished === true,
3535
runConfig: undefined,
36-
areInsightSuggestionsEnabled: window.areInsightSuggestionsEnabled === true,
36+
areInsightSuggestionsEnabled: window.isAgenticEnabled === true,
37+
isAgenticEnabled: window.isAgenticEnabled === true,
3738
googleClientId: isString(window.googleClientId) ? window.googleClientId : ""
3839
};
3940

src/components/common/App/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ export interface ConfigContextData {
181181
userInfo?: UserInfo;
182182
runConfig?: RunConfiguration;
183183
areInsightSuggestionsEnabled: boolean;
184+
isAgenticEnabled: boolean;
184185
googleClientId: string;
185186
}
186187

src/globals.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ declare global {
6767
isDigmathonGameFinished?: unknown;
6868
isLoggingEnabled?: unknown;
6969
areInsightSuggestionsEnabled?: unknown;
70+
isAgenticEnabled?: unknown;
7071
googleClientId?: unknown;
7172
isSandboxModeEnabled?: unknown;
7273
postHogApiKey?: unknown;

src/redux/services/digma.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import type {
55
CloseIncidentPayload,
66
CreateEnvironmentPayload,
77
CreateEnvironmentResponse,
8+
CreateIncidentFromInsightPayload,
9+
CreateIncidentFromInsightResponse,
810
DeleteEnvironmentPayload,
911
DeleteEnvironmentResponse,
1012
DeleteIncidentAgentDirectivePayload,
@@ -739,6 +741,15 @@ export const digmaApi = createApi({
739741
method: "DELETE"
740742
}),
741743
invalidatesTags: ["IncidentAgentMCPServer"]
744+
}),
745+
createIncidentFromInsight: builder.mutation<
746+
CreateIncidentFromInsightResponse,
747+
CreateIncidentFromInsightPayload
748+
>({
749+
query: ({ insightId }) => ({
750+
url: `Agentic/issue-entry/${window.encodeURIComponent(insightId)}`,
751+
method: "POST"
752+
})
742753
})
743754
})
744755
});
@@ -809,5 +820,6 @@ export const {
809820
useTestIncidentAgentMCPServerMutation,
810821
useAddIncidentAgentMCPServerMutation,
811822
useUpdateIncidentAgentMCPServerMutation,
812-
useDeleteIncidentAgentMCPServerMutation
823+
useDeleteIncidentAgentMCPServerMutation,
824+
useCreateIncidentFromInsightMutation
813825
} = digmaApi;

src/redux/services/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,3 +1288,11 @@ export interface UpdateMCPServerPayload {
12881288
export interface DeleteMCPServerPayload {
12891289
id: string;
12901290
}
1291+
1292+
export interface CreateIncidentFromInsightPayload {
1293+
insightId: string;
1294+
}
1295+
1296+
export interface CreateIncidentFromInsightResponse {
1297+
incidentId: string;
1298+
}

0 commit comments

Comments
 (0)