Skip to content

Commit 6021e0a

Browse files
chore: add iOS feature flag changes
1 parent d679ad6 commit 6021e0a

File tree

8 files changed

+70
-56
lines changed

8 files changed

+70
-56
lines changed

examples/default/ios/Podfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ target 'InstabugExample' do
1818
# Flags change depending on the env values.
1919
flags = get_default_flags()
2020

21+
# pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/feature-support_cp_network_filtering_obfuscation-base/13.4.2/Instabug.podspec'
22+
pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/feature-support_cp_network_filtering_obfuscation-release/13.4.2/Instabug.podspec'
2123
use_react_native!(
2224
:path => config[:reactNativePath],
2325
# Hermes is now enabled by default. Disable by setting this flag to false.

examples/default/ios/Podfile.lock

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PODS:
3838
- hermes-engine (0.72.3):
3939
- hermes-engine/Pre-built (= 0.72.3)
4040
- hermes-engine/Pre-built (0.72.3)
41-
- Instabug (13.3.0)
41+
- Instabug (13.4.2)
4242
- instabug-reactnative-ndk (0.1.0):
4343
- RCT-Folly (= 2021.07.22.00)
4444
- React-Core
@@ -476,7 +476,7 @@ PODS:
476476
- RCT-Folly (= 2021.07.22.00)
477477
- React-Core
478478
- RNInstabug (13.3.0):
479-
- Instabug (= 13.3.0)
479+
- Instabug (= 13.4.2)
480480
- React-Core
481481
- RNReanimated (3.5.4):
482482
- DoubleConversion
@@ -524,6 +524,7 @@ DEPENDENCIES:
524524
- FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`)
525525
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
526526
- hermes-engine (from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`)
527+
- Instabug (from `https://ios-releases.instabug.com/custom/feature-support_cp_network_filtering_obfuscation-release/13.4.2/Instabug.podspec`)
527528
- instabug-reactnative-ndk (from `../node_modules/instabug-reactnative-ndk`)
528529
- libevent (~> 2.1.12)
529530
- OCMock
@@ -580,7 +581,6 @@ SPEC REPOS:
580581
- fmt
581582
- Google-Maps-iOS-Utils
582583
- GoogleMaps
583-
- Instabug
584584
- libevent
585585
- OCMock
586586
- SocketRocket
@@ -599,6 +599,8 @@ EXTERNAL SOURCES:
599599
hermes-engine:
600600
:podspec: "../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec"
601601
:tag: hermes-2023-03-20-RNv0.72.0-49794cfc7c81fb8f69fd60c3bbf85a7480cc5a77
602+
Instabug:
603+
:podspec: https://ios-releases.instabug.com/custom/feature-support_cp_network_filtering_obfuscation-release/13.4.2/Instabug.podspec
602604
instabug-reactnative-ndk:
603605
:path: "../node_modules/instabug-reactnative-ndk"
604606
RCT-Folly:
@@ -704,7 +706,7 @@ SPEC CHECKSUMS:
704706
Google-Maps-iOS-Utils: f77eab4c4326d7e6a277f8e23a0232402731913a
705707
GoogleMaps: 032f676450ba0779bd8ce16840690915f84e57ac
706708
hermes-engine: 10fbd3f62405c41ea07e71973ea61e1878d07322
707-
Instabug: 4f26295103a330ec0236918359eef7ccaa74e2fa
709+
Instabug: 2a314dc5c7a6d5d07f7cb20f21c98dab72ec2387
708710
instabug-reactnative-ndk: 960119a69380cf4cbe47ccd007c453f757927d17
709711
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
710712
OCMock: 589f2c84dacb1f5aaf6e4cec1f292551fe748e74
@@ -748,14 +750,14 @@ SPEC CHECKSUMS:
748750
ReactCommon: 3ccb8fb14e6b3277e38c73b0ff5e4a1b8db017a9
749751
RNCClipboard: 41d8d918092ae8e676f18adada19104fa3e68495
750752
RNGestureHandler: 6e46dde1f87e5f018a54fe5d40cd0e0b942b49ee
751-
RNInstabug: a4ac0bd09123f6be7d58be541dc220acbaff8dc3
753+
RNInstabug: 3bd51c9e01a076ed5b0bc0a10590e34272dff2fb
752754
RNReanimated: ab2e96c6d5591c3dfbb38a464f54c8d17fb34a87
753755
RNScreens: b21dc57dfa2b710c30ec600786a3fc223b1b92e7
754756
RNSVG: 80584470ff1ffc7994923ea135a3e5ad825546b9
755757
RNVectorIcons: 8b5bb0fa61d54cd2020af4f24a51841ce365c7e9
756758
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
757759
Yoga: 8796b55dba14d7004f980b54bcc9833ee45b28ce
758760

759-
PODFILE CHECKSUM: 281036e04bd4b9e7c2cc03a503b3245d3f1dd0dd
761+
PODFILE CHECKSUM: 406d29e19cb1ac67c149111d9ea23ee7bbf9db83
760762

761763
COCOAPODS: 1.15.2

ios/RNInstabug/InstabugNetworkLoggerBridge.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
+------------------------------------------------------------------------+
1111
*/
1212

13+
- (void)isNativeInterceptionEnabled:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject;
1314
@end

ios/RNInstabug/InstabugNetworkLoggerBridge.m

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Created by Andrew Amin on 01/10/2024.
66
//
77
#import "InstabugNetworkLoggerBridge.h"
8+
#import "Util/IBGNetworkLogger+CP.h"
89

910
@implementation InstabugNtworkLoggerBridge
1011

@@ -39,17 +40,11 @@ -(void)stopObserving {
3940
// Remove upstream listeners, stop unnecessary background tasks
4041
}
4142

42-
// Get first-time value of [cp_native_interception_enabled] flag
43-
RCT_EXPORT_METHOD(isNativeInterceptionEnabled:(RCTPromiseResolveBlock)resolve
44-
rejecter:(RCTPromiseRejectBlock)reject) {
45-
@try {
46-
// Assuming you want to return YES for now, wrapped in NSNumber
47-
resolve(@(NO));
48-
} @catch (NSError *error) {
49-
reject(@"error_code", @"An error occurred", error);
50-
}
43+
RCT_EXPORT_METHOD(isNativeInterceptionEnabled:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject) {
44+
resolve(@(IBGNetworkLogger.isNativeNetworkInterceptionFeatureEnabled));
5145
}
5246

47+
5348
// RCT_EXPORT_METHOD(registerNetworkLogsListener){
5449
// [IBGNetworkLogger setRequestObfuscationHandlerV2:^(NSURLRequest * _Nonnull request, void (^ _Nonnull completionHandler)(NSURLRequest * _Nonnull)) {
5550
// NSString *tempId = [[[NSUUID alloc] init] UUIDString];

ios/RNInstabug/Util/IBGNetworkLogger+CP.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
NS_ASSUME_NONNULL_BEGIN
44

5+
6+
57
@interface IBGNetworkLogger (CP)
68

9+
@property (class, atomic, assign) BOOL isNativeNetworkInterceptionFeatureEnabled;
10+
711
+ (void)disableAutomaticCapturingOfNetworkLogs;
812
+ (void)addNetworkLogWithUrl:(NSString *)url
913
method:(NSString *)method

ios/native.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$instabug = { :version => '13.3.0' }
1+
$instabug = { :version => '13.4.2' }
22

33
def use_instabug! (spec = nil)
44
version = $instabug[:version]

src/modules/Instabug.ts

Lines changed: 41 additions & 31 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 isNativeInterceptionEnabled = false;
46+
let isNativeInterceptionFeatureEnabled = false;
4747
let hasAPMNetworkPlugin = false;
4848
let isAPMNetworkEnabled = false;
49-
let disableAPMLogging = false; // used to disable APM logging inside reportNetworkLog() -> NativeAPM.networkLogAndroid()
49+
let shouldEnableNativeInterception = false; // used to disable APM logging inside reportNetworkLog() -> NativeAPM.networkLogAndroid()
5050

5151
/**
5252
* Enables or disables Instabug functionality.
@@ -73,6 +73,17 @@ function reportCurrentViewForAndroid(screenName: string | null) {
7373
}
7474
}
7575

76+
function _logFlags() {
77+
console.log(
78+
`Andrew: init -> {
79+
isNativeInterceptionFeatureEnabled: ${isNativeInterceptionFeatureEnabled},
80+
hasAPMNetworkPlugin: ${hasAPMNetworkPlugin},
81+
isApmNetworkEnabled: ${isAPMNetworkEnabled},
82+
shouldEnableNativeInterception: ${shouldEnableNativeInterception}
83+
}`,
84+
);
85+
}
86+
7687
/**
7788
* Initializes the SDK.
7889
* This is the main SDK method that does all the magic. This is the only
@@ -82,11 +93,12 @@ function reportCurrentViewForAndroid(screenName: string | null) {
8293
*/
8394
export const init = async (config: InstabugConfig) => {
8495
// Initialize necessary variables
85-
isNativeInterceptionEnabled = await NativeNetworkLogger.isNativeInterceptionEnabled();
96+
isNativeInterceptionFeatureEnabled = await NativeNetworkLogger.isNativeInterceptionEnabled();
8697
if (Platform.OS === 'android') {
8798
hasAPMNetworkPlugin = await NativeNetworkLogger.hasAPMNetworkPlugin();
8899
isAPMNetworkEnabled = await NativeNetworkLogger.isAPMNetworkEnabled();
89-
disableAPMLogging = config.networkInterceptionMode === NetworkInterceptionMode.native;
100+
shouldEnableNativeInterception =
101+
config.networkInterceptionMode === NetworkInterceptionMode.native;
90102
}
91103

92104
// Add app state listener to handle background/foreground transitions
@@ -100,21 +112,14 @@ export const init = async (config: InstabugConfig) => {
100112
handleNetworkInterceptionMode(config);
101113

102114
// Log the current APM network flags and initialize Instabug
103-
console.log(
104-
`Andrew: init -> {
105-
isNativeInterceptionEnabled: ${isNativeInterceptionEnabled},
106-
hasAPMNetworkPlugin: ${hasAPMNetworkPlugin},
107-
isApmNetworkEnabled: ${isAPMNetworkEnabled},
108-
disableAPMLogging: ${disableAPMLogging}
109-
}`,
110-
);
115+
_logFlags();
111116

112117
//Set APM networking flags for the first time
113118
setApmNetworkFlagsIfChanged({
114-
isNativeInterceptionEnabled: isNativeInterceptionEnabled,
119+
isNativeInterceptionFeatureEnabled: isNativeInterceptionFeatureEnabled,
115120
hasAPMNetworkPlugin: hasAPMNetworkPlugin,
116121
isAPMNetworkEnabled: isAPMNetworkEnabled,
117-
disableAPMLogging: disableAPMLogging,
122+
shouldEnableNativeInterception: shouldEnableNativeInterception,
118123
});
119124

120125
// call Instabug native init method
@@ -146,7 +151,7 @@ const handleAppStateChange = async (nextAppState: AppStateStatus, config: Instab
146151
handleNetworkInterceptionMode(config);
147152
initializeNativeInstabug(config);
148153
}
149-
154+
_logFlags();
150155
console.log('Andrew: App has come to the foreground!');
151156
}
152157

@@ -158,15 +163,17 @@ const handleAppStateChange = async (nextAppState: AppStateStatus, config: Instab
158163
* Fetches the current APM network flags.
159164
*/
160165
const fetchApmNetworkFlags = async () => {
161-
isNativeInterceptionEnabled = await NativeNetworkLogger.isNativeInterceptionEnabled();
162-
hasAPMNetworkPlugin = await NativeNetworkLogger.hasAPMNetworkPlugin();
163-
isAPMNetworkEnabled = await NativeNetworkLogger.isAPMNetworkEnabled();
166+
isNativeInterceptionFeatureEnabled = await NativeNetworkLogger.isNativeInterceptionEnabled();
167+
if (Platform.OS === 'android') {
168+
hasAPMNetworkPlugin = await NativeNetworkLogger.hasAPMNetworkPlugin();
169+
isAPMNetworkEnabled = await NativeNetworkLogger.isAPMNetworkEnabled();
170+
}
164171

165172
return {
166-
isNativeInterceptionEnabled,
173+
isNativeInterceptionFeatureEnabled,
167174
hasAPMNetworkPlugin,
168175
isAPMNetworkEnabled,
169-
disableAPMLogging,
176+
shouldEnableNativeInterception,
170177
};
171178
};
172179

@@ -198,15 +205,15 @@ const checkNativeInterceptionForAndroid = (config: InstabugConfig) => {
198205
const { networkInterceptionMode } = config;
199206

200207
if (networkInterceptionMode === NetworkInterceptionMode.javascript) {
201-
if (isNativeInterceptionEnabled && hasAPMNetworkPlugin) {
202-
disableAPMLogging = true;
208+
if (isNativeInterceptionFeatureEnabled && hasAPMNetworkPlugin) {
209+
shouldEnableNativeInterception = true;
203210
console.warn(
204211
InstabugConstants.IBG_APM_TAG + 'Switched to Native Interception: Android Plugin Detected',
205212
);
206213
}
207214
} else {
208-
if (isNativeInterceptionEnabled) {
209-
disableAPMLogging = hasAPMNetworkPlugin;
215+
if (isNativeInterceptionFeatureEnabled) {
216+
shouldEnableNativeInterception = hasAPMNetworkPlugin;
210217
if (!hasAPMNetworkPlugin) {
211218
console.error(
212219
InstabugConstants.IBG_APM_TAG +
@@ -230,12 +237,13 @@ const checkNativeInterceptionForAndroid = (config: InstabugConfig) => {
230237
* Handles the native interception logic for iOS.
231238
*/
232239
const checkNativeInterceptionForIOS = (config: InstabugConfig) => {
233-
if (
234-
config.networkInterceptionMode === NetworkInterceptionMode.native &&
235-
!isNativeInterceptionEnabled
236-
) {
237-
config.networkInterceptionMode = NetworkInterceptionMode.javascript;
238-
console.error(InstabugConstants.IBG_APM_TAG + 'Native interception is disabled');
240+
if (config.networkInterceptionMode === NetworkInterceptionMode.native) {
241+
if (isNativeInterceptionFeatureEnabled) {
242+
shouldEnableNativeInterception = true;
243+
} else {
244+
shouldEnableNativeInterception = false;
245+
console.error(InstabugConstants.IBG_APM_TAG + 'Native interception is disabled');
246+
}
239247
}
240248
};
241249

@@ -245,14 +253,16 @@ const checkNativeInterceptionForIOS = (config: InstabugConfig) => {
245253
const initializeNativeInstabug = (config: InstabugConfig) => {
246254
console.log(
247255
`Andrew: initializeNativeInstabug -> NativeNetworkInterceptionMode ${
256+
shouldEnableNativeInterception &&
248257
config.networkInterceptionMode === NetworkInterceptionMode.native
249258
}`,
250259
);
251260
NativeInstabug.init(
252261
config.token,
253262
config.invocationEvents,
254263
config.debugLogsLevel ?? LogLevel.error,
255-
config.networkInterceptionMode === NetworkInterceptionMode.native,
264+
shouldEnableNativeInterception &&
265+
config.networkInterceptionMode === NetworkInterceptionMode.native,
256266
config.codePushVersion,
257267
);
258268
};

src/utils/InstabugUtils.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ import { NativeInstabug } from '../native/NativeInstabug';
1414
import { NativeAPM } from '../native/NativeAPM';
1515

1616
type ApmNetworkFlags = {
17-
isNativeInterceptionEnabled: boolean;
17+
isNativeInterceptionFeatureEnabled: boolean;
1818
hasAPMNetworkPlugin: boolean;
1919
isAPMNetworkEnabled: boolean;
20-
disableAPMLogging: boolean;
20+
shouldEnableNativeInterception: boolean;
2121
};
2222

2323
let apmFlags: ApmNetworkFlags = {
24-
isNativeInterceptionEnabled: false,
24+
isNativeInterceptionFeatureEnabled: false,
2525
hasAPMNetworkPlugin: false,
2626
isAPMNetworkEnabled: false,
27-
disableAPMLogging: false,
27+
shouldEnableNativeInterception: false,
2828
};
2929

3030
export function setApmNetworkFlagsIfChanged(flags: ApmNetworkFlags): boolean {
3131
if (
3232
flags.isAPMNetworkEnabled === apmFlags.isAPMNetworkEnabled &&
3333
flags.hasAPMNetworkPlugin === apmFlags.hasAPMNetworkPlugin &&
34-
flags.isNativeInterceptionEnabled === apmFlags.isNativeInterceptionEnabled &&
35-
flags.disableAPMLogging === apmFlags.disableAPMLogging
34+
flags.isNativeInterceptionFeatureEnabled === apmFlags.isNativeInterceptionFeatureEnabled &&
35+
flags.shouldEnableNativeInterception === apmFlags.shouldEnableNativeInterception
3636
) {
3737
return false;
3838
}
@@ -188,9 +188,9 @@ export const reportNetworkLog = (network: NetworkData) => {
188188
);
189189

190190
if (
191-
(!apmFlags.isNativeInterceptionEnabled ||
191+
(!apmFlags.isNativeInterceptionFeatureEnabled ||
192192
!apmFlags.hasAPMNetworkPlugin ||
193-
!apmFlags.disableAPMLogging) &&
193+
!apmFlags.shouldEnableNativeInterception) &&
194194
apmFlags.isAPMNetworkEnabled
195195
) {
196196
console.log('Andrew: ' + 'NetworkLogger -> NativeAPM.networkLogAndroid');
@@ -216,7 +216,7 @@ export const reportNetworkLog = (network: NetworkData) => {
216216
} else {
217217
console.log(
218218
'Andrew: ' +
219-
`NetworkLogger -> {isNativeInterceptionEnabled: ${apmFlags.isNativeInterceptionEnabled}}`,
219+
`NetworkLogger -> {isNativeInterceptionEnabled: ${apmFlags.isNativeInterceptionFeatureEnabled}}`,
220220
);
221221
console.log('Andrew: ' + 'NetworkLogger -> NativeInstabug.networkLogIOS');
222222

0 commit comments

Comments
 (0)