fix: replace direct console.* calls with SDK logger in react-ui package#1596
fix: replace direct console.* calls with SDK logger in react-ui package#1596devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Conversation
🦋 Changeset detectedLatest commit: e5ecdbc The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Original prompt from Guillecan you determine the issue and propose a PR in case it's feasible to maintain the silent logs flag in every part of our sdks? |
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
|
||
| export const reactUiLogger = new SdkLogger(); | ||
|
|
||
| export function initReactUiLogger(apiKey: string): void { |
There was a problem hiding this comment.
initReactUiLogger() is never called, so reactUiLogger remains uninitialized and falls back to raw console.*. Call this in CrossmintProvider (similar to how initReactLogger is called on line 26) to ensure utility functions respect consoleLogLevel.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/client/ui/react-ui/src/logger.ts
Line: 11
Comment:
`initReactUiLogger()` is never called, so `reactUiLogger` remains uninitialized and falls back to raw `console.*`. Call this in `CrossmintProvider` (similar to how `initReactLogger` is called on line 26) to ensure utility functions respect `consoleLogLevel`.
How can I resolve this? If you propose a fix, please make it concise.
🔥 Smoke Test Results✅ Status: Passed Statistics
✅ All smoke tests passed!All critical flows are working correctly. This is a non-blocking smoke test. Full regression tests run separately. |
Description
Part of the effort to make
consoleLogLevel="silent"work across all SDK packages. This PR replaces ~33 directconsole.*calls in@crossmint/client-sdk-react-uiwith SDK logger instances so they respect theconsoleLogLevelsetting configured viaCrossmintProvider.Two logging approaches are used depending on context:
useLogger(LoggerContext)(e.g.,CrossmintAuthProvider,useOAuthWindowListener)reactUiLoggersingleton (e.g.,handleEvmTransaction,handleSolanaTransaction,handleSuiTransaction, and several UI components likeBaseConfirmation,BaseCodeInput)A new
src/logger.tsfile is added with thereactUiLoggerinstance and aninitReactUiLogger(apiKey)initializer following the same pattern used in other packages (auth, window, wallets).initReactUiLogger()is exported but not called anywhere in this diff. Until it is called, thereactUiLoggersingleton will fall back to rawconsole.*(theSdkLoggeruninitialized behavior). This means the utility functions and non-context components usingreactUiLoggerwon't actually be silenced byconsoleLogLevel="silent"until initialization is wired up — likely inCrossmintProvider. The components usinguseLogger(LoggerContext)should work correctly since they receive an already-initialized logger from React context.Companion PRs for other packages:
@crossmint/wallets-sdk)@crossmint/client-sdk-auth)@crossmint/client-sdk-window)@crossmint/client-sdk-react-base)Test plan
pnpm lint)consoleLogLevel="silent"inCrossmintProviderand confirm logs from react-ui components are suppressed after loginPackage updates
@crossmint/client-sdk-react-ui: patch (changeset added)Link to Devin run
Requested by: Guille (@xmint-guille)