Skip to content

refactor(lane-4): pipelineAlert() helper for FE Sentry signals#1914

Closed
Hugo0 wants to merge 2 commits intoqa/post-cutover-fe-fixesfrom
chore/pipeline-alerts-helper
Closed

refactor(lane-4): pipelineAlert() helper for FE Sentry signals#1914
Hugo0 wants to merge 2 commits intoqa/post-cutover-fe-fixesfrom
chore/pipeline-alerts-helper

Conversation

@Hugo0
Copy link
Copy Markdown
Contributor

@Hugo0 Hugo0 commented Apr 29, 2026

Summary

Mirror the BE `pipelineAlert` helper. Migrate the transformer default-arm
unknown-kind alert to the shared schema (`component=pipeline`, fixed
category union, `intentKind` tag), so BE+FE pipeline events filter on the
same dashboard query.

Pairs with

peanutprotocol/peanut-api-ts#679

Verified

  • `pnpm typecheck` clean
  • `npm test` 961/961 passing

Base

Stacked on `qa/post-cutover-fe-fixes` (PR #1912).

Mirror the BE pipelineAlert helper. Migrates the transformer default-arm
unknown-kind alert to the shared schema (component=pipeline, fixed
category union, intentKind tag), so BE+FE pipeline events filter on the
same dashboard query.

Pairs with peanut-api-ts PR #679.
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
peanut-wallet Ready Ready Preview, Comment Apr 29, 2026 5:51pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ecbb4da3-872f-46de-a3e8-71e6c728f8e5

📥 Commits

Reviewing files that changed from the base of the PR and between 5440d58 and fd20e71.

📒 Files selected for processing (3)
  • src/components/TransactionDetails/__tests__/transactionTransformer.test.ts
  • src/context/PeanutDebug.tsx
  • src/utils/account-mask.utils.ts
✅ Files skipped from review due to trivial changes (3)
  • src/context/PeanutDebug.tsx
  • src/utils/account-mask.utils.ts
  • src/components/TransactionDetails/tests/transactionTransformer.test.ts

Walkthrough

Adds a new pipeline alerts utility that centralizes lazy Sentry message capture with category tagging and metadata. Replaces direct/lazy Sentry usage in the transaction transformer with pipelineAlert(...), performs several formatting-only simplifications, and reformats related tests and small utility/context files.

Changes

Cohort / File(s) Summary
New Pipeline Alerts Utility
src/utils/pipelineAlerts.ts
Adds pipelineAlert with PipelineAlertCategory and PipelineAlertExtra exports. The function no-ops outside the browser, lazily imports @sentry/nextjs, captures a message tagged with component: 'pipeline', category, and intentKind (from extra.kind), and swallows import/capture failures.
Transaction Transformer
src/components/TransactionDetails/transactionTransformer.ts
Replaces prior browser-guarded, lazy dynamic import usage of @sentry/nextjs for unknown TRANSACTION_INTENT kinds with a single pipelineAlert('unknown_transformer_kind', ...) call carrying entryUuid, kind, and userRole at 'warning' level. Also collapses several multi-line conditional/ternary expressions into single-line expressions (formatting-only).
Tests (formatting only)
src/components/TransactionDetails/__tests__/transactionTransformer.test.ts
Reformats imports and many test literals/expectations across the file to multi-line style; no functional test logic changes.
Minor formatting changes
src/context/PeanutDebug.tsx, src/utils/account-mask.utils.ts
Small formatting-only edits: single-line constant initialization collapse in PeanutDebug.tsx and reflowed parameter formatting in maskAccountIdentifier signature; no behavior changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: introducing a pipelineAlert() helper for frontend Sentry signals, which matches the primary objective of mirroring the backend helper.
Description check ✅ Passed The description is directly related to the changeset, clearly explaining the purpose of mirroring the backend pipelineAlert helper and migrating alert schemas for consistent filtering.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Review rate limit: 3/5 reviews remaining, refill in 22 minutes and 59 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/utils/pipelineAlerts.ts (1)

42-42: Avoid fully silent failure handling in the alert path.

Swallowing all errors here makes helper regressions hard to detect locally. Consider logging only in development while keeping production no-op behavior.

Proposed fix
-        .catch(() => {})
+        .catch((err) => {
+            if (process.env.NODE_ENV === 'development') {
+                console.warn('pipelineAlert failed', err)
+            }
+        })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/utils/pipelineAlerts.ts` at line 42, Replace the empty catch handler
(.catch(() => {})) in src/utils/pipelineAlerts.ts with a handler that surfaces
the error during development but remains a no-op in production; e.g. change to
.catch(err => { if (process.env.NODE_ENV === 'development')
console.error('pipelineAlerts error:', err); }) so failures in the alert path
are logged locally while production behavior stays silent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/utils/pipelineAlerts.ts`:
- Around line 35-39: The tag value for intentKind is using a TypeScript cast
only and can still receive non-string runtime values; compute a runtime-checked
string before calling Sentry.captureMessage — e.g., derive intentKind = typeof
extra?.kind === 'string' ? extra.kind : 'n/a' (or use String(...) only after a
typeof check) and use that variable in the tags object (referencing the existing
extra variable and the tags key intentKind in the Sentry.captureMessage call) so
the tag is always a stable string.

---

Nitpick comments:
In `@src/utils/pipelineAlerts.ts`:
- Line 42: Replace the empty catch handler (.catch(() => {})) in
src/utils/pipelineAlerts.ts with a handler that surfaces the error during
development but remains a no-op in production; e.g. change to .catch(err => { if
(process.env.NODE_ENV === 'development') console.error('pipelineAlerts error:',
err); }) so failures in the alert path are logged locally while production
behavior stays silent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5810f289-1831-4a66-bd93-5540e3e8c33e

📥 Commits

Reviewing files that changed from the base of the PR and between b4c974c and 5440d58.

📒 Files selected for processing (2)
  • src/components/TransactionDetails/transactionTransformer.ts
  • src/utils/pipelineAlerts.ts

Comment on lines +35 to +39
.then((Sentry) =>
Sentry.captureMessage(message, {
level,
tags: { component: 'pipeline', category, intentKind: (extra.kind as string | undefined) ?? 'n/a' },
extra,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Harden intentKind extraction to guarantee stable tag values.

(extra.kind as string | undefined) is compile-time only; non-string runtime values can leak into tags and fragment the dashboard filter schema.

Proposed fix
 export function pipelineAlert(
@@
 ): void {
     if (typeof window === 'undefined') return
     import('@sentry/nextjs')
-        .then((Sentry) =>
-            Sentry.captureMessage(message, {
+        .then((Sentry) => {
+            const intentKind =
+                typeof extra.kind === 'string' && extra.kind.trim().length > 0 ? extra.kind : 'n/a'
+            Sentry.captureMessage(message, {
                 level,
-                tags: { component: 'pipeline', category, intentKind: (extra.kind as string | undefined) ?? 'n/a' },
+                tags: { component: 'pipeline', category, intentKind },
                 extra,
             })
-        )
+        })
         .catch(() => {})
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/utils/pipelineAlerts.ts` around lines 35 - 39, The tag value for
intentKind is using a TypeScript cast only and can still receive non-string
runtime values; compute a runtime-checked string before calling
Sentry.captureMessage — e.g., derive intentKind = typeof extra?.kind ===
'string' ? extra.kind : 'n/a' (or use String(...) only after a typeof check) and
use that variable in the tags object (referencing the existing extra variable
and the tags key intentKind in the Sentry.captureMessage call) so the tag is
always a stable string.

@Hugo0
Copy link
Copy Markdown
Contributor Author

Hugo0 commented Apr 29, 2026

Superseded by consolidated PR #1916. CR comment triaged: pipelineAlerts type guard tracked in mono Tier 4 #7 (defensive).

@Hugo0 Hugo0 closed this Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant