Skip to content

[EXTERNAL] fix: prefix browser-mode detection logs with [RevenueCat] (#1953) via @cpruijsen - #1954

Merged
rickvdl merged 2 commits into
mainfrom
rickvdl/fix-issue-1709
Sep 11, 2026
Merged

[EXTERNAL] fix: prefix browser-mode detection logs with [RevenueCat] (#1953) via @cpruijsen#1954
rickvdl merged 2 commits into
mainfrom
rickvdl/fix-issue-1709

Conversation

@rickvdl

@rickvdl rickvdl commented Sep 11, 2026

Copy link
Copy Markdown
Member

Thank you for contributing to react-native-purchases. Before pressing the "Create Pull Request" button, please provide the following:

  • A description about what and why you are contributing, even if it's trivial.

  • The issue number(s) or PR number(s) in the description if you are contributing in response to those.

    • If applicable, unit tests.

Prefixes the three existing console.log calls in shouldUseBrowserMode() with [RevenueCat]. Other TypeScript logs from this package's default handler are tagged [RevenueCat], so the unprefixed web / Expo Go / Rork detection line is hard to filter in a busy console. Detection is unchanged: the log still runs at module import, before configure().

Prefix is [RevenueCat], not [purchases]. The issue asked for [purchases] "as other messages." Native iOS NSLog and purchases-js use [Purchases] / [purchases]. [RevenueCat] is already the TypeScript log tag in this package (default log handler, isConfigured(), etc.).

The detection logs are not gated on setLogLevel. The issue asked whether this line should respect log level. Deferring until configure() / setLogLevel(), or dropping the log, would be a larger behavior change: the log runs at module import, before any log level exists.

Can switch the prefix, or defer or silence the log.

Unit tests in __tests__/environment.test.ts assert the prefixed strings for web, Expo Go, and Rork, and that native iOS does not log.

Fixes #1709.


Note

Low Risk
Logging-only change with no impact on browser-mode detection or purchase flows; covered by new unit tests.

Overview
Browser-mode detection messages from shouldUseBrowserMode() now go through a small logBrowserModeDetection() helper that prefixes them with [RevenueCat], matching other TypeScript logs in the package so they are easier to filter in the console. Detection behavior is unchanged—only the log format.

Adds __tests__/environment.test.ts with tests for prefixed web, Expo Go, and Rork messages, and that native iOS does not emit these logs.

Fixes #1709.

Reviewed by Cursor Bugbot for commit f5d8a28. Bugbot is set up for automated code reviews on this repo. Configure here.

Thank you for contributing to react-native-purchases. Before pressing the "Create Pull Request" button, please provide the following:

  • A description about what and why you are contributing, even if it's trivial.

  • The issue number(s) or PR number(s) in the description if you are contributing in response to those.

  • If applicable, unit tests.

…1953)

Thank you for contributing to react-native-purchases. Before pressing
the "Create Pull Request" button, please provide the following:

- [x] A description about what and why you are contributing, even if
it's trivial.

- [x] The issue number(s) or PR number(s) in the description if you are
contributing in response to those.

  - [x] If applicable, unit tests.

Prefixes the three existing `console.log` calls in
`shouldUseBrowserMode()` with `[RevenueCat]`. Other TypeScript logs from
this package's default handler are tagged `[RevenueCat]`, so the
unprefixed web / Expo Go / Rork detection line is hard to filter in a
busy console. Detection is unchanged: the log still runs at module
import, before `configure()`.

Prefix is `[RevenueCat]`, not `[purchases]`. The issue asked for
`[purchases]` "as other messages." Native iOS `NSLog` and purchases-js
use `[Purchases]` / `[purchases]`. `[RevenueCat]` is already the
TypeScript log tag in this package (default log handler,
`isConfigured()`, etc.).

The detection logs are not gated on `setLogLevel`. The issue asked
whether this line should respect log level. Deferring until
`configure()` / `setLogLevel()`, or dropping the log, would be a larger
behavior change: the log runs at module import, before any log level
exists.

Can switch the prefix, or defer or silence the log.

Unit tests in `__tests__/environment.test.ts` assert the prefixed
strings for web, Expo Go, and Rork, and that native iOS does not log.

Fixes #1709.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Cosmetic log-prefix change only; no change to environment detection or
purchase flow.
> 
> **Overview**
> Prefixes the three **browser-mode detection** `console.log` lines in
`shouldUseBrowserMode()` with **`[RevenueCat]`**, matching the rest of
this package’s TypeScript logging so those messages are easier to filter
in the console.
> 
> **Detection behavior is unchanged** (web, Expo Go, Rork, native); only
log text changes. Adds **`__tests__/environment.test.ts`** to assert the
prefixed messages and that native iOS does not log.
> 
> Fixes #1709.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
3f96227. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@rickvdl rickvdl added the pr:other A code change that improves performance label Sep 11, 2026
@rickvdl
rickvdl requested a review from a team as a code owner September 11, 2026 06:23
@rickvdl
rickvdl requested a review from a team September 11, 2026 06:24
Comment thread src/utils/environment.ts Outdated
return true;
} else if (isWebPlatform()) {
console.log('Web platform detected. Using RevenueCat in Browser Mode.');
console.log('[RevenueCat] Web platform detected. Using RevenueCat in Browser Mode.');

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.

I guess we could potentially build the message with the prefix in one place instead of adding the prefix in 3 places... But TBH, I think its fine as is :)

@rickvdl
rickvdl enabled auto-merge (squash) September 11, 2026 07:18
@rickvdl
rickvdl merged commit 45a6e92 into main Sep 11, 2026
13 checks passed
@rickvdl
rickvdl deleted the rickvdl/fix-issue-1709 branch September 11, 2026 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:other A code change that improves performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[react-native-purchases] Message in web console "Web platform detected. Using RevenueCat in Browser Mode." doesnt have prefix [purchases]

4 participants