Skip to content

Commit 628e5f7

Browse files
qfranksiddarthkay
andauthored
feat_: allow user to change default app log level during pre-login (#22425)
* feat_: support pre-login log setting(WIP) * nix: add gradle deps * chore: update status-go version status-im/status-go@614000a...50a1c9f * feat: implement MMKV storage functionality for ClojureScript - Added MMKV instance for persistent storage - Implemented basic operations: set/get string, boolean, number, and object - Included methods for key management: contains-key?, delete-key, clear-all, and get-all-keys - Integrated Transit for serialization/deserialization of ClojureScript data structures * feat_: enhance logging functionality with pre-login log level settings - Introduced a new view for managing pre-login log levels. - Updated logging configuration to utilize MMKV for persistent storage of log levels. - Refactored existing logging functions to integrate new log level management. - Improved user experience by allowing log level changes before login. - Added constants for pre-login log level key and report email. * chore_: rebase * ios: pin libwebp at 1.0.0 * chore_: mock mmkv * chore_: address review feedback from Parvesh * chore_: update status-go version and commit details * fix_: remove redundant closing brackets in logging view component * refactor_: simplify get functions in MMKV by using if-let for value retrieval - Updated get-string, get-number, and get-object functions to use if-let for cleaner code. - Removed redundant nil checks, improving readability and maintainability. * refactor_: replace direct JS calls with oops.core for MMKV operations - Updated all MMKV operations to use oops.core for method calls, enhancing error handling and improving code consistency. - Refactored store, get, contains-key?, delete-key, clear-all, and get-all-keys functions to utilize oops/ocall. * refactor_: rename store function to set-value for clarity - Updated the MMKV store function to set-value, improving code readability. - Adjusted the logging core to use the new set-value function for setting pre-login log levels. * feat_: add getMMKVStoragePath method for native storage path retrieval - Implemented getMMKVStoragePath in both Android and iOS native modules to provide a consistent path for MMKV storage. - Updated ClojureScript to utilize the new method for initializing the MMKV instance with the correct storage path. * chore(mmkv)_: rename set-value to set * refactor(mmkv): update set function to use local set implementation - Replaced the oops/ocall for the set function with a direct call to the local set implementation for improved clarity and consistency in the MMKV module. * feat(test_utils): add getMMKVStoragePath function to test utilities - Introduced getMMKVStoragePath to return the storage path for MMKV, enhancing test utility functions for better integration with native storage paths. * refactor(js_dependencies): rename mmkv-storage to react-native-mmkv for clarity * fix(mmkv): add fallback for MMKV storage path in case of errors - Implemented a try-catch block to provide a fallback storage path ("/tmp/test-mmkv") for the MMKV instance, ensuring stability during tests when the native storage path retrieval fails. * refactor(logging): update send-logs function to include hide-bottom-sheet parameter * fix_: bottom sheet not hidden after sharing logs * chore_: solve circular dependency * fix_: android logs drawer constantly opens * fix_: pre-login log level init with incorrect value after logout * chore_: update status-go-version to v10.22.0 --------- Co-authored-by: Siddarth Kumar <siddarthkay@gmail.com>
1 parent 4721ce5 commit 628e5f7

File tree

34 files changed

+1510
-294
lines changed

34 files changed

+1510
-294
lines changed

ios/Podfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ abstract_target 'Status' do
5757
pod 'react-native-config', :path => '../node_modules/react-native-config'
5858

5959
pod 'SSZipArchive', '2.4.3'
60+
# to fix [!] [!] CocoaPods could not find compatible versions for pod "libwebp"
61+
pod 'libwebp', '1.0.0'
6062
# to fix [!] CocoaPods could not find compatible versions for pod "CryptoSwift"
6163
pod 'CryptoSwift', git: "https://github.com/krzyzanowskim/CryptoSwift", tag: '1.8.0'
6264
pod "react-native-status-keycard", path: "../node_modules/react-native-status-keycard"

ios/Podfile.lock

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,33 @@ PODS:
2323
- secp256k1
2424
- SSZipArchive
2525
- libevent (2.1.12)
26-
- libwebp (1.3.2):
27-
- libwebp/demux (= 1.3.2)
28-
- libwebp/mux (= 1.3.2)
29-
- libwebp/sharpyuv (= 1.3.2)
30-
- libwebp/webp (= 1.3.2)
31-
- libwebp/demux (1.3.2):
26+
- libwebp (1.0.0):
27+
- libwebp/core (= 1.0.0)
28+
- libwebp/dec (= 1.0.0)
29+
- libwebp/demux (= 1.0.0)
30+
- libwebp/dsp (= 1.0.0)
31+
- libwebp/enc (= 1.0.0)
32+
- libwebp/mux (= 1.0.0)
33+
- libwebp/utils (= 1.0.0)
34+
- libwebp/webp (= 1.0.0)
35+
- libwebp/core (1.0.0):
3236
- libwebp/webp
33-
- libwebp/mux (1.3.2):
34-
- libwebp/demux
35-
- libwebp/sharpyuv (1.3.2)
36-
- libwebp/webp (1.3.2):
37-
- libwebp/sharpyuv
37+
- libwebp/dec (1.0.0):
38+
- libwebp/core
39+
- libwebp/demux (1.0.0):
40+
- libwebp/core
41+
- libwebp/dsp (1.0.0):
42+
- libwebp/core
43+
- libwebp/enc (1.0.0):
44+
- libwebp/core
45+
- libwebp/mux (1.0.0):
46+
- libwebp/core
47+
- libwebp/utils (1.0.0):
48+
- libwebp/core
49+
- libwebp/webp (1.0.0)
50+
- MMKV (2.1.0):
51+
- MMKVCore (~> 2.1.0)
52+
- MMKVCore (2.1.1)
3853
- RCT-Folly (2022.05.16.00):
3954
- boost
4055
- DoubleConversion
@@ -936,6 +951,11 @@ PODS:
936951
- React
937952
- react-native-lottie-splash-screen (1.1.2):
938953
- React
954+
- react-native-mmkv (2.12.2):
955+
- glog
956+
- MMKV (>= 1.3.3)
957+
- RCT-Folly (= 2022.05.16.00)
958+
- React-Core
939959
- react-native-netinfo (4.7.0):
940960
- React
941961
- react-native-orientation-locker (1.5.0):
@@ -1205,6 +1225,7 @@ DEPENDENCIES:
12051225
- hermes-engine (from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`)
12061226
- Keycard (from `https://github.com/status-im/Keycard.swift.git`, tag `3.1.1`)
12071227
- libevent (~> 2.1.12)
1228+
- libwebp (= 1.0.0)
12081229
- RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`)
12091230
- RCT-Folly/Fabric (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`)
12101231
- RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`)
@@ -1239,6 +1260,7 @@ DEPENDENCIES:
12391260
- react-native-hole-view (from `../node_modules/react-native-hole-view`)
12401261
- react-native-image-resizer (from `../node_modules/react-native-image-resizer`)
12411262
- react-native-lottie-splash-screen (from `../node_modules/react-native-lottie-splash-screen`)
1263+
- react-native-mmkv (from `../node_modules/react-native-mmkv`)
12421264
- "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)"
12431265
- react-native-orientation-locker (from `../node_modules/react-native-orientation-locker`)
12441266
- react-native-pdf (from `../node_modules/react-native-pdf`)
@@ -1296,6 +1318,8 @@ SPEC REPOS:
12961318
- HMSegmentedControl
12971319
- libevent
12981320
- libwebp
1321+
- MMKV
1322+
- MMKVCore
12991323
- SDWebImage
13001324
- SDWebImageWebPCoder
13011325
- SocketRocket
@@ -1386,6 +1410,8 @@ EXTERNAL SOURCES:
13861410
:path: "../node_modules/react-native-image-resizer"
13871411
react-native-lottie-splash-screen:
13881412
:path: "../node_modules/react-native-lottie-splash-screen"
1413+
react-native-mmkv:
1414+
:path: "../node_modules/react-native-mmkv"
13891415
react-native-netinfo:
13901416
:path: "../node_modules/@react-native-community/netinfo"
13911417
react-native-orientation-locker:
@@ -1509,7 +1535,9 @@ SPEC CHECKSUMS:
15091535
HMSegmentedControl: 34c1f54d822d8308e7b24f5d901ec674dfa31352
15101536
Keycard: 3bd24405b9a875b3b3cf1ab1be69b5c30c5f28bc
15111537
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
1512-
libwebp: 1786c9f4ff8a279e4dac1e8f385004d5fc253009
1538+
libwebp: d7e0c95fe97245c97e08101eba10702ebb0f6101
1539+
MMKV: ce484c1ac40bf76d5f09a0195d2ec5b3d3840d55
1540+
MMKVCore: 1eb661c6c498ab88e3df9ce5d8ff94d05fcc0567
15131541
RCT-Folly: 7169b2b1c44399c76a47b5deaaba715eeeb476c0
15141542
RCTRequired: 2544c0f1081a5fa12e108bb8cb40e5f4581ccd87
15151543
RCTTypeSafety: 50efabe2b115c11ed03fbf3fd79e2f163ddb5d7c
@@ -1542,6 +1570,7 @@ SPEC CHECKSUMS:
15421570
react-native-hole-view: 6935448993bac79f2b5a4ad7e9741094cf810679
15431571
react-native-image-resizer: 2f1577efa3bc762597681f530c8e8d05ce0ceeb3
15441572
react-native-lottie-splash-screen: 4e1b1fd9d6633f9cd2106d6877eb5ba0147f3e2b
1573+
react-native-mmkv: 1fdc81aa70c1aba09370718e6a63a09cbbbac8d2
15451574
react-native-netinfo: ddaca8bbb9e6e914b1a23787ccb879bc642931c9
15461575
react-native-orientation-locker: 851f6510d8046ea2f14aa169b1e01fcd309a94ba
15471576
react-native-pdf: 103940c90d62adfd259f63cca99c7c0c306b514c
@@ -1596,6 +1625,6 @@ SPEC CHECKSUMS:
15961625
TOCropViewController: 80b8985ad794298fb69d3341de183f33d1853654
15971626
Yoga: a716eea57d0d3430219c0a5a233e1e93ee931eb7
15981627

1599-
PODFILE CHECKSUM: 56d9f695324306d6db368d1172d211dfab55b7cb
1628+
PODFILE CHECKSUM: 1a15018a9c864c8f0a1cdec9a6e195e1ab0b1d0d
16001629

16011630
COCOAPODS: 1.15.2

modules/react-native-status/android/src/main/java/im/status/ethereum/module/LogManager.kt

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,24 +198,46 @@ class LogManager(private val reactContext: ReactApplicationContext) : ReactConte
198198
}
199199

200200
@ReactMethod(isBlockingSynchronousMethod = true)
201-
fun setLogLevel(setLogLevelRequest: String): String {
202-
Log.d(TAG, "setLogLevel: $setLogLevelRequest")
201+
fun setProfileLogLevel(setProfileLogLevelRequest: String): String {
202+
Log.d(TAG, "setProfileLogLevel: $setProfileLogLevelRequest")
203203

204204
return StatusBackendClient.executeStatusGoRequestWithResult(
205-
endpoint = "SetLogLevel",
206-
requestBody = setLogLevelRequest,
207-
statusgoFunction = { Statusgo.setLogLevel(setLogLevelRequest) }
205+
endpoint = "SetProfileLogLevel",
206+
requestBody = setProfileLogLevelRequest,
207+
statusgoFunction = { Statusgo.setProfileLogLevel(setProfileLogLevelRequest) }
208208
)
209209
}
210210

211211
@ReactMethod(isBlockingSynchronousMethod = true)
212-
fun setLogEnabled(setLogEnabledRequest: String): String {
213-
Log.d(TAG, "setLogEnabled: $setLogEnabledRequest")
212+
fun setProfileLogEnabled(setProfileLogEnabledRequest: String): String {
213+
Log.d(TAG, "setProfileLogEnabled: $setProfileLogEnabledRequest")
214214

215215
return StatusBackendClient.executeStatusGoRequestWithResult(
216216
endpoint = "SetLogEnabled",
217-
requestBody = setLogEnabledRequest,
218-
statusgoFunction = { Statusgo.setLogEnabled(setLogEnabledRequest) }
217+
requestBody = setProfileLogEnabledRequest,
218+
statusgoFunction = { Statusgo.setProfileLogEnabled(setProfileLogEnabledRequest) }
219+
)
220+
}
221+
222+
@ReactMethod
223+
fun setPreLoginLogLevel(setPreLoginLogLevelRequest: String) {
224+
Log.d(TAG, "setPreLoginLogLevel: $setPreLoginLogLevelRequest")
225+
226+
StatusBackendClient.executeStatusGoRequest(
227+
endpoint = "SetPreLoginLogLevel",
228+
requestBody = setPreLoginLogLevelRequest,
229+
statusgoFunction = { Statusgo.setPreLoginLogLevel(setPreLoginLogLevelRequest) }
230+
)
231+
}
232+
233+
@ReactMethod
234+
fun setPreLoginLogEnabled(setPreLoginLogEnabledRequest: String) {
235+
Log.d(TAG, "setPreLoginLogEnabled: $setPreLoginLogEnabledRequest")
236+
237+
StatusBackendClient.executeStatusGoRequest(
238+
endpoint = "SetPreLoginLogEnabled",
239+
requestBody = setPreLoginLogEnabledRequest,
240+
statusgoFunction = { Statusgo.setPreLoginLogEnabled(setPreLoginLogEnabledRequest) }
219241
)
220242
}
221243

modules/react-native-status/android/src/main/java/im/status/ethereum/module/Utils.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ class Utils(private val reactContext: ReactApplicationContext) : ReactContextBas
3939
return getNoBackupDirectory()
4040
}
4141

42+
@ReactMethod(isBlockingSynchronousMethod = true)
43+
fun getMMKVStoragePath(): String {
44+
return pathCombine(reactContext.noBackupFilesDir.absolutePath, "/mmkv")
45+
}
46+
4247
fun getLogDirectory(usePublicLogDir: Boolean): File? {
4348
return if (usePublicLogDir) {
4449
StatusBackendClient.getInstance()?.let { client ->

modules/react-native-status/ios/RCTStatus/LogManager.m

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,35 @@ - (void)copyExistingLogsToFolder:(NSURL *)logsFolderPath withFileManager:(NSFile
8989
return logsUrl.path;
9090
}
9191

92-
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(setLogLevel:(NSString *)setLogLevelRequest) {
93-
return [StatusBackendClient executeStatusGoRequestWithResult:@"SetLogLevel"
94-
body:setLogLevelRequest
92+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(setProfileLogLevel:(NSString *)setProfileLogLevelRequest) {
93+
return [StatusBackendClient executeStatusGoRequestWithResult:@"SetProfileLogLevel"
94+
body:setProfileLogLevelRequest
9595
statusgoFunction:^NSString *{
96-
return StatusgoSetLogLevel(setLogLevelRequest);
96+
return StatusgoSetProfileLogLevel(setProfileLogLevelRequest);
9797
}];
9898
}
9999

100-
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(setLogEnabled:(NSString *)setLogEnabledRequest) {
101-
return [StatusBackendClient executeStatusGoRequestWithResult:@"SetLogEnabled"
102-
body:setLogEnabledRequest
100+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(setProfileLogEnabled:(NSString *)setProfileLogEnabledRequest) {
101+
return [StatusBackendClient executeStatusGoRequestWithResult:@"SetProfileLogEnabled"
102+
body:setProfileLogEnabledRequest
103103
statusgoFunction:^NSString *{
104-
return StatusgoSetLogEnabled(setLogEnabledRequest);
104+
return StatusgoSetProfileLogEnabled(setProfileLogEnabledRequest);
105+
}];
106+
}
107+
108+
RCT_EXPORT_METHOD(setPreLoginLogLevel:(NSString *)setPreLoginLogLevelRequest) {
109+
[StatusBackendClient executeStatusGoRequest:@"SetPreLoginLogLevel"
110+
body:setPreLoginLogLevelRequest
111+
statusgoFunction:^NSString *{
112+
return StatusgoSetPreLoginLogLevel(setPreLoginLogLevelRequest);
113+
}];
114+
}
115+
116+
RCT_EXPORT_METHOD(setPreLoginLogEnabled:(NSString *)setPreLoginLogEnabledRequest) {
117+
[StatusBackendClient executeStatusGoRequest:@"SetPreLoginLogEnabled"
118+
body:setPreLoginLogEnabledRequest
119+
statusgoFunction:^NSString *{
120+
return StatusgoSetPreLoginLogEnabled(setPreLoginLogEnabledRequest);
105121
}];
106122
}
107123

modules/react-native-status/ios/RCTStatus/Utils.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ + (void) migrateKeystore:(NSString *)accountData
140140
return rootUrl.path;
141141
}
142142

143+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(getMMKVStoragePath) {
144+
NSFileManager *fileManager = [NSFileManager defaultManager];
145+
NSURL *rootUrl = [[fileManager URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] lastObject];
146+
return [rootUrl.path stringByAppendingPathComponent:@"mmkv"];
147+
}
148+
143149
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(keystoreDir) {
144150
NSFileManager *fileManager = [NSFileManager defaultManager];
145151
NSURL *rootUrl =[Utils getRootUrl];

0 commit comments

Comments
 (0)