Skip to content

Commit de65770

Browse files
chore: pull the android upgrade changes, update the network log messages, amend the example app to wait for the Instabug.init() method
1 parent e66c67a commit de65770

File tree

9 files changed

+65
-45
lines changed

9 files changed

+65
-45
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: '14.0.0.6273213-SNAPSHOT'
2+
version: '14.0.0.6273738-SNAPSHOT'
33
]
44

55
dependencies {

examples/default/android/app/build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: "com.android.application"
22
apply plugin: "org.jetbrains.kotlin.android"
33
apply plugin: "com.facebook.react"
44
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
5-
5+
apply plugin: 'instabug-apm'
66
/**
77
* This is the configuration block to customize your React Native Android app.
88
* By default you don't need to apply any configuration, just uncomment the lines you need.
@@ -124,6 +124,12 @@ android {
124124
}
125125
}
126126

127+
instabug {
128+
apm {
129+
networkEnabled = true
130+
}
131+
}
132+
127133
dependencies {
128134
// The version of react-native is set by the React Native Gradle Plugin
129135
implementation("com.facebook.react:react-android")

examples/default/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ buildscript {
2424
classpath("com.android.tools.build:gradle:8.1.0")
2525
classpath("com.facebook.react:react-native-gradle-plugin")
2626
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
27-
classpath 'com.instabug.library:instabug-plugin:13.4.1.6273165-SNAPSHOT'
27+
classpath("com.instabug.library:instabug-plugin:14.0.0.6273738-SNAPSHOT")
2828
}
2929
}
3030

examples/default/ios/Podfile.lock

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ PODS:
3131
- hermes-engine (0.75.4):
3232
- hermes-engine/Pre-built (= 0.75.4)
3333
- hermes-engine/Pre-built (0.75.4)
34-
- Instabug (13.4.2)
34+
- Instabug (13.4.3)
3535
- instabug-reactnative-ndk (0.1.0):
3636
- DoubleConversion
3737
- glog
@@ -1603,7 +1603,7 @@ PODS:
16031603
- ReactCommon/turbomodule/core
16041604
- Yoga
16051605
- RNInstabug (13.4.0):
1606-
- Instabug (= 13.4.2)
1606+
- Instabug (= 13.4.3)
16071607
- React-Core
16081608
- RNReanimated (3.16.1):
16091609
- DoubleConversion
@@ -1747,6 +1747,7 @@ DEPENDENCIES:
17471747
- fmt (from `../node_modules/react-native/third-party-podspecs/fmt.podspec`)
17481748
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
17491749
- hermes-engine (from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`)
1750+
- Instabug (from `https://ios-releases.instabug.com/custom/release-support_cp_network_filtering_obfuscation-add_reset_network_state/13.4.3/Instabug.podspec`)
17501751
- instabug-reactnative-ndk (from `../node_modules/instabug-reactnative-ndk`)
17511752
- OCMock
17521753
- RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`)
@@ -1825,7 +1826,6 @@ SPEC REPOS:
18251826
trunk:
18261827
- Google-Maps-iOS-Utils
18271828
- GoogleMaps
1828-
- Instabug
18291829
- OCMock
18301830
- SocketRocket
18311831

@@ -1843,6 +1843,8 @@ EXTERNAL SOURCES:
18431843
hermes-engine:
18441844
:podspec: "../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec"
18451845
:tag: hermes-2024-08-15-RNv0.75.1-4b3bf912cc0f705b51b71ce1a5b8bd79b93a451b
1846+
Instabug:
1847+
:podspec: https://ios-releases.instabug.com/custom/release-support_cp_network_filtering_obfuscation-add_reset_network_state/13.4.3/Instabug.podspec
18461848
instabug-reactnative-ndk:
18471849
:path: "../node_modules/instabug-reactnative-ndk"
18481850
RCT-Folly:
@@ -1993,7 +1995,7 @@ SPEC CHECKSUMS:
19931995
Google-Maps-iOS-Utils: f77eab4c4326d7e6a277f8e23a0232402731913a
19941996
GoogleMaps: 032f676450ba0779bd8ce16840690915f84e57ac
19951997
hermes-engine: ea92f60f37dba025e293cbe4b4a548fd26b610a0
1996-
Instabug: 7a71890217b97b1e32dbca96661845396b66da2f
1998+
Instabug: 12ea6990039094c48a7c7e8103ba8679c0833f5e
19971999
instabug-reactnative-ndk: d765ac289d56e8896398d02760d9abf2562fc641
19982000
OCMock: 589f2c84dacb1f5aaf6e4cec1f292551fe748e74
19992001
RCT-Folly: 4464f4d875961fce86008d45f4ecf6cef6de0740
@@ -2059,14 +2061,14 @@ SPEC CHECKSUMS:
20592061
ReactCommon: 6a952e50c2a4b694731d7682aaa6c79bc156e4ad
20602062
RNCClipboard: 2821ac938ef46f736a8de0c8814845dde2dcbdfb
20612063
RNGestureHandler: 511250b190a284388f9dd0d2e56c1df76f14cfb8
2062-
RNInstabug: 8e7eb1df3f35b935dda661f5bb475f37cef595e6
2064+
RNInstabug: 514b187e5b884939fd337eefb3244ea75e7e34f8
20632065
RNReanimated: f42a5044d121d68e91680caacb0293f4274228eb
20642066
RNScreens: c7ceced6a8384cb9be5e7a5e88e9e714401fd958
20652067
RNSVG: 8b1a777d54096b8c2a0fd38fc9d5a454332bbb4d
20662068
RNVectorIcons: 6382277afab3c54658e9d555ee0faa7a37827136
20672069
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
2068-
Yoga: 055f92ad73f8c8600a93f0e25ac0b2344c3b07e6
2070+
Yoga: aa3df615739504eebb91925fc9c58b4922ea9a08
20692071

2070-
PODFILE CHECKSUM: 9116afa418638f45a5fba99099befb7da0049828
2072+
PODFILE CHECKSUM: 784fde5e5fa833eeefea8a5deaa699d18167d101
20712073

2072-
COCOAPODS: 1.14.0
2074+
COCOAPODS: 1.15.2

examples/default/src/App.tsx

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, { useEffect } from 'react';
2-
import { StyleSheet } from 'react-native';
1+
import React, { useEffect, useState } from 'react';
2+
import { ActivityIndicator, StyleSheet } from 'react-native';
33

44
import { GestureHandlerRootView } from 'react-native-gesture-handler';
55
import { NavigationContainer } from '@react-navigation/native';
@@ -20,23 +20,36 @@ import { QueryClient, QueryClientProvider } from 'react-query';
2020

2121
const queryClient = new QueryClient();
2222

23-
//Setting up the handler
24-
2523
export const App: React.FC = () => {
24+
const [isInstabugInitialized, setIsInstabugInitialized] = useState(false);
25+
2626
useEffect(() => {
27-
Instabug.init({
28-
token: '0fcc87b8bf731164828cc411eccc802a',
29-
invocationEvents: [InvocationEvent.floatingButton],
30-
debugLogsLevel: LogLevel.verbose,
31-
networkInterceptionMode: NetworkInterceptionMode.native,
32-
});
33-
CrashReporting.setNDKCrashesEnabled(true);
34-
35-
Instabug.setReproStepsConfig({
36-
all: ReproStepsMode.enabled,
37-
});
27+
const initializeInstabug = async () => {
28+
try {
29+
await Instabug.init({
30+
token: '0fcc87b8bf731164828cc411eccc802a',
31+
invocationEvents: [InvocationEvent.floatingButton],
32+
debugLogsLevel: LogLevel.verbose,
33+
networkInterceptionMode: NetworkInterceptionMode.native,
34+
});
35+
36+
CrashReporting.setNDKCrashesEnabled(true);
37+
Instabug.setReproStepsConfig({ all: ReproStepsMode.enabled });
38+
39+
setIsInstabugInitialized(true); // Set to true after initialization
40+
} catch (error) {
41+
console.error('Instabug initialization failed:', error);
42+
setIsInstabugInitialized(true); // Proceed even if initialization fails
43+
}
44+
};
45+
46+
initializeInstabug();
3847
}, []);
3948

49+
if (!isInstabugInitialized) {
50+
return <ActivityIndicator size="large" color="#0000ff" style={styles.loading} />;
51+
}
52+
4053
return (
4154
<GestureHandlerRootView style={styles.root}>
4255
<NativeBaseProvider theme={nativeBaseTheme}>
@@ -54,4 +67,9 @@ const styles = StyleSheet.create({
5467
root: {
5568
flex: 1,
5669
},
70+
loading: {
71+
flex: 1,
72+
justifyContent: 'center',
73+
alignItems: 'center',
74+
},
5775
});

src/modules/Instabug.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const firstScreen = 'Initial Screen';
4545
let _currentAppState = AppState.currentState;
4646
let isNativeInterceptionFeatureEnabled = false; // Checks the value of "cp_native_interception_enabled" backend flag.
4747
let hasAPMNetworkPlugin = false; // Android only: checks if the APM plugin is installed.
48-
let shouldEnableNativeInterception = false; // Android: used to disable APM logging inside reportNetworkLog() -> NativeAPM.networkLogAndroid(), iOS: used to control native interception (true == enabled , false == disabled)
48+
let shouldEnableNativeInterception = false; // For Android: used to disable APM logging inside reportNetworkLog() -> NativeAPM.networkLogAndroid(), For iOS: used to control native interception (true == enabled , false == disabled)
4949

5050
/**
5151
* Enables or disables Instabug functionality.
@@ -240,16 +240,9 @@ function handleAndroidNativeInterception() {
240240
}
241241
} else {
242242
shouldEnableNativeInterception = false; // rollback to use JS interceptor for APM & Core.
243-
if (hasAPMNetworkPlugin) {
244-
console.error(
245-
InstabugConstants.IBG_APM_TAG + InstabugConstants.NATIVE_INTERCEPTION_DISABLED_MESSAGE,
246-
);
247-
} else {
248-
console.error(
249-
InstabugConstants.IBG_APM_TAG +
250-
InstabugConstants.PLUGIN_NOT_INSTALLED_AND_NATIVE_INTERCEPTION_DISABLED_MESSAGE,
251-
);
252-
}
243+
console.error(
244+
InstabugConstants.IBG_APM_TAG + InstabugConstants.NATIVE_INTERCEPTION_DISABLED_MESSAGE,
245+
);
253246
}
254247
}
255248

src/utils/InstabugConstants.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ const InstabugConstants = {
99
'The request body has not been logged because it exceeds the maximum size of 10 Kb',
1010
IBG_APM_TAG: 'IBG-APM: ',
1111
SWITCHED_TO_NATIVE_INTERCEPTION_MESSAGE:
12-
'Switched to Native Interception: Android Plugin Detected',
13-
PLUGIN_NOT_INSTALLED_MESSAGE: 'Network traces won’t get captured as plugin is not installed',
14-
PLUGIN_NOT_INSTALLED_AND_NATIVE_INTERCEPTION_DISABLED_MESSAGE:
15-
'Network traces won’t get captured as plugin is not installed and native interception is disabled from BE',
16-
NATIVE_INTERCEPTION_DISABLED_MESSAGE: 'Native interception is disabled',
12+
'Android Plugin Detected. Switched to Native Interception.',
13+
PLUGIN_NOT_INSTALLED_MESSAGE:
14+
'Network Spans will not be captured as Android Plugin is not installed. Disabling Native Interception to minimize data loss.',
15+
NATIVE_INTERCEPTION_DISABLED_MESSAGE:
16+
'Network Spans capture is disabled by Instabug. Disabling native interception to avoid data loss.',
1717
};
1818

1919
export default InstabugConstants;

test/mocks/mockNetworkLogger.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const mockNetworkLogger: NetworkLoggerNativeModule = {
55
removeListeners: jest.fn(),
66
hasAPMNetworkPlugin: jest.fn(),
77
isNativeInterceptionEnabled: jest.fn(),
8+
forceStartNetworkLoggingIOS: jest.fn(),
9+
forceStopNetworkLoggingIOS: jest.fn(),
810
};
911

1012
export default mockNetworkLogger;

test/modules/Instabug.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ describe('Instabug iOS initialization tests', () => {
926926
await Instabug.init(config);
927927

928928
expect(NativeNetworkLogger.isNativeInterceptionEnabled).toHaveBeenCalled();
929-
expect(NetworkLogger.setEnabled).not.toHaveBeenCalled();
929+
expect(NetworkLogger.setEnabled).toHaveBeenCalledWith(false);
930930
expect(NativeInstabug.init).toHaveBeenCalledWith(
931931
config.token,
932932
config.invocationEvents,
@@ -1044,8 +1044,7 @@ describe('Instabug Android initialization tests', () => {
10441044

10451045
expect(logSpy).toBeCalledTimes(1);
10461046
expect(logSpy).toBeCalledWith(
1047-
InstabugConstants.IBG_APM_TAG +
1048-
InstabugConstants.PLUGIN_NOT_INSTALLED_AND_NATIVE_INTERCEPTION_DISABLED_MESSAGE,
1047+
InstabugConstants.IBG_APM_TAG + InstabugConstants.NATIVE_INTERCEPTION_DISABLED_MESSAGE,
10491048
);
10501049
});
10511050

0 commit comments

Comments
 (0)