Skip to content

⚡ [Performance] Wrap console.log in onNotification with __DEV__ check#226

Open
xRahul wants to merge 2 commits intomasterfrom
perf-remove-console-log-notification-17428890248048097133
Open

⚡ [Performance] Wrap console.log in onNotification with __DEV__ check#226
xRahul wants to merge 2 commits intomasterfrom
perf-remove-console-log-notification-17428890248048097133

Conversation

@xRahul
Copy link
Owner

@xRahul xRahul commented Feb 11, 2026

💡 What: Wrapped the synchronous console.log statement in src/App.js's onNotification handler with a if (__DEV__) { ... } check.

🎯 Why: Leaving debug logs in production code is a performance anti-pattern. console.log can be synchronous and blocking (or at least expensive) in React Native, potentially affecting UI responsiveness or notification handling speed. It also clutters production logs.

📊 Measured Improvement:
Verified using a new test suite __tests__/NotificationLogging.test.js.

  • Baseline: console.log was called on every notification.
  • Improvement: console.log is not called when __DEV__ is false (simulating production).
  • Correctness: console.log is still called when __DEV__ is true, preserving the developer experience.

The test suite explicitly mocks the environment to demonstrate that the code path is skipped in production.


PR created automatically by Jules for task 17428890248048097133 started by @xRahul

- Wraps the synchronous `console.log` statement in `App.js` `onNotification` handler with `if (__DEV__) { ... }` to prevent it from running in production builds.
- Adds `__tests__/NotificationLogging.test.js` to verify the behavior and prevent regression.

This optimization reduces I/O overhead in production and cleans up logs.

Co-authored-by: xRahul <1639945+xRahul@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

- Wraps the synchronous `console.log` statement in `App.js` `onNotification` handler with `if (__DEV__) { ... }` to prevent it from running in production builds.
- Adds `__tests__/NotificationLogging.test.js` to verify the behavior and prevent regression.
- Fixes linting errors in `__tests__/SettingsSwitchPerf.test.js` (unused vars, imports).

This optimization reduces I/O overhead in production and cleans up logs.

Co-authored-by: xRahul <1639945+xRahul@users.noreply.github.com>
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