@localstack/appinspector-ui 1.0.0-dev-c7a4c87a → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +109 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +87 -45
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/pages/spans-list-page.tsx
|
|
2
2
|
import { Box as Box6 } from "@mui/material";
|
|
3
|
-
import { useCallback as
|
|
3
|
+
import { useCallback as useCallback5, useEffect as useEffect4, useRef as useRef3, useState as useState5 } from "react";
|
|
4
4
|
import { useNavigate } from "react-router-dom";
|
|
5
5
|
|
|
6
6
|
// src/api/use-api.tsx
|
|
@@ -3254,16 +3254,58 @@ var AppInspectorContextProvider = (props) => {
|
|
|
3254
3254
|
) });
|
|
3255
3255
|
};
|
|
3256
3256
|
|
|
3257
|
+
// src/hooks/use-local-storage.tsx
|
|
3258
|
+
import { useCallback as useCallback3, useEffect as useEffect2, useState as useState3 } from "react";
|
|
3259
|
+
function useLocalStorage(key, initialValue) {
|
|
3260
|
+
const [storedValue, setStoredValue] = useState3(() => {
|
|
3261
|
+
try {
|
|
3262
|
+
const item = globalThis.localStorage.getItem(key);
|
|
3263
|
+
return item ? JSON.parse(item) : initialValue;
|
|
3264
|
+
} catch (error) {
|
|
3265
|
+
console.error(`Error reading localStorage key "${key}":`, error);
|
|
3266
|
+
return initialValue;
|
|
3267
|
+
}
|
|
3268
|
+
});
|
|
3269
|
+
const setValue = useCallback3((value) => {
|
|
3270
|
+
try {
|
|
3271
|
+
setStoredValue(value);
|
|
3272
|
+
globalThis.localStorage.setItem(key, JSON.stringify(value));
|
|
3273
|
+
globalThis.dispatchEvent(new StorageEvent("storage", {
|
|
3274
|
+
key,
|
|
3275
|
+
newValue: JSON.stringify(value)
|
|
3276
|
+
}));
|
|
3277
|
+
} catch (error) {
|
|
3278
|
+
console.error(`Error setting localStorage key "${key}":`, error);
|
|
3279
|
+
}
|
|
3280
|
+
}, [key]);
|
|
3281
|
+
useEffect2(() => {
|
|
3282
|
+
const handleStorageChange = (event) => {
|
|
3283
|
+
if (event.key === key && event.newValue !== null) {
|
|
3284
|
+
try {
|
|
3285
|
+
setStoredValue(JSON.parse(event.newValue));
|
|
3286
|
+
} catch (error) {
|
|
3287
|
+
console.error(`Error parsing localStorage key "${key}":`, error);
|
|
3288
|
+
}
|
|
3289
|
+
}
|
|
3290
|
+
};
|
|
3291
|
+
globalThis.addEventListener("storage", handleStorageChange);
|
|
3292
|
+
return () => {
|
|
3293
|
+
globalThis.removeEventListener("storage", handleStorageChange);
|
|
3294
|
+
};
|
|
3295
|
+
}, [key]);
|
|
3296
|
+
return [storedValue, setValue];
|
|
3297
|
+
}
|
|
3298
|
+
|
|
3257
3299
|
// src/hooks/use-status.tsx
|
|
3258
|
-
import { useCallback as
|
|
3300
|
+
import { useCallback as useCallback4, useEffect as useEffect3, useRef as useRef2, useState as useState4 } from "react";
|
|
3259
3301
|
var useStatus = () => {
|
|
3260
3302
|
const api = useAppInspectorApi();
|
|
3261
|
-
const [checking, setChecking] =
|
|
3262
|
-
const [status, setStatus] =
|
|
3263
|
-
const [error, setError] =
|
|
3303
|
+
const [checking, setChecking] = useState4(true);
|
|
3304
|
+
const [status, setStatus] = useState4();
|
|
3305
|
+
const [error, setError] = useState4();
|
|
3264
3306
|
const hasFetchedReference = useRef2(false);
|
|
3265
3307
|
const abortControllerReference = useRef2(null);
|
|
3266
|
-
const checkStatus =
|
|
3308
|
+
const checkStatus = useCallback4(async () => {
|
|
3267
3309
|
if (abortControllerReference.current) {
|
|
3268
3310
|
abortControllerReference.current.abort();
|
|
3269
3311
|
}
|
|
@@ -3287,7 +3329,7 @@ var useStatus = () => {
|
|
|
3287
3329
|
}
|
|
3288
3330
|
}
|
|
3289
3331
|
}, [api]);
|
|
3290
|
-
|
|
3332
|
+
useEffect3(() => {
|
|
3291
3333
|
if (!hasFetchedReference.current) {
|
|
3292
3334
|
hasFetchedReference.current = true;
|
|
3293
3335
|
void checkStatus();
|
|
@@ -3301,13 +3343,13 @@ import { jsx as jsx128 } from "react/jsx-runtime";
|
|
|
3301
3343
|
var MAX_WIDTH = 1400;
|
|
3302
3344
|
var SpansListPage = () => {
|
|
3303
3345
|
const api = useAppInspectorApi();
|
|
3304
|
-
const [spans, setSpans] =
|
|
3305
|
-
const [loading, setLoading] =
|
|
3346
|
+
const [spans, setSpans] = useState5();
|
|
3347
|
+
const [loading, setLoading] = useState5(false);
|
|
3306
3348
|
const hasFetched = useRef3(false);
|
|
3307
|
-
const [filterWriteOperations, setFilterWriteOperations] =
|
|
3308
|
-
const [fetchError, setFetchError] =
|
|
3349
|
+
const [filterWriteOperations, setFilterWriteOperations] = useLocalStorage("filterWriteOperations", true);
|
|
3350
|
+
const [fetchError, setFetchError] = useState5();
|
|
3309
3351
|
const { checkStatus, error: statusError, status } = useStatus();
|
|
3310
|
-
const fetchSpans =
|
|
3352
|
+
const fetchSpans = useCallback5(async () => {
|
|
3311
3353
|
setLoading(true);
|
|
3312
3354
|
try {
|
|
3313
3355
|
const response = await api.getSpans({
|
|
@@ -3323,26 +3365,26 @@ var SpansListPage = () => {
|
|
|
3323
3365
|
setLoading(false);
|
|
3324
3366
|
}
|
|
3325
3367
|
}, [api, filterWriteOperations]);
|
|
3326
|
-
const fetchSpansSync =
|
|
3368
|
+
const fetchSpansSync = useCallback5(() => {
|
|
3327
3369
|
void fetchSpans();
|
|
3328
3370
|
}, [fetchSpans]);
|
|
3329
|
-
|
|
3371
|
+
useEffect4(() => {
|
|
3330
3372
|
if (hasFetched.current) return;
|
|
3331
3373
|
if (status?.status !== "ENABLED") return;
|
|
3332
3374
|
hasFetched.current = true;
|
|
3333
3375
|
void fetchSpans();
|
|
3334
3376
|
}, [fetchSpans, status]);
|
|
3335
|
-
|
|
3377
|
+
useEffect4(() => {
|
|
3336
3378
|
if (!hasFetched.current) return;
|
|
3337
3379
|
void fetchSpans();
|
|
3338
3380
|
}, [fetchSpans]);
|
|
3339
3381
|
const navigate = useNavigate();
|
|
3340
3382
|
const { resolveLink } = useAppInspector();
|
|
3341
|
-
const navigateToSpan =
|
|
3383
|
+
const navigateToSpan = useCallback5((span) => {
|
|
3342
3384
|
const url = resolveLink({ to: "trace-graph", traceId: span.trace_id });
|
|
3343
3385
|
navigate(`${url}?spanId=${span.span_id}`);
|
|
3344
3386
|
}, [navigate, resolveLink]);
|
|
3345
|
-
const clearSpans =
|
|
3387
|
+
const clearSpans = useCallback5(async () => {
|
|
3346
3388
|
setLoading(true);
|
|
3347
3389
|
try {
|
|
3348
3390
|
await api.deleteSpans();
|
|
@@ -3356,7 +3398,7 @@ var SpansListPage = () => {
|
|
|
3356
3398
|
setLoading(false);
|
|
3357
3399
|
}
|
|
3358
3400
|
}, [api, fetchSpans]);
|
|
3359
|
-
const handleRetry =
|
|
3401
|
+
const handleRetry = useCallback5(() => {
|
|
3360
3402
|
void checkStatus();
|
|
3361
3403
|
}, [checkStatus]);
|
|
3362
3404
|
const shouldShowStatusMessage = Boolean(statusError) || status?.status === "DISABLED";
|
|
@@ -3421,7 +3463,7 @@ var SpansListPage = () => {
|
|
|
3421
3463
|
import { Box as Box12, Drawer, Paper as Paper2 } from "@mui/material";
|
|
3422
3464
|
import { styled } from "@mui/material/styles";
|
|
3423
3465
|
import { ReactFlowProvider } from "@xyflow/react";
|
|
3424
|
-
import { useCallback as
|
|
3466
|
+
import { useCallback as useCallback8, useEffect as useEffect6, useState as useState8 } from "react";
|
|
3425
3467
|
import { useParams, useSearchParams } from "react-router-dom";
|
|
3426
3468
|
|
|
3427
3469
|
// src/components/event-details/event-details.tsx
|
|
@@ -3462,10 +3504,10 @@ var EventDetailsHeader = ({ event, onClose }) => {
|
|
|
3462
3504
|
// src/components/event-details/toggle-section.tsx
|
|
3463
3505
|
import { KeyboardArrowDown, KeyboardArrowRight } from "@mui/icons-material";
|
|
3464
3506
|
import { Box as Box8, Typography as Typography5 } from "@mui/material";
|
|
3465
|
-
import { useState as
|
|
3507
|
+
import { useState as useState6 } from "react";
|
|
3466
3508
|
import { jsx as jsx130, jsxs as jsxs124 } from "react/jsx-runtime";
|
|
3467
3509
|
var ToggleSection = ({ children, headline, initialOpen = true }) => {
|
|
3468
|
-
const [isOpen, setIsOpen] =
|
|
3510
|
+
const [isOpen, setIsOpen] = useState6(initialOpen);
|
|
3469
3511
|
return /* @__PURE__ */ jsxs124(Box8, { sx: { mt: 4 }, children: [
|
|
3470
3512
|
/* @__PURE__ */ jsx130(
|
|
3471
3513
|
Box8,
|
|
@@ -3575,13 +3617,13 @@ var EventDetails = ({ selectedEvent }) => {
|
|
|
3575
3617
|
import "@xyflow/react/dist/base.css";
|
|
3576
3618
|
import { Alert as Alert3, Button as Button4 } from "@mui/material";
|
|
3577
3619
|
import { Background, Controls, ReactFlow, useReactFlow, useStoreApi } from "@xyflow/react";
|
|
3578
|
-
import { useCallback as
|
|
3620
|
+
import { useCallback as useCallback7, useEffect as useEffect5, useState as useState7 } from "react";
|
|
3579
3621
|
|
|
3580
3622
|
// src/components/trace-graph/service-node.tsx
|
|
3581
3623
|
import { Box as Box11, Stack as Stack2, Typography as Typography7 } from "@mui/material";
|
|
3582
3624
|
import "@xyflow/react/dist/style.css";
|
|
3583
3625
|
import { Handle, Position } from "@xyflow/react";
|
|
3584
|
-
import { memo, useCallback as
|
|
3626
|
+
import { memo, useCallback as useCallback6 } from "react";
|
|
3585
3627
|
|
|
3586
3628
|
// src/components/trace-graph/problem-indicator.tsx
|
|
3587
3629
|
import { Error as ErrorIcon, Info, Warning } from "@mui/icons-material";
|
|
@@ -3642,10 +3684,10 @@ var handleStyle = {
|
|
|
3642
3684
|
opacity: 0
|
|
3643
3685
|
};
|
|
3644
3686
|
var ServiceNode = memo(function ServiceNode2({ data, selected }) {
|
|
3645
|
-
const handleClick =
|
|
3687
|
+
const handleClick = useCallback6(() => {
|
|
3646
3688
|
data.onEventSelect(data.event);
|
|
3647
3689
|
}, [data]);
|
|
3648
|
-
const handleKeyPress =
|
|
3690
|
+
const handleKeyPress = useCallback6(
|
|
3649
3691
|
(event) => {
|
|
3650
3692
|
if (event.key === "Enter" || event.key === " ") {
|
|
3651
3693
|
handleClick();
|
|
@@ -3842,12 +3884,12 @@ var TraceGraph = ({
|
|
|
3842
3884
|
spans,
|
|
3843
3885
|
viewPortPixelWidth
|
|
3844
3886
|
}) => {
|
|
3845
|
-
const [nodes, setNodes] =
|
|
3846
|
-
const [edges, setEdges] =
|
|
3847
|
-
const [initialViewSet, setInitialViewSet] =
|
|
3887
|
+
const [nodes, setNodes] = useState7([]);
|
|
3888
|
+
const [edges, setEdges] = useState7([]);
|
|
3889
|
+
const [initialViewSet, setInitialViewSet] = useState7(false);
|
|
3848
3890
|
const { fitView, setCenter } = useReactFlow();
|
|
3849
3891
|
const store = useStoreApi();
|
|
3850
|
-
const updateSelectedNode =
|
|
3892
|
+
const updateSelectedNode = useCallback7(
|
|
3851
3893
|
(nodeId) => {
|
|
3852
3894
|
const { addSelectedNodes } = store.getState();
|
|
3853
3895
|
if (nodeId) {
|
|
@@ -3859,7 +3901,7 @@ var TraceGraph = ({
|
|
|
3859
3901
|
},
|
|
3860
3902
|
[nodes, store]
|
|
3861
3903
|
);
|
|
3862
|
-
|
|
3904
|
+
useEffect5(() => {
|
|
3863
3905
|
const spansMap = /* @__PURE__ */ new Map();
|
|
3864
3906
|
const rootSpans = [];
|
|
3865
3907
|
for (const span of spans.data ?? []) {
|
|
@@ -3891,7 +3933,7 @@ var TraceGraph = ({
|
|
|
3891
3933
|
setNodes(layoutedNodes);
|
|
3892
3934
|
setEdges(layoutedEdges);
|
|
3893
3935
|
}, [onEventSelect, spans.data]);
|
|
3894
|
-
|
|
3936
|
+
useEffect5(() => {
|
|
3895
3937
|
const shouldSetInitialView = !spans.loading && nodes.length > 0 && !initialViewSet;
|
|
3896
3938
|
if (shouldSetInitialView) {
|
|
3897
3939
|
if (initialFocusEventId) {
|
|
@@ -3911,12 +3953,12 @@ var TraceGraph = ({
|
|
|
3911
3953
|
setInitialViewSet(true);
|
|
3912
3954
|
}
|
|
3913
3955
|
}, [spans.loading, nodes, initialFocusEventId, viewPortPixelWidth, setCenter, fitView, onEventSelect, initialViewSet]);
|
|
3914
|
-
|
|
3956
|
+
useEffect5(() => {
|
|
3915
3957
|
if (initialFocusEventId) {
|
|
3916
3958
|
updateSelectedNode(initialFocusEventId);
|
|
3917
3959
|
}
|
|
3918
3960
|
}, [initialFocusEventId, updateSelectedNode]);
|
|
3919
|
-
const onNodeClick =
|
|
3961
|
+
const onNodeClick = useCallback7((_event, node) => {
|
|
3920
3962
|
onEventSelect(node.data.event);
|
|
3921
3963
|
updateSelectedNode(node.id);
|
|
3922
3964
|
}, [onEventSelect, updateSelectedNode]);
|
|
@@ -3994,10 +4036,10 @@ var TraceGraphPage = () => {
|
|
|
3994
4036
|
const [searchParameters] = useSearchParams();
|
|
3995
4037
|
const spanId = searchParameters.get("spanId");
|
|
3996
4038
|
const api = useAppInspectorApi();
|
|
3997
|
-
const [spans, setSpans] =
|
|
3998
|
-
const [loading, setLoading] =
|
|
3999
|
-
const [fetchError, setFetchError] =
|
|
4000
|
-
const fetchSpans =
|
|
4039
|
+
const [spans, setSpans] = useState8();
|
|
4040
|
+
const [loading, setLoading] = useState8(false);
|
|
4041
|
+
const [fetchError, setFetchError] = useState8();
|
|
4042
|
+
const fetchSpans = useCallback8(async () => {
|
|
4001
4043
|
setLoading(true);
|
|
4002
4044
|
try {
|
|
4003
4045
|
const response = await api.getSpans({
|
|
@@ -4012,14 +4054,14 @@ var TraceGraphPage = () => {
|
|
|
4012
4054
|
setLoading(false);
|
|
4013
4055
|
}
|
|
4014
4056
|
}, [api, traceId]);
|
|
4015
|
-
|
|
4057
|
+
useEffect6(() => {
|
|
4016
4058
|
void fetchSpans();
|
|
4017
4059
|
}, [fetchSpans]);
|
|
4018
|
-
const [open, setOpen] =
|
|
4019
|
-
const [selectedEvent, setSelectedEvent] =
|
|
4020
|
-
const [viewPortPixelWidth, setViewPortPixelWidth] =
|
|
4060
|
+
const [open, setOpen] = useState8(true);
|
|
4061
|
+
const [selectedEvent, setSelectedEvent] = useState8();
|
|
4062
|
+
const [viewPortPixelWidth, setViewPortPixelWidth] = useState8(0);
|
|
4021
4063
|
const { checkStatus, error: statusError, status } = useStatus();
|
|
4022
|
-
const calculateDrawerWidth =
|
|
4064
|
+
const calculateDrawerWidth = useCallback8(() => {
|
|
4023
4065
|
const percentageMatch = /(\d+)%/.exec(DRAWER_WIDTH);
|
|
4024
4066
|
if (percentageMatch && open) {
|
|
4025
4067
|
const percentage = Number.parseInt(percentageMatch[1], 10);
|
|
@@ -4027,7 +4069,7 @@ var TraceGraphPage = () => {
|
|
|
4027
4069
|
}
|
|
4028
4070
|
return 0;
|
|
4029
4071
|
}, [open]);
|
|
4030
|
-
|
|
4072
|
+
useEffect6(() => {
|
|
4031
4073
|
const updateViewportWidth = () => {
|
|
4032
4074
|
const totalWidth = window.innerWidth;
|
|
4033
4075
|
const drawerPixelWidth = open ? calculateDrawerWidth() : 0;
|
|
@@ -4041,11 +4083,11 @@ var TraceGraphPage = () => {
|
|
|
4041
4083
|
clearTimeout(timeoutId);
|
|
4042
4084
|
};
|
|
4043
4085
|
}, [open, calculateDrawerWidth]);
|
|
4044
|
-
const handleEventSelect =
|
|
4086
|
+
const handleEventSelect = useCallback8((event) => {
|
|
4045
4087
|
setSelectedEvent(event);
|
|
4046
4088
|
setOpen(true);
|
|
4047
4089
|
}, []);
|
|
4048
|
-
const handleRetry =
|
|
4090
|
+
const handleRetry = useCallback8(() => {
|
|
4049
4091
|
void checkStatus();
|
|
4050
4092
|
}, [checkStatus]);
|
|
4051
4093
|
const shouldShowStatusMessage = Boolean(statusError) || status?.status === "DISABLED";
|