-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize diagnostics file management (#1194)
### Description This PR is the first part of a possible approach to avoid loading huge files in memory in diagnostics at once. Basically, in here we change to reading the file per lines instead of reading everything in one go. #### Behavior changes - Diagnostics will be Android 24+ only. - An important change in behavior is that, instead of using the number of events in the diagnostics file to set a limit, we use the file size. So if on SDK configuration we detect that it's reached X size, we would clear the whole file and start over. - When we reach the file size limit, we remove the whole file, instead of just the oldest events. - We remove the properties from the `MAX_EVENTS_STORED_LIMIT_REACHED` event since they don't make sense with the new approach. (This will require backend changes) - Now we will have a limit to the max number of diagnostics events in memory and per request.
- Loading branch information
Showing
16 changed files
with
340 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
purchases/src/main/kotlin/com/revenuecat/purchases/utils/AndroidVersionUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.revenuecat.purchases.utils | ||
|
||
import android.os.Build | ||
|
||
fun isAndroidNOrNewer() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N |
10 changes: 10 additions & 0 deletions
10
purchases/src/main/kotlin/com/revenuecat/purchases/utils/FileExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.revenuecat.purchases.utils | ||
|
||
import java.io.File | ||
|
||
private const val BYTE_UNIT_CONVERSION: Double = 1024.0 | ||
|
||
val File.sizeInBytes: Long | ||
get() = length() | ||
val File.sizeInKB: Double | ||
get() = sizeInBytes / BYTE_UNIT_CONVERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.