Skip to content

Add Purchases.logLevel and deprecate Purchases.debugLogsEnabled#753

Merged
NachoSoto merged 6 commits into
mainfrom
log-level
Jan 25, 2023
Merged

Add Purchases.logLevel and deprecate Purchases.debugLogsEnabled#753
NachoSoto merged 6 commits into
mainfrom
log-level

Conversation

@NachoSoto

@NachoSoto NachoSoto commented Jan 23, 2023

Copy link
Copy Markdown
Contributor

Fixes CSDK-549.

@NachoSoto NachoSoto added the pr:feat A new feature label Jan 23, 2023
@NachoSoto NachoSoto requested a review from a team January 23, 2023 21:42
@codecov

codecov Bot commented Jan 23, 2023

Copy link
Copy Markdown

Codecov Report

Merging #753 (3d02288) into main (30cc1a1) will increase coverage by 0.04%.
The diff coverage is 86.95%.

@@            Coverage Diff             @@
##             main     #753      +/-   ##
==========================================
+ Coverage   81.50%   81.54%   +0.04%     
==========================================
  Files         120      121       +1     
  Lines        3984     3999      +15     
  Branches      510      512       +2     
==========================================
+ Hits         3247     3261      +14     
- Misses        534      535       +1     
  Partials      203      203              
Impacted Files Coverage Δ
...java/com/revenuecat/purchases/common/logWrapper.kt 91.66% <0.00%> (-2.62%) ⬇️
.../main/kotlin/com/revenuecat/purchases/Purchases.kt 83.80% <50.00%> (+0.04%) ⬆️
...ain/java/com/revenuecat/purchases/common/Config.kt 100.00% <100.00%> (ø)
...n/java/com/revenuecat/purchases/common/logUtils.kt 93.33% <100.00%> (+4.44%) ⬆️
...src/main/java/com/revenuecat/purchases/LogLevel.kt 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

NachoSoto added a commit to RevenueCat/purchases-hybrid-common that referenced this pull request Jan 23, 2023
For [CSDK-609], [CSDK-607], [CSDK-610], [CSDK-608].
Depends on RevenueCat/purchases-android#753.
NachoSoto added a commit to RevenueCat/purchases-hybrid-common that referenced this pull request Jan 24, 2023
For [CSDK-609], [CSDK-607], [CSDK-610], [CSDK-608].
Depends on RevenueCat/purchases-android#753.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Weird, this is called by tests.

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 believe in the tests we are setting the Config.logLevel directly instead of going through Purchases.logLevel right?

In this case, I think it might be nice to change the tests to use these methods to make sure we cover the full flow users would use.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OMG you're right!! Thank you!
I'm gonna make it explicit instead of relying on that static import.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This code coverage thing is useful haha

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Now I know not to assume it was wrong 🫢

NachoSoto added a commit to RevenueCat/purchases-flutter that referenced this pull request Jan 24, 2023
NachoSoto added a commit to RevenueCat/purchases-flutter that referenced this pull request Jan 24, 2023
NachoSoto added a commit to RevenueCat/cordova-plugin-purchases that referenced this pull request Jan 24, 2023

@tonidero tonidero left a comment

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.

Nothing major, but I think hiding those log level methods is worth it. As for changing tests to use the Purchases accessors, it would be nice but can be done separately.

Comment thread public/src/main/java/com/revenuecat/purchases/LogLevel.kt Outdated
Comment thread common/src/main/java/com/revenuecat/purchases/common/Config.kt Outdated

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 believe in the tests we are setting the Config.logLevel directly instead of going through Purchases.logLevel right?

In this case, I think it might be nice to change the tests to use these methods to make sure we cover the full flow users would use.

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.

Hmm this is accessible by devs... should we make this and the method below internal? I don't think it would help devs to have access to these.

@NachoSoto NachoSoto Jan 25, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I had to leave them as public because they're used from 2 different packages.

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.

Ahh right 🤦 ... I really want to try to unify these modules soon.

What comes to mind is moving these 2 to the common module as extensions properties/functions. Maybe to the logUtils.kt file?

val LogLevel.debugLogsEnabled: Boolean
    get() = this <= LogLevel.DEBUG

fun LogLevel.Companion.debugLogsEnabled(enabled: Boolean): LogLevel {
    return if (enabled) {
        LogLevel.DEBUG
    } else {
        LogLevel.INFO
    }
}

Might need fixing some imports but they should be accessible to both the common and purchases modules once they are there and not be accessible to devs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That works thanks 👍🏻

@NachoSoto

Copy link
Copy Markdown
Contributor Author

Great feedback, thanks @tonidero. Updated!

@NachoSoto

Copy link
Copy Markdown
Contributor Author

@tonidero done.

@tonidero tonidero left a comment

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.

Looks great! 🙌

@NachoSoto NachoSoto merged commit 4f4c575 into main Jan 25, 2023
@NachoSoto NachoSoto deleted the log-level branch January 25, 2023 19:33
NachoSoto added a commit that referenced this pull request Jan 25, 2023
**This is an automatic release.**

### New Features
* Add `Purchases.logLevel` and deprecate `Purchases.debugLogsEnabled`
(#753) via NachoSoto (@NachoSoto)
### Bugfixes
* Avoid syncing attributes for users with blank user ids (#755) via Toni
Rico (@tonidero)
### Other Changes
* Fixed Readme.MD (#727) via AristiDevs (@ArisGuimera)
* Add codecov (#750) via Cesar de la Vega (@vegaro)
* Update AGP to 7.4.0 (#747) via Cesar de la Vega (@vegaro)
* Add test coverage using Kover (#748) via Cesar de la Vega (@vegaro)

Co-authored-by: revenuecat-ops <ops@revenuecat.com>
Co-authored-by: Cesar de la Vega <cesarvegaro@gmail.com>
Co-authored-by: NachoSoto <ignaciosoto90@gmail.com>
vegaro pushed a commit to RevenueCat/purchases-flutter that referenced this pull request Jan 26, 2023
NachoSoto added a commit to RevenueCat/purchases-hybrid-common that referenced this pull request Jan 26, 2023
For [CSDK-609], [CSDK-607], [CSDK-610], [CSDK-608].
Depends on RevenueCat/purchases-android#753.
NachoSoto added a commit to RevenueCat/purchases-flutter that referenced this pull request Jan 27, 2023
NachoSoto added a commit to RevenueCat/cordova-plugin-purchases that referenced this pull request Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:feat A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants