Skip to content

ci: restore CI workflows, add Storybook config, and bound the ethers … - #1136

Merged
godwinameh merged 3 commits into
MettaChain:mainfrom
eulami:fix/eulami-1095-1098
Sep 26, 2026
Merged

godwinameh merged 3 commits into
MettaChain:mainfrom
eulami:fix/eulami-1095-1098

Conversation

@eulami

@eulami eulami commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Closes #1095
Closes #1096
Closes #1097
Closes #1098

The repo has drifted: .github/workflows/* was deleted in 6e2e7ff (an a11y commit that also removed all three CI workflows), .storybook/ was never committed at all even though package.json and vitest.config.ts both point at it, and src/middleware.ts lost the body of checkAdminAuth to a bad merge in b7d7980, which left the project unable to parse.

Fixes the three issues plus the blocking breakage:

  • Add dependabot config for github-actions ecosystem #1098 dependabot: add the github-actions ecosystem (weekly, grouped, same labels/reviewers as the npm entry) so workflow action versions are covered. The npm config is untouched.

  • Upload test coverage and Playwright artifacts from CI #1097 coverage/artifacts: restore .github/workflows/ci.yml and add the coverage/ and playwright-report/ + test-results/ artifact uploads that were missing, plus a coverage table in the job summary via scripts/write-coverage-summary.mjs. Untrack the committed test-results/ files — they were the "wrong workaround" the issue calls out and they are already gitignored, so they now come from the run instead of the tree.

  • Expand Storybook story coverage beyond the current components #1096 storybook: add the missing .storybook/main.ts and preview.tsx, and stories for the four priority components named in the issue (PropertyCard, FilterSidebar, WalletModal, NotificationCenter) covering their real states plus RTL. New storybook CI job builds Storybook and runs the story tests. a11y stays at the addon default for now: flipping it to a hard gate would fail CI on the pre-existing story inventory, which has never been triaged.

  • Determine canonical Web3 stack: ethers and viem/wagmi both in use #1095 web3 stack: record the decision in ADR-006 — viem + wagmi is canonical and ethers is confined to the two boundaries a third party forces (the Safe protocol-kit adapter and EIP-712 signing). Move the pure-utility ethers calls in cacheManager, secureTransactionUtils and TransactionAuditTrail to viem, and turn the three type-only import { ethers } uses into imports of a type-only re-export so they stop pulling a second Ethereum runtime in. no-restricted-imports now holds the boundary at three named files, so it can only shrink.

Also restores the truncated checkAdminAuth body so the project parses again; without it typecheck, lint and build could not run for anyone.

Fix #24: Replace Console Override System with Proper Error Handling

Summary

This PR addresses the critical issue where the application was implementing aggressive console overriding and error suppression mechanisms that masked critical runtime errors and compromised production debugging capabilities.

Problem Statement

The previous implementation was:

  • Suppressing critical runtime errors
  • Making production debugging impossible
  • Increasing mean time to resolution (MTTR) for incidents
  • Creating potential security vulnerabilities from suppressed error information
  • Providing poor developer experience and onboarding challenges

Solution Implemented

🗑️ Removed Problematic Files

  • Deleted src/utils/consoleOverride.ts
  • Deleted src/utils/manualErrorSuppressor.ts

✨ New Error Handling Framework

1. Structured Logging Service (src/utils/structuredLogger.ts)

  • Proper log levels: DEBUG, INFO, WARN, ERROR
  • Structured log entries with metadata and correlation tracking
  • Performance monitoring with automatic threshold alerts
  • Network request logging for API debugging
  • Web3 activity tracking for blockchain operations
  • Sensitive data filtering to protect private information
  • Remote logging capabilities for production monitoring

2. Error Monitoring Service (src/utils/errorMonitoringService.ts)

  • Real-time error monitoring with categorization
  • Automatic error recovery with exponential backoff
  • User feedback collection for error resolution
  • Performance metrics tracking
  • Error alerting with suggested actions
  • Retry mechanisms with configurable limits

3. Global Error Boundary (src/components/error/GlobalErrorBoundary.tsx)

  • Comprehensive error catching for all error types
  • Retry mechanisms with user-friendly controls
  • Graceful degradation when errors occur
  • Development vs production error display modes
  • Automatic recovery attempts for recoverable errors

4. Updated Application Integration (src/app/page.tsx)

  • Removed console override imports
  • Integrated structured logging
  • Added proper global error handling
  • Implemented error monitoring

🎯 Acceptance Criteria Met

✅ All console override mechanisms removed

  • Completely removed aggressive console suppression
  • No more hidden errors or masked runtime issues

✅ Structured logging implemented with proper log levels

  • DEBUG, INFO, WARN, ERROR levels properly implemented
  • Structured log entries with correlation IDs and metadata
  • Environment-aware logging configuration

✅ Error boundaries handle Web3, network, and AR-specific errors

  • Comprehensive error categorization system
  • Specialized handling for:
    • Web3 errors (wallet, transactions, networks)
    • Network errors (API failures, connectivity)
    • AR errors (augmented reality features)
    • UI errors (component failures)
    • Validation errors (input validation)
    • Permission errors (access control)
    • Resource errors (missing assets)
    • Authentication errors (login/session)

✅ Production error monitoring integrated and configured

  • Real-time error tracking and reporting
  • Performance monitoring with automatic alerts
  • User feedback collection system
  • Configurable monitoring settings

✅ Error reporting provides actionable insights for debugging

  • Structured error information with context
  • Stack traces and correlation IDs
  • Component and action tracking
  • Performance metrics and timing data

✅ Performance impact of logging is minimal (<5% overhead)

  • Efficient buffering and batching of logs
  • Configurable log levels for different environments
  • Lazy evaluation of expensive operations
  • Memory-efficient log management

🧪 Testing

  • Created comprehensive test suite (src/utils/errorHandlingTest.ts)
  • Verified console override removal
  • Tested structured logging functionality
  • Validated error monitoring capabilities
  • Confirmed performance monitoring works

🔧 Configuration Options

The new system provides extensive configuration options:

// Structured Logger Configuration
interface StructuredLoggerConfig {
  enablePerformanceMonitoring: boolean;
  enableNetworkLogging: boolean;
  enableWeb3Logging: boolean;
  enableErrorTracking: boolean;
  maxLogEntries: number;
  flushInterval: number;
}

// Error Monitoring Configuration  
interface ErrorMonitoringConfig {
  enableConsoleAlerts: boolean;
  enableUserNotifications: boolean;
  enableAutomaticRecovery: boolean;
  maxRetryAttempts: number;
  retryDelay: number;
  enablePerformanceMonitoring: boolean;
  performanceThreshold: number;
  enableUserFeedback: boolean;
}

📊 Benefits

For Developers

  • Better debugging: All errors are now visible and properly logged
  • Actionable insights: Structured logs provide context and metadata
  • Easier onboarding: Clear error messages and proper documentation
  • Development tools: Rich error information in development mode

For Production

  • Real-time monitoring: Immediate error detection and alerting
  • Automatic recovery: Self-healing capabilities for common issues
  • Performance tracking: Proactive performance issue detection
  • User feedback: Direct feedback loop for error resolution

For Security

  • Data protection: Automatic redaction of sensitive information
  • Controlled exposure: Environment-specific error detail levels
  • Audit trail: Comprehensive error logging for security analysis

🚀 Performance Impact

  • Minimal overhead: <5% performance impact as required
  • Efficient implementation: Optimized buffering and batching
  • Configurable verbosity: Can disable verbose logging in production
  • Memory conscious: Automatic cleanup and size limits

📝 Migration Guide

For Existing Code

  1. Replace console.log() → structuredLogger.info()
  2. Replace console.error() → structuredLogger.error()
  3. Add error boundaries around critical components
  4. Implement proper error categorization

For New Development

  1. Use structured logging from the start
  2. Implement error boundaries for major features
  3. Add performance monitoring for critical operations
  4. Configure appropriate log levels per environment

🔮 Future Enhancements

  • Integration with external services (Sentry, LogRocket)
  • Advanced error analytics and trend analysis
  • Automated alerting (Slack/Email notifications)
  • Real-time error monitoring dashboard

📋 Files Changed

  • Deleted: src/utils/consoleOverride.ts
  • Deleted: src/utils/manualErrorSuppressor.ts
  • Created: src/utils/structuredLogger.ts
  • Created: src/utils/errorMonitoringService.ts
  • Created: src/components/error/GlobalErrorBoundary.tsx
  • Modified: src/app/page.tsx
  • Created: src/utils/errorHandlingTest.ts
  • Created: ERROR_HANDLING_IMPLEMENTATION_SUMMARY.md

✅ Verification

  • All console override mechanisms removed
  • Structured logging with proper levels implemented
  • Error boundaries for all error categories
  • Production error monitoring configured
  • Actionable error reporting implemented
  • Performance impact < 5%
  • Test suite created and passing
  • Documentation complete

This implementation completely addresses the issues described in #24 and provides a robust, production-ready error handling framework that will significantly improve debugging capabilities and developer experience.

…surface

Closes MettaChain#1095, MettaChain#1096, MettaChain#1097, MettaChain#1098

The repo has drifted: .github/workflows/* was deleted in 6e2e7ff (an a11y
commit that also removed all three CI workflows), .storybook/ was never
committed at all even though package.json and vitest.config.ts both point at
it, and src/middleware.ts lost the body of checkAdminAuth to a bad merge in
b7d7980, which left the project unable to parse.

Fixes the three issues plus the blocking breakage:

- MettaChain#1098 dependabot: add the github-actions ecosystem (weekly, grouped, same
  labels/reviewers as the npm entry) so workflow action versions are covered.
  The npm config is untouched.

- MettaChain#1097 coverage/artifacts: restore .github/workflows/ci.yml and add the
  coverage/ and playwright-report/ + test-results/ artifact uploads that were
  missing, plus a coverage table in the job summary via
  scripts/write-coverage-summary.mjs. Untrack the committed test-results/ files
  — they were the "wrong workaround" the issue calls out and they are already
  gitignored, so they now come from the run instead of the tree.

- MettaChain#1096 storybook: add the missing .storybook/main.ts and preview.tsx, and
  stories for the four priority components named in the issue (PropertyCard,
  FilterSidebar, WalletModal, NotificationCenter) covering their real states
  plus RTL. New `storybook` CI job builds Storybook and runs the story tests.
  a11y stays at the addon default for now: flipping it to a hard gate would
  fail CI on the pre-existing story inventory, which has never been triaged.

- MettaChain#1095 web3 stack: record the decision in ADR-006 — viem + wagmi is canonical
  and ethers is confined to the two boundaries a third party forces (the Safe
  protocol-kit adapter and EIP-712 signing). Move the pure-utility ethers calls
  in cacheManager, secureTransactionUtils and TransactionAuditTrail to viem,
  and turn the three type-only `import { ethers }` uses into imports of a
  type-only re-export so they stop pulling a second Ethereum runtime in.
  no-restricted-imports now holds the boundary at three named files, so it
  can only shrink.

Also restores the truncated checkAdminAuth body so the project parses again;
without it typecheck, lint and build could not run for anyone.
@drips-wave

drips-wave Bot commented Sep 26, 2026

Copy link
Copy Markdown

@eulami 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! 🚀

Learn more about application limits

Every CI job starts with `npm ci`, and `npm ci` refuses to run when
package.json and package-lock.json disagree. The lockfile was missing
@emnapi/core and @emnapi/runtime, so all four jobs in MettaChain#1136 died at the
install step before running a single line of project code.

Regenerated with `npm install --package-lock-only`, which reconciles the
lockfile against package.json without touching installed packages or
re-resolving ranges beyond what the manifest already asks for.
The Safe boundary was cited as the hard blocker for dropping ethers, but
@safe-global/protocol-kit is neither declared in package.json nor installed,
so useSafeInfo.ts does not compile and useSafeInfo.test.ts fails on the
missing module. Only the EIP-712 boundary is real today.

Records that plainly, and notes the dependency has to be added before the
Safe question can even be answered.
@godwinameh
godwinameh merged commit 5bf8cc2 into MettaChain:main Sep 26, 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

2 participants