Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/flow/sink-node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type SinkNodeData = {
type SinkNodeType = Node<SinkNodeData, "sink">;

function SinkNodeComponent({ data, selected }: NodeProps<SinkNodeType>) {
const { componentDef, componentKey, displayName, metrics, disabled } = data;
const { componentDef, displayName, metrics, disabled } = data;
const isShared = !!data.sharedComponentId;
const isStale = isShared && data.sharedComponentLatestVersion != null &&
(data.sharedComponentVersion ?? 0) < data.sharedComponentLatestVersion;
Expand Down Expand Up @@ -63,7 +63,7 @@ function SinkNodeComponent({ data, selected }: NodeProps<SinkNodeType>) {

{/* Body */}
<div className="space-y-2 px-3 py-2.5">
<p className="truncate text-xs font-medium text-foreground">{displayName || componentKey}</p>
{displayName && <p className="truncate text-xs font-medium text-foreground">{displayName}</p>}

{metrics && (
<p className="truncate text-xs font-mono text-purple-400">
Expand Down
4 changes: 2 additions & 2 deletions src/components/flow/source-node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type SourceNodeData = {
type SourceNodeType = Node<SourceNodeData, "source">;

function SourceNodeComponent({ data, selected }: NodeProps<SourceNodeType>) {
const { componentDef, componentKey, displayName, metrics, disabled, isSystemLocked } = data;
const { componentDef, displayName, metrics, disabled, isSystemLocked } = data;
const isShared = !!data.sharedComponentId;
const isStale = isShared && data.sharedComponentLatestVersion != null &&
(data.sharedComponentVersion ?? 0) < data.sharedComponentLatestVersion;
Expand Down Expand Up @@ -61,7 +61,7 @@ function SourceNodeComponent({ data, selected }: NodeProps<SourceNodeType>) {

{/* Body */}
<div className="space-y-2 px-3 py-2.5">
<p className="truncate text-xs font-medium text-foreground">{displayName || componentKey}</p>
{displayName && <p className="truncate text-xs font-medium text-foreground">{displayName}</p>}

{metrics && (
<p className="truncate text-xs font-mono text-emerald-400">
Expand Down
4 changes: 2 additions & 2 deletions src/components/flow/transform-node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function TransformNodeComponent({
data,
selected,
}: NodeProps<TransformNodeType>) {
const { componentDef, componentKey, displayName, metrics, disabled } = data;
const { componentDef, displayName, metrics, disabled } = data;
const isShared = !!data.sharedComponentId;
const isStale = isShared && data.sharedComponentLatestVersion != null &&
(data.sharedComponentVersion ?? 0) < data.sharedComponentLatestVersion;
Expand Down Expand Up @@ -66,7 +66,7 @@ function TransformNodeComponent({

{/* Body */}
<div className="space-y-2 px-3 py-2.5">
<p className="truncate text-xs font-medium text-foreground">{displayName || componentKey}</p>
{displayName && <p className="truncate text-xs font-medium text-foreground">{displayName}</p>}

{metrics && (
metrics.eventsInPerSec != null ? (
Expand Down
12 changes: 11 additions & 1 deletion src/server/routers/alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -665,9 +665,19 @@ export const alertRouter = router({
.query(async ({ input }) => {
const { environmentId, limit, cursor } = input;

// Exclude informational event metrics (deploys, version checks) from history;
// they still fire notifications but aren't surfaced in the alert table.
const HIDDEN_METRICS: AlertMetric[] = [
"deploy_requested",
"deploy_completed",
"deploy_rejected",
"deploy_cancelled",
"new_version_available",
];
Comment on lines +670 to +676
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded list diverges from existing EVENT_METRIC_VALUES constant

alert.ts already imports isEventMetric from @/server/services/event-alerts, which is re-exported from src/lib/alert-metrics.ts. That module defines EVENT_METRIC_VALUES with 10 entries — the same 5 deploy/version metrics listed here, plus scim_sync_failed, backup_failed, certificate_expiring, node_joined, and node_left.

The new HIDDEN_METRICS constant duplicates 5 of those 10 values in a separate location. If a new deploy-related metric (e.g. deploy_rolled_back) is added to EVENT_METRIC_VALUES in the future, it won't be automatically excluded from the alert history table, since HIDDEN_METRICS won't be updated alongside it.

Consider extracting a named sub-constant (e.g. DEPLOY_AND_VERSION_METRICS) into src/lib/alert-metrics.ts and importing it here, so both the firing side and the display side share the same authoritative list for this subset.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/server/routers/alert.ts
Line: 670-676

Comment:
**Hardcoded list diverges from existing `EVENT_METRIC_VALUES` constant**

`alert.ts` already imports `isEventMetric` from `@/server/services/event-alerts`, which is re-exported from `src/lib/alert-metrics.ts`. That module defines `EVENT_METRIC_VALUES` with 10 entries — the same 5 deploy/version metrics listed here, plus `scim_sync_failed`, `backup_failed`, `certificate_expiring`, `node_joined`, and `node_left`.

The new `HIDDEN_METRICS` constant duplicates 5 of those 10 values in a separate location. If a new deploy-related metric (e.g. `deploy_rolled_back`) is added to `EVENT_METRIC_VALUES` in the future, it won't be automatically excluded from the alert history table, since `HIDDEN_METRICS` won't be updated alongside it.

Consider extracting a named sub-constant (e.g. `DEPLOY_AND_VERSION_METRICS`) into `src/lib/alert-metrics.ts` and importing it here, so both the firing side and the display side share the same authoritative list for this subset.

How can I resolve this? If you propose a fix, please make it concise.


const items = await prisma.alertEvent.findMany({
where: {
alertRule: { environmentId },
alertRule: { environmentId, metric: { notIn: HIDDEN_METRICS } },
},
include: {
alertRule: {
Expand Down
Loading