Skip to content

Commit acce870

Browse files
committed
feat: add network body max size APIs in Android
- Added `onNetworkLogBodyMaxSizeChange` method to `FeatureFlagsFlutterApi` in Dart. - Implemented `getNetworkBodyMaxSize` method in `InstabugApi` to retrieve network log character limit. - Updated `InstabugApiTest` with a new test for `getNetworkBodyMaxSize`.
1 parent 5d82000 commit acce870

File tree

4 files changed

+47
-1
lines changed

4 files changed

+47
-1
lines changed

android/build.gradle

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ rootProject.allprojects {
1616
repositories {
1717
google()
1818
mavenCentral()
19+
20+
maven {
21+
url "https://mvn.instabug.com/nexus/repository/instabug-internal/"
22+
credentials {
23+
username "instabug"
24+
password System.getenv("INSTABUG_REPOSITORY_PASSWORD")
25+
}
26+
}
1927
}
2028
}
2129

@@ -44,7 +52,7 @@ android {
4452
}
4553

4654
dependencies {
47-
api 'com.instabug.library:instabug:14.3.0'
55+
api 'com.instabug.library:instabug:14.3.0.6760192-SNAPSHOT'
4856
testImplementation 'junit:junit:4.13.2'
4957
testImplementation "org.mockito:mockito-inline:3.12.1"
5058
testImplementation "io.mockk:mockk:1.13.13"

android/src/main/java/com/instabug/flutter/modules/InstabugApi.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,11 @@ public void reply(Void reply) {
472472

473473
}
474474
});
475+
476+
featureFlagsFlutterApi.onNetworkLogBodyMaxSizeChange(
477+
(long) featuresState.getNetworkLogCharLimit(),
478+
reply -> {}
479+
);
475480
}
476481
});
477482
}
@@ -509,4 +514,21 @@ public void setNetworkLogBodyEnabled(@NonNull Boolean isEnabled) {
509514
e.printStackTrace();
510515
}
511516
}
517+
518+
@Override
519+
public void getNetworkBodyMaxSize(@NonNull InstabugPigeon.Result<Long> result) {
520+
ThreadManager.runOnMainThread(
521+
new Runnable() {
522+
@Override
523+
public void run() {
524+
try {
525+
long networkCharLimit = InternalCore.INSTANCE.get_networkLogCharLimit();
526+
result.success(networkCharLimit);
527+
} catch (Exception e) {
528+
e.printStackTrace();
529+
}
530+
}
531+
}
532+
);
533+
}
512534
}

android/src/test/java/com/instabug/flutter/InstabugApiTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,4 +658,15 @@ public void testSetNetworkLogBodyDisabled() {
658658

659659
mInstabug.verify(() -> Instabug.setNetworkLogBodyEnabled(false));
660660
}
661+
662+
@Test
663+
public void testGetNetworkBodyMaxSize() {
664+
int expected = 10240;
665+
InstabugPigeon.Result<Long> result = makeResult((actual) -> assertEquals((Long) (long) expected, actual));
666+
667+
mockkObject(new InternalCore[]{InternalCore.INSTANCE}, false);
668+
every(mockKMatcherScope -> InternalCore.INSTANCE.get_networkLogCharLimit()).returns(expected);
669+
670+
api.getNetworkBodyMaxSize(result);
671+
}
661672
}

pigeons/instabug.api.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ abstract class FeatureFlagsFlutterApi {
77
bool isW3cExternalGeneratedHeaderEnabled,
88
bool isW3cCaughtHeaderEnabled,
99
);
10+
11+
void onNetworkLogBodyMaxSizeChange(int networkBodyMaxSize);
1012
}
1113

1214
@HostApi()
@@ -76,4 +78,7 @@ abstract class InstabugHostApi {
7678
void willRedirectToStore();
7779

7880
void setNetworkLogBodyEnabled(bool isEnabled);
81+
82+
@async
83+
int? getNetworkBodyMaxSize();
7984
}

0 commit comments

Comments
 (0)