Skip to content

Commit 25feb32

Browse files
committed
Get span errors via REST API
1 parent 83376fc commit 25feb32

File tree

5 files changed

+20
-51
lines changed

5 files changed

+20
-51
lines changed

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default tseslint.config(
1717
parserOptions: {
1818
project: "./tsconfig.eslint.json",
1919
tsconfigRootDir: import.meta.dirname,
20-
ecmaVersion: 2022
20+
ecmaVersion: 2023
2121
}
2222
},
2323
rules: {

src/components/Errors/Errors.stories.tsx

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import type { Meta, StoryObj } from "@storybook/react";
22
import { Errors } from ".";
33
import { ConfigContext, initialState } from "../common/App/ConfigContext";
44
import type { ConfigContextData } from "../common/App/types";
5-
import { actions } from "./actions";
6-
import { mockedErrorsData } from "./mockData";
75

86
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
97
const mockedConfig: ConfigContextData = {
@@ -48,34 +46,10 @@ export default meta;
4846
type Story = StoryObj<typeof Errors>;
4947

5048
// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
51-
export const ErrorsList: Story = {
52-
play: () => {
53-
window.setTimeout(() => {
54-
window.postMessage({
55-
type: "digma",
56-
action: actions.SET_ERRORS_DATA,
57-
payload: mockedErrorsData
58-
});
59-
}, 1000);
60-
}
61-
};
49+
export const ErrorsList: Story = {};
6250

6351
export const ErrorDetails: Story = {
6452
args: {
6553
errorId: "1"
6654
}
6755
};
68-
69-
export const Empty: Story = {
70-
play: () => {
71-
window.setTimeout(() => {
72-
window.postMessage({
73-
type: "digma",
74-
action: actions.SET_ERRORS_DATA,
75-
payload: {
76-
errors: []
77-
}
78-
});
79-
}, 1000);
80-
}
81-
};

src/components/Errors/ErrorsList/index.tsx

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,43 @@
11
import { useMemo } from "react";
2-
import type { DataFetcherConfiguration } from "../../../hooks/useFetchData";
3-
import { useFetchData } from "../../../hooks/useFetchData";
2+
import { useGetErrorsQuery } from "../../../redux/services/digma";
3+
import type { GetErrorsPayload } from "../../../redux/services/types";
4+
import { useConfigSelector } from "../../../store/config/useConfigSelector";
5+
import { isString } from "../../../typeGuards/isString";
46
import { sendUserActionTrackingEvent } from "../../../utils/actions/sendUserActionTrackingEvent";
57
import { EmptyState } from "../EmptyState";
68
import { ErrorCard } from "../ErrorCard";
7-
import { actions } from "../actions";
89
import { trackingEvents } from "../tracking";
9-
import type { GetErrorsDataPayload, SetErrorsDataPayload } from "../types";
1010
import * as s from "./styles";
1111
import type { ErrorsListProps } from "./types";
1212

13-
const dataFetcherConfiguration: DataFetcherConfiguration = {
14-
requestAction: actions.GET_ERRORS_DATA,
15-
responseAction: actions.SET_ERRORS_DATA,
16-
refreshWithInterval: true,
17-
refreshOnPayloadChange: true
18-
};
13+
const REFRESH_INTERVAL = 10 * 1000; // in milliseconds
1914

2015
export const ErrorsList = ({
2116
onErrorSelect,
2217
spanCodeObjectId,
2318
methodId
2419
}: ErrorsListProps) => {
25-
const payload = useMemo(
20+
const { environment } = useConfigSelector();
21+
22+
const payload: GetErrorsPayload = useMemo(
2623
() => ({
27-
spanCodeObjectId,
28-
methodId
24+
codeObjectId: [spanCodeObjectId, methodId].filter(isString),
25+
environment: environment?.id ?? ""
2926
}),
30-
[spanCodeObjectId, methodId]
27+
[spanCodeObjectId, methodId, environment?.id]
3128
);
3229

33-
const { data } = useFetchData<GetErrorsDataPayload, SetErrorsDataPayload>(
34-
dataFetcherConfiguration,
35-
payload
36-
);
30+
const { data } = useGetErrorsQuery(payload, {
31+
pollingInterval: REFRESH_INTERVAL,
32+
skip: !environment?.id
33+
});
3734

3835
if (!data) {
3936
// TODO: replace with skeletons
4037
return <EmptyState preset={"loading"} />;
4138
}
4239

43-
if (data.errors.length === 0) {
40+
if (data.length === 0) {
4441
return <EmptyState preset={"noData"} />;
4542
}
4643

@@ -51,7 +48,7 @@ export const ErrorsList = ({
5148

5249
return (
5350
<s.Container>
54-
{data.errors.map((x) => (
51+
{data.map((x) => (
5552
<ErrorCard key={x.uid} data={x} onClick={handleErrorCardClick} />
5653
))}
5754
</s.Container>

src/components/Errors/actions.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { addPrefix } from "../../utils/addPrefix";
33
const ACTION_PREFIX = "ERRORS";
44

55
export const actions = addPrefix(ACTION_PREFIX, {
6-
GET_ERRORS_DATA: "GET_ERRORS_DATA", // TODO: refactor to HTTP API call
7-
SET_ERRORS_DATA: "SET_ERRORS_DATA",
86
GO_TO_TRACE: "GO_TO_TRACE",
97
OPEN_RAW_ERROR_STACK_TRACE_IN_EDITOR: "OPEN_RAW_ERROR_STACK_TRACE_IN_EDITOR",
108
GO_TO_CODE_LOCATION: "GO_TO_CODE_LOCATION",

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
1919

2020
/* Language and Environment */
21-
"target": "ES2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
21+
"target": "ES2023", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
2222
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
2323
"jsx": "react-jsx", /* Specify what JSX code is generated. */
2424
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */

0 commit comments

Comments
 (0)