This document describes the debug system and mocked data implementation for the Grupo Raia web client.
The application currently operates with mock data since the backend is not yet implemented:
- Development Mode (Default) - Debug tools available, mock data enabled by default
- Production with Mocked Data - Uses mock data (MSW - Mock Service Worker)
We've implemented a centralized debug control system to manage console logging and debug features:
debugLog()- Controlled console logging that only appears in debug modedebugWarn()- Controlled console warning that only appears in debug modedebugError()- Controlled console error that always appears but with different formattingisDebugEnabled()- Function to check if debug features should be enabledshouldUseMockData()- Function to check if mock data should be used
These utilities are located in src/utils/debugControl.ts.
The following npm scripts are available:
# Development with default settings (debug mode enabled by default)
npm run dev
# Development with production-like settings (no debug)
npm run dev:prod
# Build for production with mock data
npm run build
# Build for production with mock data (explicit)
npm run build:mocked
# Check for console.log statements in codebase
npm run clean:logs:check
# Replace console.log statements with debugLog across codebase
npm run clean:logs:fixThe behavior is controlled through environment variables:
VITE_USE_MOCK_DATA=true- Forces the use of mock data (currently always true)
We provide several environment configurations:
.env.debug- Development with explicit debug features.env.mocked- Production build with mock data
To clean up unnecessary console logs:
- Check for console logs:
npm run clean:logs:check - Replace them with debug utilities:
npm run clean:logs:fix
Always use the debug utilities instead of direct console.log statements to ensure proper behavior in production builds.
- Never use direct
console.logstatements - usedebugLoginstead - Use
debugWarnfor warnings that should only appear in debug mode - Use
debugErrorfor errors that should always be visible - Use the
isDebugEnabled()check before rendering debug-only UI components - Use the
shouldUseMockData()check to determine if mock data should be used