Skip to content

fix: replace direct console.* calls with SDK logger in react-base package#1595

Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1771609051-react-base-use-sdk-logger
Open

fix: replace direct console.* calls with SDK logger in react-base package#1595
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1771609051-react-base-use-sdk-logger

Conversation

@devin-ai-integration
Copy link
Contributor

Description

Replaces all 10 direct console.* calls in @crossmint/client-sdk-react-base with the existing SDK logger accessed via React context (useLogger(LoggerContext)), so these logs respect the consoleLogLevel setting (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 — 6 console.errorlogger.error
  • CrossmintAuthBaseProvider.tsx — 2 console.errorlogger.error, 1 console.loglogger.info
  • CrossmintWalletBaseProvider.tsx — 1 console.errorlogger.error (already had useLogger)

⚠️ Items for reviewer attention

  1. useSignerAuth now depends on LoggerContext: This hook now calls useLogger(LoggerContext) internally, which will throw if the hook is ever used outside the CrossmintProvider tree. Currently it's only used inside CrossmintWalletBaseProvider, so this should be safe — but it's a new implicit contract.
  2. Missing logger in useCallback dependency arrays: The useCallback hooks in useSignerAuth have empty [] dependency arrays but now capture logger. If the logger reference is stable across renders (expected since it's memoized in CrossmintProvider), this is fine. If not, callbacks would hold a stale reference. Worth verifying.
  3. Level mapping: console.log("User not logged in") was changed to logger.info(...) since SdkLogger has no .log() method. info is the appropriate equivalent.

Test plan

  • Lint passes (pnpm lint)
  • No existing tests were broken
  • Manual verification: confirm no remaining direct console.* calls in packages/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

@changeset-bot
Copy link

changeset-bot bot commented Feb 20, 2026

🦋 Changeset detected

Latest commit: 88f1f35

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@crossmint/client-sdk-react-base Patch
@crossmint/client-sdk-react-native-ui Patch
@crossmint/client-sdk-react-ui Patch
expo-demo Patch
@crossmint/auth-ssr-nextjs-demo Patch
@crossmint/client-sdk-nextjs-starter Patch
@crossmint/wallets-quickstart-devkit Patch

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

@devin-ai-integration
Copy link
Contributor Author

Original prompt from Guille
we introduced the following change here to supress logs in our sdks:
https://github.com/Crossmint/crossmint-sdk/commit/27194e5751fd4bb3afb190550382760f978d7a20

i've tried this with the following code snippet, and I can still see logs once I'm logged in:
```ts
"use client";

import {
  CrossmintProvider,
  CrossmintAuthProvider,
  CrossmintWalletProvider,
  useAuth,
  useWallet,
} from "@crossmint/client-sdk-react-ui";

function WalletUser() {
  const { login, user } = useAuth();
  const { wallet, status } = useWallet();

  return (
    <div>
      {user == null ? (
        <button onClick={login}>Sign In</button>
      ) : (
        <p>
          Wallet: {wallet?.address} ({status})
        </p>
      )}
    </div>
  );
}

export default function Page() {
  return (
    <CrossmintProvider
      apiKey={process.env.NEXT_PUBLIC_CLIENT_API_KEY ?? ""}
      consoleLogLevel="silent"
    >
      <CrossmintAuthProvider>
        <CrossmintWalletProvider
          createOnLogin={{
            chain: "polygon-amoy",
            signer: { type: "email" },
          }}
        >
          <WalletUser />
        </CrossmintWalletProvider>
      </CrossmintAuthProvider>
    </CrossmintProvider>
  );
}

can 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?

</details>

@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

4 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 20, 2026

Additional Comments (1)

packages/client/react-base/src/hooks/useSignerAuth.ts
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.

    }, [logger]);

Apply same fix to callbacks on lines 71, 82, 92, 102, and 113.

Prompt To Fix With AI
This 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.

@github-actions
Copy link
Contributor

🔥 Smoke Test Results

Status: Passed

Statistics

  • Total Tests: 5
  • Passed: 5 ✅
  • Failed: 0
  • Skipped: 0
  • Duration: 5.36 min

✅ All smoke tests passed!

All critical flows are working correctly.


This is a non-blocking smoke test. Full regression tests run separately.

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