Skip to content

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

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

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

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

Description

Part of the effort to make consoleLogLevel="silent" work across all SDK packages. This PR replaces ~33 direct console.* calls in @crossmint/client-sdk-react-ui with SDK logger instances so they respect the consoleLogLevel setting configured via CrossmintProvider.

Two logging approaches are used depending on context:

  • React components/hooks with access to React context use useLogger(LoggerContext) (e.g., CrossmintAuthProvider, useOAuthWindowListener)
  • Plain utility functions outside the React tree use a package-level reactUiLogger singleton (e.g., handleEvmTransaction, handleSolanaTransaction, handleSuiTransaction, and several UI components like BaseConfirmation, BaseCodeInput)

A new src/logger.ts file is added with the reactUiLogger instance and an initReactUiLogger(apiKey) initializer following the same pattern used in other packages (auth, window, wallets).

⚠️ Key review point

initReactUiLogger() is exported but not called anywhere in this diff. Until it is called, the reactUiLogger singleton will fall back to raw console.* (the SdkLogger uninitialized behavior). This means the utility functions and non-context components using reactUiLogger won't actually be silenced by consoleLogLevel="silent" until initialization is wired up — likely in CrossmintProvider. The components using useLogger(LoggerContext) should work correctly since they receive an already-initialized logger from React context.

Companion PRs for other packages:

Test plan

  • Lint passes (pnpm lint)
  • No unit test changes; existing tests are unaffected
  • Manual verification recommended: set consoleLogLevel="silent" in CrossmintProvider and confirm logs from react-ui components are suppressed after login

Package updates

  • @crossmint/client-sdk-react-ui: patch (changeset added)

Link to Devin run
Requested by: Guille (@xmint-guille)

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 20, 2026

🦋 Changeset detected

Latest commit: e5ecdbc

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

This PR includes changesets to release 4 packages
Name Type
@crossmint/client-sdk-react-ui 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

15 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile


export const reactUiLogger = new SdkLogger();

export function initReactUiLogger(apiKey: string): void {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@github-actions
Copy link
Copy Markdown
Contributor

🔥 Smoke Test Results

Status: Passed

Statistics

  • Total Tests: 5
  • Passed: 5 ✅
  • Failed: 0
  • Skipped: 0
  • Duration: 5.11 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