Skip to content

Commit dd97124

Browse files
chore: fix native android feature flags
1 parent 4802864 commit dd97124

File tree

7 files changed

+51
-12
lines changed

7 files changed

+51
-12
lines changed

android/native.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project.ext.instabug = [
2-
version: '13.4.1'
2+
version: '13.4.1.6273165-SNAPSHOT'
33
]
44

55
dependencies {

android/src/main/java/com/instabug/reactlibrary/RNInstabugNetworkLoggerModule.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package com.instabug.reactlibrary;
22

33

4+
import static com.instabug.apm.configuration.cp.APMFeature.APM_NETWORK_PLUGIN_INSTALLED;
5+
import static com.instabug.apm.configuration.cp.APMFeature.CP_NATIVE_INTERCEPTION_ENABLED;
6+
import static com.instabug.apm.configuration.cp.APMFeature.NETWORK_INTERCEPTION_ENABLED;
7+
48
import androidx.annotation.NonNull;
59

610
//import com.facebook.react.bridge.Arguments;
@@ -12,6 +16,7 @@
1216
//import com.instabug.apm.sanitization.OnCompleteCallback;
1317
//import com.instabug.apm.sanitization.VoidSanitizer;
1418
//import com.instabug.library.logging.listeners.networklogs.NetworkLogSnapshot;
19+
import com.instabug.apm.InternalAPM;
1520
import com.instabug.reactlibrary.utils.EventEmitterModule;
1621
import com.instabug.reactlibrary.utils.MainThreadHandler;
1722
//
@@ -46,6 +51,10 @@ public void removeListeners(Integer count) {
4651
super.removeListeners(count);
4752
}
4853

54+
private boolean getFlagValue(String key) {
55+
return InternalAPM._isFeatureEnabledCP( key , "");
56+
}
57+
4958
/**
5059
* Get first time Value of [cp_native_interception_enabled] flag
5160
*/
@@ -55,7 +64,7 @@ public void isNativeInterceptionEnabled(Promise promise) {
5564
@Override
5665
public void run() {
5766
try {
58-
promise.resolve(true);
67+
promise.resolve(getFlagValue(CP_NATIVE_INTERCEPTION_ENABLED));
5968
} catch (Exception e) {
6069
e.printStackTrace();
6170
promise.resolve(false);
@@ -76,7 +85,7 @@ public void hasAPMNetworkPlugin(Promise promise) {
7685
@Override
7786
public void run() {
7887
try {
79-
promise.resolve(true);
88+
promise.resolve(getFlagValue(APM_NETWORK_PLUGIN_INSTALLED));
8089
} catch (Exception e) {
8190
e.printStackTrace();
8291
promise.resolve(false);
@@ -97,7 +106,7 @@ public void isAPMNetworkEnabled(Promise promise) {
97106
@Override
98107
public void run() {
99108
try {
100-
promise.resolve(true);
109+
promise.resolve(getFlagValue(NETWORK_INTERCEPTION_ENABLED));
101110
} catch (Exception e) {
102111
e.printStackTrace();
103112
promise.resolve(false);
@@ -108,7 +117,6 @@ public void run() {
108117
}
109118

110119

111-
112120
// @ReactMethod
113121
// public void registerNetworkLogsListener() {
114122
// MainThreadHandler.runOnMainThread(new Runnable() {

examples/default/android/app/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
apply plugin: "com.android.application"
22
apply plugin: "com.facebook.react"
33
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
4+
apply plugin: 'instabug-apm'
45

56
import com.android.build.OutputFile
67

@@ -95,6 +96,12 @@ def reactNativeArchitectures() {
9596
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
9697
}
9798

99+
instabug {
100+
apm {
101+
// networkEnabled = true
102+
// debugEnabled = true
103+
}
104+
}
98105
android {
99106
ndkVersion rootProject.ext.ndkVersion
100107

examples/default/android/app/src/main/res/xml/network_security_config.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@
1212
<certificates src="user" />
1313
</trust-anchors>
1414
</base-config>
15+
16+
<debug-overrides>
17+
<trust-anchors>
18+
<!-- Trust user added CAs while debuggable only -->
19+
<certificates src="user" />
20+
<certificates src="system" />
21+
</trust-anchors>
22+
</debug-overrides>
1523
</network-security-config>

examples/default/android/build.gradle

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,19 @@ buildscript {
1414
repositories {
1515
google()
1616
mavenCentral()
17+
maven {
18+
url "https://mvn.instabug.com/nexus/repository/instabug-internal/"
19+
credentials {
20+
username "instabug"
21+
password System.getenv("INSTABUG_REPOSITORY_PASSWORD")
22+
}
23+
}
1724
}
1825
dependencies {
1926
classpath("com.android.tools.build:gradle")
2027
classpath("com.facebook.react:react-native-gradle-plugin")
2128
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
29+
classpath 'com.instabug.library:instabug-plugin:13.4.1.6273165-SNAPSHOT'
2230
}
2331
}
2432

@@ -28,6 +36,13 @@ allprojects {
2836
url("$rootDir/../node_modules/detox/Detox-android")
2937
}
3038

39+
maven {
40+
url "https://mvn.instabug.com/nexus/repository/instabug-internal/"
41+
credentials {
42+
username "instabug"
43+
password System.getenv("INSTABUG_REPOSITORY_PASSWORD")
44+
}
45+
}
3146
maven {
3247
credentials {
3348
username System.getenv("DREAM11_MAVEN_USERNAME")

examples/default/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ PODS:
475475
- RNGestureHandler (2.13.4):
476476
- RCT-Folly (= 2021.07.22.00)
477477
- React-Core
478-
- RNInstabug (13.3.0):
478+
- RNInstabug (13.4.0):
479479
- Instabug (= 13.4.2)
480480
- React-Core
481481
- RNReanimated (3.5.4):
@@ -750,7 +750,7 @@ SPEC CHECKSUMS:
750750
ReactCommon: 3ccb8fb14e6b3277e38c73b0ff5e4a1b8db017a9
751751
RNCClipboard: 41d8d918092ae8e676f18adada19104fa3e68495
752752
RNGestureHandler: 6e46dde1f87e5f018a54fe5d40cd0e0b942b49ee
753-
RNInstabug: 3bd51c9e01a076ed5b0bc0a10590e34272dff2fb
753+
RNInstabug: 8e7eb1df3f35b935dda661f5bb475f37cef595e6
754754
RNReanimated: ab2e96c6d5591c3dfbb38a464f54c8d17fb34a87
755755
RNScreens: b21dc57dfa2b710c30ec600786a3fc223b1b92e7
756756
RNSVG: 80584470ff1ffc7994923ea135a3e5ad825546b9

src/modules/Instabug.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ let _lastScreen: string | null = null;
4343
let _isFirstScreen = false;
4444
const firstScreen = 'Initial Screen';
4545
let _currentAppState = AppState.currentState;
46-
let isNativeInterceptionFeatureEnabled = false;
47-
let hasAPMNetworkPlugin = false;
48-
let isAPMNetworkEnabled = false;
49-
let shouldEnableNativeInterception = false; // used to disable APM logging inside reportNetworkLog() -> NativeAPM.networkLogAndroid()
46+
let isNativeInterceptionFeatureEnabled = false; // Checks the value of "cp_native_interception_enabled" backend flag.
47+
let hasAPMNetworkPlugin = false; // Android only: checks if the APM plugin is installed.
48+
let isAPMNetworkEnabled = false; // Android only: checks if (APM enabled && Network enabled).
49+
let shouldEnableNativeInterception = false; // Android: used to disable APM logging inside reportNetworkLog() -> NativeAPM.networkLogAndroid(), iOS: used to control native interception (true == enabled , false == disabled)
5050

5151
/**
5252
* Enables or disables Instabug functionality.
@@ -188,7 +188,7 @@ const handleNetworkInterceptionMode = (config: InstabugConfig) => {
188188

189189
if (Platform.OS === 'android') {
190190
checkNativeInterceptionForAndroid(config);
191-
config.networkInterceptionMode = NetworkInterceptionMode.javascript; // Need to enable JS interceptor in all scenarios for core network logs
191+
config.networkInterceptionMode = NetworkInterceptionMode.javascript; // Need to enable JS interceptor in all scenarios for Bugs & Crashes network logs
192192
} else if (Platform.OS === 'ios') {
193193
checkNativeInterceptionForIOS(config);
194194
}
@@ -224,6 +224,7 @@ const checkNativeInterceptionForAndroid = (config: InstabugConfig) => {
224224
if (hasAPMNetworkPlugin) {
225225
console.error(InstabugConstants.IBG_APM_TAG + 'Native interception is disabled');
226226
} else {
227+
shouldEnableNativeInterception = false; // rollback to use JS interceptor for APM & Core.
227228
console.error(
228229
InstabugConstants.IBG_APM_TAG +
229230
'Native interception is disabled and plugin is not installed',

0 commit comments

Comments
 (0)