fix: replace direct console.* calls with rnWindowLogger in rn-window package#1597
fix: replace direct console.* calls with rnWindowLogger in rn-window package#1597devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Conversation
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:
|
🦋 Changeset detectedLatest commit: e0a0bca The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 |
| const platform = detectPlatform(); | ||
| if (platform === "browser") { | ||
| const sink = new BrowserDatadogSink(environment); | ||
| rnWindowLogger.addSink(sink); | ||
| } else if (platform === "server") { | ||
| const sink = new ServerDatadogSink(environment); | ||
| rnWindowLogger.addSink(sink); | ||
| } |
There was a problem hiding this comment.
missing react-native platform case. detectPlatform() returns "react-native" for RN environments, but only "browser" and "server" cases are handled here. See packages/wallets/src/logger/init.ts:46-50 for the correct pattern with a react-native case in the switch statement.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/client/rn-window/src/logger.ts
Line: 23-30
Comment:
missing `react-native` platform case. `detectPlatform()` returns `"react-native"` for RN environments, but only `"browser"` and `"server"` cases are handled here. See `packages/wallets/src/logger/init.ts:46-50` for the correct pattern with a `react-native` case in the switch statement.
How can I resolve this? If you propose a fix, please make it concise.
Description
Part of the effort to make
consoleLogLevel="silent"work across all SDK packages. Replaces 12 directconsole.*calls in@crossmint/client-sdk-rn-windowwith anrnWindowLoggerinstance (SdkLogger) so they can respect theconsoleLogLevelsetting.Files changed:
RNWebViewTransport.ts— 8 replacements (info, error, warn calls for message handling, send, reload)Parent.ts— 4 replacements (error, info calls for handshake, recovery)logger.tswithrnWindowLoggersingleton andinitRnWindowLogger(apiKey)initializerIntentionally unchanged:
RNWebViewTransport.tsline 54:console.errorinside an injected JavaScript string — this runs inside the WebView context where the SDK logger is not availableRNWebView.tsx: Console monkey-patches for WebView debugging — these are intentional overrides, not regular log callsinitRnWindowLogger()is exported but not called anywhere in this diff. Until initialization is wired up (likely in a provider), the logger falls back to rawconsole.*(SdkLogger uninitialized behavior). This means logs won't actually be silenced yet — same pattern as companion PRs.@crossmint/common-sdk-baseadded torn-windowfor SdkLogger access. Confirm this is acceptable for a React Native package.detectPlatform()in RN context — the logger init uses browser/server sink selection which may not be the right fit for React Native. Worth verifyingdetectPlatform()returns something sensible here.Companion PRs: #1592 (wallets), #1593 (auth), #1594 (window), #1595 (react-base), #1596 (react-ui)
Test plan
pnpm lint)consoleLogLevel="silent"suppresses logs once init is wired upPackage updates
@crossmint/client-sdk-rn-window: patch (changeset added)Link to Devin run
Requested by: Guille (@xmint-guille)