refactor: resolve Mirabel64 Stellar Wave issues #483, #484, #485, #486 - #607
Merged
nanaf6203-bit merged 3 commits intoJun 29, 2026
Merged
Conversation
…, migrate consumers (MettaChain#486) - Add @deprecated JSDoc to src/utils/structuredLogger.ts pointing new code to @/utils/logger. - Migrate console.* to logger.* in ViewToggle.tsx, TransactionDetailsModal.tsx, errorHandlingTest.ts. - Migrate @/utils/structuredLogger to @/utils/logger in errorMonitoringService.ts, GlobalErrorBoundary.tsx, LanguageSwitcher.tsx, app/page.tsx (including translation of structured call signatures: info(msg, {metadata}) -> info({...}), error(msg, err, {component,action,metadata}) -> errorWithStack(msg, err, {component,action,...}), component(name, action) -> info(\`Component: ${name} - ${action}\`, ...)). - Annotate earlyErrorSuppression.ts with a header explaining why it intentionally uses raw console (pre-React intercept of browser-extension noise). - ESLint enforcement: - no-restricted-imports rejects @/utils/structuredLogger (paths/patterns) with a clear migration message. - no-console denies direct console.* outside the three logger wrappers and test/story files. - README § "Logging" documents the canonical logger and the migration story. Closes MettaChain#486
…tatsPlugin (MettaChain#485, MettaChain#484) - Add explicit isProd guard so production builds never run the BuildStatsPlugin even when ANALYZE=true is set (e.g. misconfigured CI). - README § "Build stats plugin" documents the new gating. Closes MettaChain#485 Closes MettaChain#484
…in#483) - Move create+persist source-of-truth into src/store/referral/store.ts (exposes useReferralStore, ReferralStoreState, ReferralProgramSettings). - Add focused selector slices under src/store/referral/: referralLinks (useReferralLinks), referralStats (useReferralStats, useRecentRewards), leaderboard (useLeaderboard canonical + useLeaderboardCache alias), referralNotifications (useReferralNotification, useReferralLoading, useReferralError), misc (useCurrentReferralCampaign, useReferralTermsAccepted). Each slice imports from ./store to avoid circular imports. - Add barrel src/store/referral/index.ts for new code. - Slim src/store/referralStore.ts to a @deprecated back-compat re-export layer (so existing @/store/referralStore imports and jest mocks keep working). - Tighten programSettings: any -> ReferralProgramSettings = Record<string, unknown> | null and type initialState explicitly via Pick<ReferralStoreState, ...>. Closes MettaChain#483
|
@Mirabel64 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR — Resolve Mirabel64 Stellar Wave issues (#483, #484, #485, #486)
Closes #483
Closes #484
Closes #485
Close #486
— all open issues assigned to
@Mirabel64in the Stellar Wave Program (6th wave). Bundled into a single PR per the wave's "one PR per assignee" convention.Summary
Four production-safety and code-health issues filed by the code-review sweep:
console.*directly, and ~5 components imported the deprecated@/utils/structuredLoggersingleton rather than the canonical@/utils/logger.next.config.tsBuildStatsPlugin needed explicit production gating in addition to theANALYZE=trueopt-in.referralStore.tsmixed referralLinks, stats, leaderboard, notifications, settings, and the underlying Zustand store in one file.This PR resolves all four with a coordinated set of changes that keeps existing consumer imports working.
Changes
#486 — Logger consolidation (
@/utils/loggeris canonical)README.md§ "Logging", including the migration message, the@/utils/structuredLoggerdeprecation, and the intentional raw-consoleexemption inearlyErrorSuppression.ts.src/utils/structuredLogger.ts@deprecatedwith JSDoc pointing new code to@/utils/logger. The wrapper keeps re-exporting the canonical symbols, plus its domain-specificStructuredLoggerclass (with batching / remote-send) andlogNetworkRequest/logWeb3Activity/logTransactionhelpers, so existing callers compile unchanged.console.*tologger.*in:src/components/ViewToggle.tsx(4console.warn/error→logger.warn/error)src/components/TransactionDetailsModal.tsx(1console.error→logger.errorwith the error object)src/utils/errorHandlingTest.ts(allconsole.log→logger.info)@/utils/structuredLoggercallers to canonical@/utils/logger, including translation of structured-call signatures:src/utils/errorMonitoringService.ts(trackError(err, ctx)→logger.errorWithStack(err.message, err, ctx); inlineinfo({metadata: {...}})flattened toinfo({...}))src/components/error/GlobalErrorBoundary.tsx(structuredLogger.error(msg, err, {component, action, metadata})→logger.errorWithStack(msg, err, {component, action, ...metadata});warn/infosimilar)src/components/LanguageSwitcher.tsx(structuredLogger.component(name, action, ...)→logger.info(\Component: ${name} - ${action}`, {component, action})`)src/app/page.tsx(structuredLogger.info(msg, {component, action, metadata})→logger.info(msg, {component, action, ...metadata}))src/utils/earlyErrorSuppression.tswith a header comment explaining why it intentionally uses rawconsole.*(intercepts browser-extension noise that fires before the structured logger initialises). Exempt fromno-consolevia ESLint flat config.eslint.config.mjs):no-restricted-importsrejects@/utils/structuredLoggerpaths/patterns with a clear migration message.no-console: 'error'denies directconsole.*calls everywhere except the three logger-wrapper files (logger.ts,structuredLogger.ts,earlyErrorSuppression.ts) and test/story files in__tests__/,*.test.*,*.stories.*.#485 / #484 — Build stats plugin gating (
next.config.ts)The plugin was already gated by
isAnalyzeEnabled && !isServer. Added an explicit production guard:Production CI must not pass
ANALYZE=true; if it does, the plugin is still disabled by theNODE_ENV === 'production'guard. Documented inREADME.md§ "Build stats plugin".#483 — Split
referralStore.tsinto focused slicesNew layout:
useReferralStore(the create+persist source of truth with all actions) now lives insrc/store/referral/store.ts.src/store/referralStore.tsis now a thin backwards-compat re-export layer (marked@deprecatedin JSDoc) that re-exportsuseReferralStoreand all 9 selector hooks, so existing consumers (and tests, e.g.ReferralLeaderboard.test.tsx'sjest.mock('@/store/referralStore', …)) continue to compile unchanged.useReferralStorefrom./referral/store(not the back-compat layer) to avoid a circular import.programSettings: anytightened toReferralProgramSettings = Record<string, unknown> | null, which is compatible with the persistpartializelogic and is more useful for downstream narrowing.Pick<ReferralStoreState, …>to prevent[]literals widening tonever[].Acceptance criteria status
#486
Single canonical logger documented in README.
Codemod or ESLint rule applied to migrate remaining files (manual migration + ESLint enforcement in place).
No references to the deprecated module remain outside the wrapper.
Verified: zero remaining imports of
@/utils/structuredLoggeroutsidesrc/utils/structuredLogger.tsitself andsrc/utils/__tests__/structuredLogger.test.ts(which tests the wrapper contract).#485 / #484
ANALYZE=trueAND!isProd).ANALYZE.#483
useReferralLinks,useReferralStats,useLeaderboard,useReferralNotifications) live under@/store/referral/<slice>.Out-of-scope observations (not addressed in this PR)
These are surfaced for visibility but intentionally not fixed here to keep the diff focused on the wave's assigned issues:
src/stories/ReferralLinksCard.stories.tsxcallsuseReferralStore.setState({ referralLinks: links }), but the store key iscurrentReferralLinks. TheEmpty,WithLinks,OverflowLinksdecorators are therefore no-ops. Pre-existing bug — please file a separate issue.console.*usages remain in the codebase (src/hooks/useAxeAudit.ts,src/lib/requireEnv.ts,src/store/debug.ts, severalsrc/utils/security/files, etc.). These are now flagged by the newno-consolerule; they are NOT directly mentioned by refactor: consolidate logger usage #486's "notable offenders" list. A follow-up PR should migrate them.Validation
pnpm typecheck(TypeScript) — no new errors caused by this PR. Pre-existing syntax errors insrc/components/TransactionConfirmation.tsx,src/components/TransactionProgress.tsx,src/components/WalletModal.tsx, JSON locale files,src/store/comparisonStore.ts, andsrc/stories/ResponsiveContainerExample.stories.tsare unrelated.pnpm lint— pre-existing violations in unrelated files remain (@storybook/reactimports, missingreact/display-namerule, etc.). No new violations introduced by files modified in this PR.Files changed
Linked issues
🤖 Generated with Codebuff via the Stellar Wave Program.