fix: replace direct console.* calls with SDK logger in react-base package#1595
fix: replace direct console.* calls with SDK logger in react-base package#1595devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 88f1f35 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 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:
|
Additional Comments (1)
Apply same fix to callbacks on lines 71, 82, 92, 102, and 113. Prompt To Fix With AIThis is a comment left during a code review.
Path: packages/client/react-base/src/hooks/useSignerAuth.ts
Line: 61-69
Comment:
`logger` missing from dependency array. All six useCallback hooks (lines 61-120) capture `logger` but have empty dependency arrays. If the logger instance changes (e.g., `apiKey` prop changes in CrossmintProvider), callbacks will use stale logger reference.
```suggestion
}, [logger]);
```
Apply same fix to callbacks on lines 71, 82, 92, 102, and 113.
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
Replaces all 10 direct
console.*calls in@crossmint/client-sdk-react-basewith the existing SDK logger accessed via React context (useLogger(LoggerContext)), so these logs respect theconsoleLogLevelsetting (e.g."silent").This is part of a series of per-package PRs to route all SDK console output through
SdkLogger. See related PRs: #1592 (wallets), #1593 (auth), #1594 (window).Files changed:
useSignerAuth.ts— 6console.error→logger.errorCrossmintAuthBaseProvider.tsx— 2console.error→logger.error, 1console.log→logger.infoCrossmintWalletBaseProvider.tsx— 1console.error→logger.error(already haduseLogger)useSignerAuthnow depends onLoggerContext: This hook now callsuseLogger(LoggerContext)internally, which will throw if the hook is ever used outside theCrossmintProvidertree. Currently it's only used insideCrossmintWalletBaseProvider, so this should be safe — but it's a new implicit contract.loggerinuseCallbackdependency arrays: TheuseCallbackhooks inuseSignerAuthhave empty[]dependency arrays but now capturelogger. If the logger reference is stable across renders (expected since it's memoized inCrossmintProvider), this is fine. If not, callbacks would hold a stale reference. Worth verifying.console.log("User not logged in")was changed tologger.info(...)sinceSdkLoggerhas no.log()method.infois the appropriate equivalent.Test plan
pnpm lint)console.*calls inpackages/client/react-base/src/Package updates
@crossmint/client-sdk-react-base: patch (changeset added)Link to Devin run: https://crossmint.devinenterprise.com/sessions/3befe224fd2b472594dafcd3fc100e7e
Requested by: @xmint-guille