Skip to content

fix: wrap console statements with __DEV__ guard in production code#1299

Open
Deepakchwdhry wants to merge 42 commits into
SB2318:mainfrom
Deepakchwdhry:fix/remove-unguarded-console-logs
Open

fix: wrap console statements with __DEV__ guard in production code#1299
Deepakchwdhry wants to merge 42 commits into
SB2318:mainfrom
Deepakchwdhry:fix/remove-unguarded-console-logs

Conversation

@Deepakchwdhry

Copy link
Copy Markdown

Summary

Wrapped all unguarded console.log/error/warn statements with __DEV__ guard across 65 files in frontend/src.

Changes

  • 265 console statements fixed
  • Affects components, screens, hooks, helpers, contexts

Why

Unguarded console statements run in production builds causing:

  • Performance degradation
  • Potential sensitive data leaks
  • Noise in crash reporters like Sentry

Closes #1257

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Thank you @, for creating the PR and contributing to our UltimateHealth project 💗.
Our team will review the PR and will reach out to you soon! 😇
Make sure that you have marked all the tasks that you are done with ✅.
Thank you for your patience! 😀

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Automated Review Feedback

Provide actionable comments grouped by severity:

Critical

The following onSizeUpdated callbacks introduce a syntax error by placing if (__DEV__) directly within a single-expression arrow function body. This will cause compilation failure or runtime errors. Please wrap the if (__DEV__) console.log(...) statement in curly braces {} or use a logical AND && operator.

  • frontend/src/components/ImprovementCard.tsx: Line 75
    -              onSizeUpdated={size => console.log(size.height)}
    +              onSizeUpdated={size => if (__DEV__) console.log(size.height)}
    Should be: onSizeUpdated={size => { if (__DEV__) console.log(size.height); }} or onSizeUpdated={size => (__DEV__ && console.log(size.height))}
  • frontend/src/screens/overview/ImprovementReviewScreen.tsx: Line 217
    -              onSizeUpdated={size => console.log(size.height)}
    +              onSizeUpdated={size => if (__DEV__) console.log(size.height)}
    Should be: onSizeUpdated={size => { if (__DEV__) console.log(size.height); }} or onSizeUpdated={size => (__DEV__ && console.log(size.height))}
  • frontend/src/screens/overview/ReviewScreen.tsx: Line 173
    -              onSizeUpdated={size => console.log(size.height)}
    +              onSizeUpdated={size => if (__DEV__) console.log(size.height)}
    Should be: onSizeUpdated={size => { if (__DEV__) console.log(size.height); }} or onSizeUpdated={size => (__DEV__ && console.log(size.height))}
  • frontend/src/screens/article/PreviewScreen.tsx: Line 434
    -          onSizeUpdated={size => console.log(size.height)}
    +          onSizeUpdated={size => if (__DEV__) console.log(size.height)}
    Should be: onSizeUpdated={size => { if (__DEV__) console.log(size.height); }} or onSizeUpdated={size => (__DEV__ && console.log(size.height))}

Suggestions

  • Redundant __DEV__ checks: In frontend/src/components/AppContent.tsx, there are instances where if (__DEV__) is nested within another if (__DEV__) block. The inner if (__DEV__) is redundant and can be removed for cleaner code.
    Example:
    -      if (__DEV__) {
    -        console.log(
    -          'Foreground notification received from message:',
    -          remoteMessage,
    -        );
    -      }
    +      if (__DEV__) {
    +        if (__DEV__) console.log(
    +          'Foreground notification received from message:',
    +          remoteMessage,
    +        );
    +      }
    Should be:
          if (__DEV__) {
            console.log(
              'Foreground notification received from message:',
              remoteMessage,
            );
          }
    This applies to multiple lines in AppContent.tsx.

Maintainer Note:

Once the initial automated feedback has been addressed, maintainer @SB2318 will review the pull request for final evaluation.

@rushiii3

rushiii3 commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

@Deepakchwdhry
Instead of wrapping every console.log, console.warn, and console.error with __DEV__ across 65 files, it would be better to create a centralized logger utility that handles the environment check internally. This reduces code duplication, improves maintainability, and keeps the codebase cleaner.

For example, you could create a logger.ts with methods like logger.log(), logger.warn(), and logger.error(), and perform the __DEV__ check inside the utility. Then all files can use the logger directly without additional guards. This approach also makes it easier to add features later, such as remote logging, analytics, or error reporting integrations.

@SB2318 SB2318 added the gssoc label Jun 9, 2026
@Deepakchwdhry

Copy link
Copy Markdown
Author

Hi @rushiii3 , thank you for the suggestion!

I have implemented a centralized logger.ts utility in frontend/src/helper/logger.ts that handles the __DEV__ check internally. All 68 files have been updated to use logger.log(), logger.warn(), and logger.error() instead of direct console calls with __DEV__ guards.

Also fixed the critical arrow function syntax errors in the 4 files mentioned in the automated review.

Please review! 🙏

@rushiii3

rushiii3 commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

@Deepakchwdhry
You haven't committed the updates yet, so I can't review them.

@Deepakchwdhry

Copy link
Copy Markdown
Author

Hi @rushiii3, thank you for the suggestion!

I have implemented a centralized logger.ts utility in frontend/src/helper/logger.ts that handles the __DEV__ check internally. All 68 files have been updated to use logger.log(), logger.warn(), and logger.error() instead of direct console calls with __DEV__ guards.

Also fixed the critical arrow function syntax errors in the 4 files mentioned in the automated review.

Please review! 🙏

@Deepakchwdhry

Copy link
Copy Markdown
Author

@rushiii3 done

@rushiii3

rushiii3 commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Looks good to me.
@SB2318 you can merge it

@SB2318

SB2318 commented Jun 9, 2026

Copy link
Copy Markdown
Owner

/review

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

🤖 Gemini AI Code Review

Summary

This Pull Request aims to improve application performance, security, and reduce noise in production monitoring by wrapping all console.log, console.warn, and console.error statements with a __DEV__ guard. This is achieved by introducing a new logger utility that conditionally outputs messages only in development environments. The PR modifies 65 files, replacing 265 console statements.

Overall, the intent and general approach of this PR are excellent, addressing critical production concerns. The introduction of a centralized logger utility is a significant architectural improvement. However, there are critical import issues that prevent the application from running correctly, as well as some minor nits.

🔴 High Severity

  • Issue: Several helper files (MMKVUtils.ts, MultiLanguageService.ts, SecureStorageUtils.ts, Utils.ts) are attempting to import the new logger utility using a bare import specifier (import logger from 'logger';).

  • Impact: This will cause a runtime error (e.g., "Module not found") because the JavaScript module resolver will look for a package named logger in node_modules instead of the local file frontend/src/helper/logger.ts. This will prevent the application from starting or functioning correctly in any environment.

  • Fix: The import paths need to be relative to the importing file. For files within the helper directory, it should be import logger from './logger';. For files outside helper but within src, it would be import logger from '../helper/logger';.

    Example Fix for frontend/src/helper/MMKVUtils.ts:

    --- a/frontend/src/helper/MMKVUtils.ts
    +++ b/frontend/src/helper/MMKVUtils.ts
    @@ -1,4 +1,5 @@
     import AsyncStorage from '@react-native-async-storage/async-storage';
    -import logger from 'logger';
    +import logger from './logger'; // Corrected relative import
     import {PodcastData} from '../type';

    This fix needs to be applied to all files with the incorrect bare import:

    • frontend/src/helper/MMKVUtils.ts
    • frontend/src/helper/MultiLanguageService.ts
    • frontend/src/helper/SecureStorageUtils.ts
    • frontend/src/helper/Utils.ts

🟡 Medium Severity

  • Issue: In frontend/src/screens/ProfileEditScreen.tsx, the validation calls validateContactFields() and validateProfessionalFields() are commented out, but the logger.log('donee') statement immediately following them is uncommented.

  • Impact: This suggests that critical input validation might be intentionally or accidentally disabled, which could lead to invalid data being submitted to the backend. The uncommented logger.log might be a leftover from debugging, indicating that the validation logic was bypassed.

  • Fix: Re-enable the validation calls and ensure they are correctly integrated into the submission flow. Remove any extraneous logger.log statements that are not serving a clear purpose.

    Example Fix for frontend/src/screens/ProfileEditScreen.tsx (lines 180-183, 255-258):

    --- a/frontend/src/screens/ProfileEditScreen.tsx
    +++ b/frontend/src/screens/ProfileEditScreen.tsx
    @@ -180,8 +180,8 @@ const ProfileEditScreen = ({navigation}: ProfileEditScreenProp) => {
         });
         return;
       }
    -  //logger.log('donee');
    -  //userConatctDetailsMutation.mutate();
    +  const errorMessage = validateContactFields();
    +  if (errorMessage) { Alert.alert('Validation Error', errorMessage); return; }
    
       updateContactDetails(
         {
    @@ -255,8 +255,8 @@ const ProfileEditScreen = ({navigation}: ProfileEditScreenProp) => {
         });
         return;
       }
    -  //logger.log('donee');
    +  const errorMessage = validateProfessionalFields();
    +  if (errorMessage) { Alert.alert('Validation Error', errorMessage); return; }
    
       updateProfessionalDetails(
         {

🟢 Low Severity / Nits

  • Issue: Several previously commented-out console.log statements were mechanically converted to logger.log but remained commented out.

    • Examples:
      • frontend/src/components/CommentItem.tsx: //logger.log("Item", item);
      • frontend/src/components/DropDownComponent.tsx: //logger.log(isAlreadyExist);
      • frontend/src/components/ImprovementCard.tsx: // logger.log('ImprovementCard item:', item);
      • frontend/src/components/ReviewCard.tsx: //logger.log('Image Utils', item?.imageUtils[0]);
      • frontend/src/helper/Utils.ts: // logger.log(\Value saved for key : ${key}`, value);`
      • frontend/src/hooks/usePostArticle.ts: // logger.log(article);
      • frontend/src/hooks/useSubmitImprovement.ts: // logger.log(article);
      • frontend/src/screens/ChatbotScreen.tsx: //logger.log("User Token", user_token);
      • frontend/src/screens/HomeScreen.tsx: // logger.log("enter"), //logger.log("enter ele", articleCategories);, //logger.log('Search Input', textInput);
      • frontend/src/screens/OfflinePodcastDetails.tsx: //logger.log("File path", \${filePath}`);`
      • frontend/src/screens/PodcastDiscussion.tsx: //logger.log('Fetching comments for articleId:', route.params.articleId);, //logger.log('new comment loaded', data);, //logger.log('Comments Length', comments.length);, // logger.log('Comment emitting', newCommentObj);
      • frontend/src/screens/PodcastRecorder.tsx: // logger.log('File path', path);, // logger.log('Error deleting file:', err);, // logger.log('File saved at:', data.filePath);, //logger.log('event',event);, //logger.log('amplitudes', amplitudes);
      • frontend/src/screens/ProfileEditScreen.tsx: // logger.log('Password Update Error', err);, //logger.log('User cancelled image picker');, //logger.log(err);
      • frontend/src/screens/SplashScreen.tsx: //logger.log('User cancelled image picker');
      • frontend/src/screens/article/ArticleDescriptionScreen.tsx: //logger.log('User cancelled image picker');
      • frontend/src/screens/article/EditorScreen.tsx: //logger.log('Preview Screen');, // logger.error('Error fetching URI:', error);, // logger.log("editor height change:", height);, //logger.log('No image selected');, // logger.log('Image URI:', fileUri);, //logger.log('No video selected');
      • frontend/src/screens/article/PreviewScreen.tsx: // logger.log(selectedGenres);
      • frontend/src/screens/overview/ImprovementReviewScreen.tsx: // logger.log('comment loaded', data);
  • Impact: While harmless as they are commented, it indicates a mechanical find-and-replace without considering the original intent or necessity of the commented code. It adds minor noise to the codebase.

  • Fix: Consider removing these commented-out logger.log statements if they are no longer relevant or useful, or re-evaluate if they should be active logger.log calls.

  • Issue: In frontend/src/components/ImprovementCard.tsx and frontend/src/screens/article/PreviewScreen.tsx, the onSizeUpdated prop for AutoHeightWebView was changed from onSizeUpdated={size => console.log(size.height)} to onSizeUpdated={size => { logger.log(size.height); }}.

  • Impact: The curly braces {} around logger.log(size.height); are not strictly necessary for a single statement in an arrow function.

  • Fix: For conciseness, this can be simplified to onSizeUpdated={size => logger.log(size.height)}. This is purely a stylistic preference.

What's Good ✅

  1. Excellent Abstraction and Centralization: The creation of frontend/src/helper/logger.ts is a fantastic architectural decision. It centralizes all logging logic, making it incredibly easy to manage, modify, or extend logging behavior in the future (e.g., integrating with a dedicated logging service or Sentry for specific log levels in production).
  2. Significant Performance and Security Improvement: The core goal of the PR—to remove console statements from production builds—is perfectly achieved. This will lead to smaller bundle sizes, improved runtime performance (no unnecessary I/O operations for logging), and enhanced security by preventing accidental exposure of sensitive data in production logs.
  3. Thoroughness in Application: The PR demonstrates a comprehensive effort by applying the logger utility across 65 files and fixing 265 statements. This widespread adoption ensures consistency and maximizes the benefits of the new logging abstraction.

Verdict

Request Changes

The PR introduces a critical bug with incorrect bare imports for the logger utility in several helper files. This will prevent the application from running. Additionally, there's a medium-severity issue regarding potentially disabled validation in ProfileEditScreen.tsx. Once these issues are addressed, this PR will be a significant improvement to the codebase.

@SB2318

SB2318 commented Jun 9, 2026

Copy link
Copy Markdown
Owner

🤖 Gemini AI Code Review

Summary

This Pull Request aims to improve application performance, security, and reduce noise in production monitoring by wrapping all console.log, console.warn, and console.error statements with a __DEV__ guard. This is achieved by introducing a new logger utility that conditionally outputs messages only in development environments. The PR modifies 65 files, replacing 265 console statements.

Overall, the intent and general approach of this PR are excellent, addressing critical production concerns. The introduction of a centralized logger utility is a significant architectural improvement. However, there are critical import issues that prevent the application from running correctly, as well as some minor nits.

🔴 High Severity

  • Issue: Several helper files (MMKVUtils.ts, MultiLanguageService.ts, SecureStorageUtils.ts, Utils.ts) are attempting to import the new logger utility using a bare import specifier (import logger from 'logger';).

  • Impact: This will cause a runtime error (e.g., "Module not found") because the JavaScript module resolver will look for a package named logger in node_modules instead of the local file frontend/src/helper/logger.ts. This will prevent the application from starting or functioning correctly in any environment.

  • Fix: The import paths need to be relative to the importing file. For files within the helper directory, it should be import logger from './logger';. For files outside helper but within src, it would be import logger from '../helper/logger';.
    Example Fix for frontend/src/helper/MMKVUtils.ts:

    --- a/frontend/src/helper/MMKVUtils.ts
    +++ b/frontend/src/helper/MMKVUtils.ts
    @@ -1,4 +1,5 @@
     import AsyncStorage from '@react-native-async-storage/async-storage';
    -import logger from 'logger';
    +import logger from './logger'; // Corrected relative import
     import {PodcastData} from '../type';

    This fix needs to be applied to all files with the incorrect bare import:

    • frontend/src/helper/MMKVUtils.ts
    • frontend/src/helper/MultiLanguageService.ts
    • frontend/src/helper/SecureStorageUtils.ts
    • frontend/src/helper/Utils.ts

🟡 Medium Severity

  • Issue: In frontend/src/screens/ProfileEditScreen.tsx, the validation calls validateContactFields() and validateProfessionalFields() are commented out, but the logger.log('donee') statement immediately following them is uncommented.
  • Impact: This suggests that critical input validation might be intentionally or accidentally disabled, which could lead to invalid data being submitted to the backend. The uncommented logger.log might be a leftover from debugging, indicating that the validation logic was bypassed.
  • Fix: Re-enable the validation calls and ensure they are correctly integrated into the submission flow. Remove any extraneous logger.log statements that are not serving a clear purpose.
    Example Fix for frontend/src/screens/ProfileEditScreen.tsx (lines 180-183, 255-258):
    --- a/frontend/src/screens/ProfileEditScreen.tsx
    +++ b/frontend/src/screens/ProfileEditScreen.tsx
    @@ -180,8 +180,8 @@ const ProfileEditScreen = ({navigation}: ProfileEditScreenProp) => {
         });
         return;
       }
    -  //logger.log('donee');
    -  //userConatctDetailsMutation.mutate();
    +  const errorMessage = validateContactFields();
    +  if (errorMessage) { Alert.alert('Validation Error', errorMessage); return; }
    
       updateContactDetails(
         {
    @@ -255,8 +255,8 @@ const ProfileEditScreen = ({navigation}: ProfileEditScreenProp) => {
         });
         return;
       }
    -  //logger.log('donee');
    +  const errorMessage = validateProfessionalFields();
    +  if (errorMessage) { Alert.alert('Validation Error', errorMessage); return; }
    
       updateProfessionalDetails(
         {

🟢 Low Severity / Nits

  • Issue: Several previously commented-out console.log statements were mechanically converted to logger.log but remained commented out.

    • Examples:

      • frontend/src/components/CommentItem.tsx: //logger.log("Item", item);
      • frontend/src/components/DropDownComponent.tsx: //logger.log(isAlreadyExist);
      • frontend/src/components/ImprovementCard.tsx: // logger.log('ImprovementCard item:', item);
      • frontend/src/components/ReviewCard.tsx: //logger.log('Image Utils', item?.imageUtils[0]);
      • frontend/src/helper/Utils.ts: // logger.log(\Value saved for key : ${key}, value);
      • frontend/src/hooks/usePostArticle.ts: // logger.log(article);
      • frontend/src/hooks/useSubmitImprovement.ts: // logger.log(article);
      • frontend/src/screens/ChatbotScreen.tsx: //logger.log("User Token", user_token);
      • frontend/src/screens/HomeScreen.tsx: // logger.log("enter"), //logger.log("enter ele", articleCategories);, //logger.log('Search Input', textInput);
      • frontend/src/screens/OfflinePodcastDetails.tsx: //logger.log("File path", \${filePath});
      • frontend/src/screens/PodcastDiscussion.tsx: //logger.log('Fetching comments for articleId:', route.params.articleId);, //logger.log('new comment loaded', data);, //logger.log('Comments Length', comments.length);, // logger.log('Comment emitting', newCommentObj);
      • frontend/src/screens/PodcastRecorder.tsx: // logger.log('File path', path);, // logger.log('Error deleting file:', err);, // logger.log('File saved at:', data.filePath);, //logger.log('event',event);, //logger.log('amplitudes', amplitudes);
      • frontend/src/screens/ProfileEditScreen.tsx: // logger.log('Password Update Error', err);, //logger.log('User cancelled image picker');, //logger.log(err);
      • frontend/src/screens/SplashScreen.tsx: //logger.log('User cancelled image picker');
      • frontend/src/screens/article/ArticleDescriptionScreen.tsx: //logger.log('User cancelled image picker');
      • frontend/src/screens/article/EditorScreen.tsx: //logger.log('Preview Screen');, // logger.error('Error fetching URI:', error);, // logger.log("editor height change:", height);, //logger.log('No image selected');, // logger.log('Image URI:', fileUri);, //logger.log('No video selected');
      • frontend/src/screens/article/PreviewScreen.tsx: // logger.log(selectedGenres);
      • frontend/src/screens/overview/ImprovementReviewScreen.tsx: // logger.log('comment loaded', data);
  • Impact: While harmless as they are commented, it indicates a mechanical find-and-replace without considering the original intent or necessity of the commented code. It adds minor noise to the codebase.

  • Fix: Consider removing these commented-out logger.log statements if they are no longer relevant or useful, or re-evaluate if they should be active logger.log calls.

  • Issue: In frontend/src/components/ImprovementCard.tsx and frontend/src/screens/article/PreviewScreen.tsx, the onSizeUpdated prop for AutoHeightWebView was changed from onSizeUpdated={size => console.log(size.height)} to onSizeUpdated={size => { logger.log(size.height); }}.

  • Impact: The curly braces {} around logger.log(size.height); are not strictly necessary for a single statement in an arrow function.

  • Fix: For conciseness, this can be simplified to onSizeUpdated={size => logger.log(size.height)}. This is purely a stylistic preference.

What's Good ✅

  1. Excellent Abstraction and Centralization: The creation of frontend/src/helper/logger.ts is a fantastic architectural decision. It centralizes all logging logic, making it incredibly easy to manage, modify, or extend logging behavior in the future (e.g., integrating with a dedicated logging service or Sentry for specific log levels in production).
  2. Significant Performance and Security Improvement: The core goal of the PR—to remove console statements from production builds—is perfectly achieved. This will lead to smaller bundle sizes, improved runtime performance (no unnecessary I/O operations for logging), and enhanced security by preventing accidental exposure of sensitive data in production logs.
  3. Thoroughness in Application: The PR demonstrates a comprehensive effort by applying the logger utility across 65 files and fixing 265 statements. This widespread adoption ensures consistency and maximizes the benefits of the new logging abstraction.

Verdict

Request Changes

The PR introduces a critical bug with incorrect bare imports for the logger utility in several helper files. This will prevent the application from running. Additionally, there's a medium-severity issue regarding potentially disabled validation in ProfileEditScreen.tsx. Once these issues are addressed, this PR will be a significant improvement to the codebase.

Headmaster Ji, why does your performance always peak here?

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

🤖 Gemini AI Code Review

Summary

This Pull Request aims to address a critical production issue by wrapping all console.log, console.warn, and console.error statements with a __DEV__ guard. This is achieved by introducing a new logger utility (frontend/src/helper/logger.ts) that conditionally calls the native console methods only when in a development environment. The PR states that it fixes 265 console statements across 65 files, which is a significant and positive change for performance, security, and reducing noise in production monitoring.

The overall intent and approach are excellent and directly tackle a common pitfall in frontend development. However, a deep dive into the changes reveals some critical issues that need to be addressed before merging.

🔴 High Severity

These issues will cause runtime errors or prevent the application from building/running correctly.

  • Issue: Incorrect logger import paths in MMKVUtils.ts and MultiLanguageService.ts
    • Impact: The import statement import logger from 'logger'; is incorrect. logger is a local file (../helper/logger), not a node module. This will lead to a module resolution error at build time or runtime, causing the application to crash or fail to start.
    • Fix:
      diff --git a/frontend/src/helper/MMKVUtils.ts b/frontend/src/helper/MMKVUtils.ts
      index 2dadfdad..69170dbf 100644
      --- a/frontend/src/helper/MMKVUtils.ts
      +++ b/frontend/src/helper/MMKVUtils.ts
      @@ -1,4 +1,5 @@
       import AsyncStorage from '@react-native-async-storage/async-storage';
      -import logger from 'logger';
      +import logger from './logger'; // Corrected import path
       import {PodcastData} from '../type';
       
       type MMKVStorageLike = {
      diff --git a/frontend/src/helper/MultiLanguageService.ts b/frontend/src/helper/MultiLanguageService.ts
      index 03d960b5..2ad62c92 100644
      --- a/frontend/src/helper/MultiLanguageService.ts
      +++ b/frontend/src/helper/MultiLanguageService.ts
      @@ -1,4 +1,5 @@
       import Tts from "react-native-tts";
      -import logger from 'logger';
      +import logger from './logger'; // Corrected import path
       import { Platform } from "react-native";
       
       type SupportedLang = "en-IN" | "hi-IN" | "bn-IN" | "ta-IN";

🟡 Medium Severity

These issues represent architectural concerns, redundant code, or minor bugs that should be addressed for better maintainability and efficiency.

  • Issue: Redundant __DEV__ guards around logger calls

    • Impact: The newly introduced logger utility already contains an if (__DEV__) check internally. Wrapping logger.log, logger.warn, or logger.error calls with an additional if (__DEV__) block is redundant. While it doesn't break functionality, it adds unnecessary code, reduces readability, and defeats some of the purpose of abstracting the logging.
    • Fix: Remove the outer if (__DEV__) checks.
      // Example from frontend/src/components/AppContent.tsx
      diff --git a/frontend/src/components/AppContent.tsx b/frontend/src/components/AppContent.tsx
      index f092b26f..2fc23290 100644
      --- a/frontend/src/components/AppContent.tsx
      +++ b/frontend/src/components/AppContent.tsx
      @@ -90,7 +91,7 @@ export default function AppContent() {
             // FCM message content (including user-targeted data fields) to
             // production log aggregators or crash reporters.
             if (__DEV__) {
      -        console.log(
      +        logger.log( // This `if (__DEV__)` is redundant
                 'Foreground notification received from message:',
                 remoteMessage,
               );
      @@ -99,8 +100,8 @@ export default function AppContent() {
       
           const unsubscribe1 = addEventListener(state => {
             if (__DEV__) {
      -        console.log('Connection type', state.type);
      -        console.log('Is connected?', state.isConnected);
      +        logger.log('Connection type', state.type); // This `if (__DEV__)` is redundant
      +        logger.log('Is connected?', state.isConnected); // This `if (__DEV__)` is redundant
             }
             /** Dispatch use a reducer to update the value in store */
             dispatch(setConnected(state.isConnected));
      @@ -108,7 +109,7 @@ export default function AppContent() {
       
           const onOpenApp = messaging().onNotificationOpenedApp(remoteMessage => {
             if (__DEV__) {
      -        console.log('Notification caused app to open:', remoteMessage);
      +        logger.log('Notification caused app to open:', remoteMessage); // This `if (__DEV__)` is redundant
             }
             // const data = remoteMessage.data;
             // handleNotification(data);
      Apply this fix to all instances where logger.* is wrapped in if (__DEV__), including:
      • frontend/src/components/AppContent.tsx
      • frontend/src/contexts/SocketContext.tsx
      • frontend/src/hooks/useUploadAudio.tsx
      • frontend/src/hooks/useUploadImage.tsx
      • frontend/src/screens/HomeScreen.tsx
      • frontend/src/screens/auth/LoginScreen.tsx
  • Issue: Unused logger imports due to commented-out code

    • Impact: Several files import the logger utility, but the logger.log (or warn/error) calls are commented out. This leaves unused imports, which can slightly increase bundle size and clutter the codebase.
    • Fix: Remove the import logger from '...' statement if all its usages are commented out.
      • frontend/src/components/CommentItem.tsx
      • frontend/src/components/DropDownComponent.tsx
      • frontend/src/components/ReviewCard.tsx
      • frontend/src/hooks/usePostArticle.ts
      • frontend/src/hooks/useSubmitImprovement.ts
      • frontend/src/screens/article/ArticleDescriptionScreen.tsx
      • frontend/src/screens/article/EditorScreen.tsx
      • frontend/src/screens/auth/SignUpScreenFirst.tsx

🟢 Low Severity / Nits

These are minor suggestions for code style, consistency, or potential improvements.

  • Consistency in commented console statements: Some commented-out console.log statements were updated to logger.log (e.g., ArticleCard.tsx), while others were left as console.log (e.g., PodcastDiscussion.tsx). For consistency, it would be better to either update all commented console statements to logger or remove them if they are truly dead code and not intended for future debugging.
  • Immutability of the logger object: Consider freezing the logger object in frontend/src/helper/logger.ts to prevent accidental modification at runtime.
    // frontend/src/helper/logger.ts
    const logger = {
      // ... methods
    };
    
    export default Object.freeze(logger); // Add Object.freeze()
  • onSizeUpdated callback in AutoHeightWebView: In several files (ImprovementCard.tsx, PreviewScreen.tsx, ImprovementReviewScreen.tsx, ReviewScreen.tsx), the onSizeUpdated prop of AutoHeightWebView now uses logger.log(size.height);. If this logging is purely for debugging layout in development and serves no functional purpose, consider removing the callback entirely to avoid unnecessary function calls. If it's a useful dev tool, it's fine to keep.
  • Unnecessary commented logger.log statements: In frontend/src/screens/PodcastDiscussion.tsx, frontend/src/screens/ProfileEditScreen.tsx, and frontend/src/screens/auth/SignUpScreenFirst.tsx, there are commented logger.log statements. If these are not intended for future use, they should be removed.

What's Good ✅

  1. Centralized Logging Solution: The creation of frontend/src/helper/logger.ts provides a clean, centralized, and reusable way to manage console output, which is a significant improvement over scattered if (__DEV__) blocks.
  2. Comprehensive Application: The PR demonstrates a thorough effort by applying the logging guard across a large number of files (65 files, 265 statements), indicating a commitment to code quality and production readiness.
  3. Improved Production Performance and Security: By preventing console statements from running in production, the PR directly addresses potential performance bottlenecks, reduces the risk of sensitive data exposure, and minimizes noise in crash reporting tools like Sentry.

Verdict

Request Changes

The incorrect import paths for the logger utility in frontend/src/helper/MMKVUtils.ts and frontend/src/helper/MultiLanguageService.ts are high-severity issues that will prevent the application from running. These must be fixed. Additionally, addressing the redundant __DEV__ guards and cleaning up unused imports will improve code quality and maintainability.

@SB2318 SB2318 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@Deepakchwdhry Please read the recent bot review and update logger import accordingly.

@Deepakchwdhry

Copy link
Copy Markdown
Author

@SB2318 Fixed the following issues as per the bot review:

  1. ✅ Corrected bare import paths to relative paths (./logger) in helper files - MMKVUtils.ts, MultiLanguageService.ts, SecureStorageUtils.ts, Utils.ts
  2. ✅ Removed redundant __DEV__ guards around logger calls in AppContent.tsx
  3. ✅ Removed unused logger imports from files with commented-out calls

Please review! 🙏

@Deepakchwdhry Deepakchwdhry left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

reviewed

SB2318 and others added 28 commits June 10, 2026 16:27
The mutationFn in useSendOtpMutation was forwarding res.data.otp directly as its return value, meaning the raw OTP token was surfaced to the React Query result object and any intermediate logging layer.

Per maintainer scope (issue SB2318#1210): the frontend fix is to remove all client-side consumption of the OTP from the API response. The backend will separately stop including the otp field in the response body.

Changes:
- Change UseMutationResult type parameter from string to �oid
- Replace 
eturn res.data.otp as string with �oid res so no token value is ever forwarded out of the mutation
- Both call sites (OtpScreen, LoginScreen) already ignore the return value in their onSuccess callbacks — no changes needed there
Bumps [@lottiefiles/dotlottie-react](https://github.com/LottieFiles/dotlottie-web/tree/HEAD/packages/react) from 0.13.5 to 0.19.4.
- [Release notes](https://github.com/LottieFiles/dotlottie-web/releases)
- [Changelog](https://github.com/LottieFiles/dotlottie-web/blob/main/packages/react/CHANGELOG.md)
- [Commits](https://github.com/LottieFiles/dotlottie-web/commits/@lottiefiles/dotlottie-react@0.19.4/packages/react)

---
updated-dependencies:
- dependency-name: "@lottiefiles/dotlottie-react"
  dependency-version: 0.19.4
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [react-native-safe-area-context](https://github.com/AppAndFlow/react-native-safe-area-context) from 5.6.2 to 5.8.0.
- [Release notes](https://github.com/AppAndFlow/react-native-safe-area-context/releases)
- [Commits](AppAndFlow/react-native-safe-area-context@v5.6.2...v5.8.0)

---
updated-dependencies:
- dependency-name: react-native-safe-area-context
  dependency-version: 5.8.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [react-native-svg](https://github.com/software-mansion/react-native-svg) from 15.12.1 to 15.15.5.
- [Release notes](https://github.com/software-mansion/react-native-svg/releases)
- [Commits](software-mansion/react-native-svg@v15.12.1...v15.15.5)

---
updated-dependencies:
- dependency-name: react-native-svg
  dependency-version: 15.15.5
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [expo/expo-github-action](https://github.com/expo/expo-github-action) from 8 to 9.
- [Release notes](https://github.com/expo/expo-github-action/releases)
- [Changelog](https://github.com/expo/expo-github-action/blob/main/CHANGELOG.md)
- [Commits](expo/expo-github-action@v8...v9)

---
updated-dependencies:
- dependency-name: expo/expo-github-action
  dependency-version: '9'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
@Deepakchwdhry Deepakchwdhry force-pushed the fix/remove-unguarded-console-logs branch from 3da069a to d447a1c Compare June 10, 2026 11:00
@SB2318

SB2318 commented Jun 11, 2026

Copy link
Copy Markdown
Owner

@Deepakchwdhry, please fix the conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐞[Bug]: Unguarded console.log/error/warn statements leaking into production builds

8 participants