@localstack/appinspector-ui 1.0.211 → 1.0.212

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 CHANGED
@@ -31703,6 +31703,12 @@ var checkIsSqsSendMessage = (span) => {
31703
31703
  var PERMISSION_SEVERITY = ["explicitly_denied", "implicitly_denied", "explicitly_allowed"];
31704
31704
  var getWorstPermission = (events) => PERMISSION_SEVERITY.find((permission) => events.some((event) => event.permission === permission));
31705
31705
  var IAM_OUTCOME = { allowed: "allowed", error: "denied", none: void 0, warning: "warning" };
31706
+ var OPTIONAL_TABS = ["error", "logs", "permissions"];
31707
+ var getOptionalTabs = (span, eventGroups) => ({
31708
+ error: getSpanIssues(span).error,
31709
+ logs: checkIsLambdaInvoke(span) && typeof span.attributes?.["localstack.request_id"] === "string",
31710
+ permissions: span.iam_errors_suppressed === true || eventGroups.permissions !== void 0
31711
+ });
31706
31712
  var Field = ({ children, copy, label, testId, testIdOn = "value" }) => /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(import_material20.Box, { children: [
31707
31713
  /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_material20.Typography, { sx: { fontWeight: 600 }, variant: "caption", children: label }),
31708
31714
  /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(import_material20.Stack, { alignItems: "center", "data-testid": testIdOn === "row" ? testId : void 0, direction: "row", sx: { "&:hover .copy-btn": { opacity: 1 } }, children: [
@@ -31711,7 +31717,7 @@ var Field = ({ children, copy, label, testId, testIdOn = "value" }) => /* @__PUR
31711
31717
  ] })
31712
31718
  ] });
31713
31719
  var EmptyTab = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_material20.Typography, { color: "text.secondary", variant: "body2", children });
31714
- var EventDetails = ({ onClose, selectedEvent }) => {
31720
+ var EventDetails = ({ onClose, onOperationShown, selectedEvent }) => {
31715
31721
  const eventGroups = (0, import_react52.useMemo)(
31716
31722
  () => getEventGroupsByType(selectedEvent?.events ?? []),
31717
31723
  [selectedEvent?.events]
@@ -31719,6 +31725,18 @@ var EventDetails = ({ onClose, selectedEvent }) => {
31719
31725
  const [parseNestedJson, setParseNestedJson] = (0, import_react52.useState)(true);
31720
31726
  const [tab, setTab] = (0, import_react52.useState)("details");
31721
31727
  const { operationStatus: variant } = useDevSettings();
31728
+ const optionalTabs = selectedEvent ? getOptionalTabs(selectedEvent, eventGroups) : void 0;
31729
+ const activeTab = optionalTabs && OPTIONAL_TABS.some((optional) => optional === tab && !optionalTabs[optional]) ? "details" : tab;
31730
+ const onOperationShownRef = (0, import_react52.useRef)(onOperationShown);
31731
+ (0, import_react52.useEffect)(() => {
31732
+ onOperationShownRef.current = onOperationShown;
31733
+ }, [onOperationShown]);
31734
+ const shownSpanId = selectedEvent?.span_id;
31735
+ (0, import_react52.useEffect)(() => {
31736
+ if (shownSpanId !== void 0) {
31737
+ onOperationShownRef.current?.(shownSpanId, activeTab);
31738
+ }
31739
+ }, [shownSpanId, activeTab]);
31722
31740
  if (!selectedEvent) {
31723
31741
  return /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_material20.Box, { sx: { p: 3, textAlign: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_material20.Typography, { color: "text.secondary", variant: "body2", children: "Select an operation to view graph" }) });
31724
31742
  }
@@ -31750,10 +31768,7 @@ var EventDetails = ({ onClose, selectedEvent }) => {
31750
31768
  const errorType = functionError?.errorType ?? issues.errorType;
31751
31769
  const duration = selectedEvent.end_time_unix_nano ? ((BigInt(selectedEvent.end_time_unix_nano) - BigInt(selectedEvent.start_time_unix_nano)) / BigInt("1000000")).toString() : void 0;
31752
31770
  const resource = shortResourceName(selectedEvent.resource_name, selectedEvent.arn);
31753
- const showError = issues.error;
31754
- const showPermissions = selectedEvent.iam_errors_suppressed === true || eventGroups.permissions !== void 0;
31755
- const showLogs = isLambdaInvoke && requestId !== void 0;
31756
- const activeTab = tab === "error" && !showError || tab === "permissions" && !showPermissions || tab === "logs" && !showLogs ? "details" : tab;
31771
+ const { error: showError, logs: showLogs, permissions: showPermissions } = getOptionalTabs(selectedEvent, eventGroups);
31757
31772
  const errorMessages = functionError?.errorMessage === void 0 ? [.../* @__PURE__ */ new Set([selectedEvent.status_message, ...(selectedEvent.errors ?? []).filter((item) => item.level === "error").map((item) => item.message)])].filter((message) => Boolean(message) && message !== errorType) : [functionError.errorMessage];
31758
31773
  const iamEvents = getIamEvents(selectedEvent);
31759
31774
  const iamPermission = getWorstPermission(iamEvents);
@@ -31834,7 +31849,7 @@ var EventDetails = ({ onClose, selectedEvent }) => {
31834
31849
  variant: "scrollable",
31835
31850
  children: [
31836
31851
  /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_material20.Tab, { "data-testid": DETAIL_TAB_DETAILS_TEST_ID, label: "Details", value: "details" }),
31837
- /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_material20.Tab, { "data-testid": DETAIL_TAB_REQUEST_TEST_ID, label: "Payload", value: "request" }),
31852
+ /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_material20.Tab, { "data-testid": DETAIL_TAB_REQUEST_TEST_ID, label: "Payload", value: "payload" }),
31838
31853
  /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_material20.Tab, { "data-testid": DETAIL_TAB_RESPONSE_TEST_ID, label: "Response", value: "response" }),
31839
31854
  showError && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_material20.Tab, { "data-testid": DETAIL_TAB_ERROR_TEST_ID, icon: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_icons_material11.Cancel, { color: "error", sx: { fontSize: 16 } }), iconPosition: "end", label: "Error", value: "error" }),
31840
31855
  showPermissions && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_material20.Tab, { "data-testid": DETAIL_TAB_PERMISSIONS_TEST_ID, icon: permissionsIcon, iconPosition: "end", label: "Permissions", value: "permissions" }),
@@ -31880,7 +31895,7 @@ var EventDetails = ({ onClose, selectedEvent }) => {
31880
31895
  eventGroups.warnings && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(EventDetail, { displayText: "Warning", events: eventGroups.warnings, type: "warning" }),
31881
31896
  eventGroups.info && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(EventDetail, { displayText: "Info", events: eventGroups.info, type: "info" })
31882
31897
  ] }),
31883
- activeTab === "request" && (requestPayload === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(EmptyTab, { children: "No request payload recorded." }) : /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(import_jsx_runtime144.Fragment, { children: [
31898
+ activeTab === "payload" && (requestPayload === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(EmptyTab, { children: "No request payload recorded." }) : /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(import_jsx_runtime144.Fragment, { children: [
31884
31899
  rawDataSwitch,
31885
31900
  /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(PayloadViewer, { testId: EVENT_DETAILS_REQUEST_PAYLOAD, value: requestPayload })
31886
31901
  ] })),
@@ -32956,7 +32971,7 @@ var SPLIT_STORAGE_KEY = "appinspector-trace-sidebar-split";
32956
32971
  var VIEW_STORAGE_KEY = "appinspector-trace-sidebar-view";
32957
32972
  var clampSplit = (split2) => Math.min(MAX_SPLIT, Math.max(MIN_SPLIT, split2));
32958
32973
  var noop = () => void 0;
32959
- var TraceSidebar = ({ onClose, onRequestRendered, onSelectSpan, onViewChange, selectedSpanId, spanMatches, spans }) => {
32974
+ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan, onViewChange, selectedSpanId, spanMatches, spans }) => {
32960
32975
  const [storedWidth, setStoredWidth] = useLocalStorage(WIDTH_STORAGE_KEY, DEFAULT_WIDTH_SHARE);
32961
32976
  const [maximized, setMaximized] = useLocalStorage(MAXIMIZED_STORAGE_KEY, false);
32962
32977
  const [storedSplit, setStoredSplit] = useLocalStorage(SPLIT_STORAGE_KEY, DEFAULT_SPLIT);
@@ -33170,7 +33185,7 @@ var TraceSidebar = ({ onClose, onRequestRendered, onSelectSpan, onViewChange, se
33170
33185
  tabIndex: 0
33171
33186
  }
33172
33187
  ) }),
33173
- /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_material26.Box, { sx: { flex: 1, minHeight: 0 }, children: selectedSpan ? /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(EventDetails, { selectedEvent: selectedSpan }) : /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_material26.Typography, { color: "text.secondary", sx: { p: 3, textAlign: "center" }, variant: "body2", children: "The selected operation is not part of this trace." }) })
33188
+ /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_material26.Box, { sx: { flex: 1, minHeight: 0 }, children: selectedSpan ? /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(EventDetails, { onOperationShown, selectedEvent: selectedSpan }) : /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_material26.Typography, { color: "text.secondary", sx: { p: 3, textAlign: "center" }, variant: "body2", children: "The selected operation is not part of this trace." }) })
33174
33189
  ]
33175
33190
  }
33176
33191
  );
@@ -33334,15 +33349,16 @@ var getRequestId = (spans) => {
33334
33349
  };
33335
33350
 
33336
33351
  // src/hooks/use-operation-open-analytics.ts
33337
- var useOperationOpenAnalytics = ({ open, selectedEvent, spans }) => {
33352
+ var useOperationOpenAnalytics = ({ open, shown, spans }) => {
33338
33353
  const api = useAppInspectorApi();
33339
33354
  const { deploymentContainer } = useAppInspector();
33340
- const shownSpanIdRef = (0, import_react64.useRef)();
33355
+ const shownKeyRef = (0, import_react64.useRef)();
33341
33356
  (0, import_react64.useEffect)(() => {
33342
- const shownSpanId = open ? selectedEvent?.span_id : void 0;
33343
- const previousSpanId = shownSpanIdRef.current;
33344
- shownSpanIdRef.current = shownSpanId;
33345
- if (shownSpanId === void 0 || shownSpanId === previousSpanId || selectedEvent === void 0) {
33357
+ const shownKey = open && shown ? `${shown.span.span_id}
33358
+ ${shown.view}` : void 0;
33359
+ const previousKey = shownKeyRef.current;
33360
+ shownKeyRef.current = shownKey;
33361
+ if (shownKey === void 0 || shownKey === previousKey || shown === void 0) {
33346
33362
  return;
33347
33363
  }
33348
33364
  const requestId = getRequestId(spans ?? []);
@@ -33353,12 +33369,13 @@ var useOperationOpenAnalytics = ({ open, selectedEvent, spans }) => {
33353
33369
  event: "appinspector_operation_open",
33354
33370
  payload: {
33355
33371
  ...buildAnalyticsPayload(deploymentContainer),
33356
- metrics: buildProblemMetrics([selectedEvent]),
33357
- request_id: requestId
33372
+ metrics: buildProblemMetrics([shown.span]),
33373
+ request_id: requestId,
33374
+ view: shown.view
33358
33375
  }
33359
33376
  }).catch(() => {
33360
33377
  });
33361
- }, [api, deploymentContainer, open, selectedEvent, spans]);
33378
+ }, [api, deploymentContainer, open, shown, spans]);
33362
33379
  };
33363
33380
 
33364
33381
  // src/hooks/use-request-open-analytics.ts
@@ -34160,8 +34177,10 @@ var SpansListPage = () => {
34160
34177
  const firstMatch = queryActive && rootSpanId2 !== void 0 ? findFirstSpan(buildTraceTree(getSpans(rootSpanId2)).roots, (spanId) => rows[spanId]?.matches ?? false) : void 0;
34161
34178
  setSelectedSpanId(firstMatch?.span_id ?? span.span_id);
34162
34179
  }, []);
34180
+ const [shownOperation, setShownOperation] = (0, import_react69.useState)();
34163
34181
  const closeSidebar = (0, import_react69.useCallback)(() => {
34164
34182
  setSelectedSpanId(void 0);
34183
+ setShownOperation(void 0);
34165
34184
  }, []);
34166
34185
  const rootSpanId = selectedSpanId === void 0 ? void 0 : compute.rows[selectedSpanId]?.rootSpanId;
34167
34186
  const treeSpans = (0, import_react69.useMemo)(() => rootSpanId === void 0 ? [] : getTreeSpans(rootSpanId), [getTreeSpans, rootSpanId]);
@@ -34188,8 +34207,15 @@ var SpansListPage = () => {
34188
34207
  view: renderedRequest?.view ?? "operations"
34189
34208
  });
34190
34209
  const sidebarOpen = selectedSpanId !== void 0 && rootSpanId !== void 0;
34191
- const selectedSpan = (0, import_react69.useMemo)(() => treeSpans.find((span) => span.span_id === selectedSpanId), [selectedSpanId, treeSpans]);
34192
- useOperationOpenAnalytics({ open: sidebarOpen, selectedEvent: selectedSpan, spans: treeSpans });
34210
+ const handleOperationShown = (0, import_react69.useCallback)((spanId, view) => {
34211
+ setShownOperation({ spanId, view });
34212
+ }, []);
34213
+ const shown = (0, import_react69.useMemo)(() => {
34214
+ if (shownOperation === void 0) return;
34215
+ const span = treeSpans.find((treeSpan) => treeSpan.span_id === shownOperation.spanId);
34216
+ return span && { span, view: shownOperation.view };
34217
+ }, [shownOperation, treeSpans]);
34218
+ useOperationOpenAnalytics({ open: sidebarOpen, shown, spans: treeSpans });
34193
34219
  const handleRetry = (0, import_react69.useCallback)(() => {
34194
34220
  checkStatus();
34195
34221
  fetchForward();
@@ -34316,6 +34342,7 @@ var SpansListPage = () => {
34316
34342
  TraceSidebar,
34317
34343
  {
34318
34344
  onClose: closeSidebar,
34345
+ onOperationShown: handleOperationShown,
34319
34346
  onRequestRendered: handleRequestRendered,
34320
34347
  onSelectSpan: setSelectedSpanId,
34321
34348
  onViewChange: handleViewChange,