Skip to content

Commit 1271f4d

Browse files
chore: add iOS new APIs
1 parent 68a9f4e commit 1271f4d

File tree

8 files changed

+22
-108
lines changed

8 files changed

+22
-108
lines changed

examples/default/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ target 'InstabugExample' do
1919
flags = get_default_flags()
2020

2121
# 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'
22+
pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/feature-support_cp_network_filtering_obfuscation-release/13.4.3/Instabug.podspec'
2323
use_react_native!(
2424
:path => config[:reactNativePath],
2525
# Hermes is now enabled by default. Disable by setting this flag to false.

examples/default/ios/Podfile.lock

Lines changed: 7 additions & 7 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.4.2)
41+
- Instabug (13.4.3)
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.4.0):
479-
- Instabug (= 13.4.2)
479+
- Instabug (= 13.4.3)
480480
- React-Core
481481
- RNReanimated (3.5.4):
482482
- DoubleConversion
@@ -524,7 +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`)
527+
- Instabug (from `https://ios-releases.instabug.com/custom/feature-support_cp_network_filtering_obfuscation-release/13.4.3/Instabug.podspec`)
528528
- instabug-reactnative-ndk (from `../node_modules/instabug-reactnative-ndk`)
529529
- libevent (~> 2.1.12)
530530
- OCMock
@@ -600,7 +600,7 @@ EXTERNAL SOURCES:
600600
:podspec: "../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec"
601601
:tag: hermes-2023-03-20-RNv0.72.0-49794cfc7c81fb8f69fd60c3bbf85a7480cc5a77
602602
Instabug:
603-
:podspec: https://ios-releases.instabug.com/custom/feature-support_cp_network_filtering_obfuscation-release/13.4.2/Instabug.podspec
603+
:podspec: https://ios-releases.instabug.com/custom/feature-support_cp_network_filtering_obfuscation-release/13.4.3/Instabug.podspec
604604
instabug-reactnative-ndk:
605605
:path: "../node_modules/instabug-reactnative-ndk"
606606
RCT-Folly:
@@ -706,7 +706,7 @@ SPEC CHECKSUMS:
706706
Google-Maps-iOS-Utils: f77eab4c4326d7e6a277f8e23a0232402731913a
707707
GoogleMaps: 032f676450ba0779bd8ce16840690915f84e57ac
708708
hermes-engine: 10fbd3f62405c41ea07e71973ea61e1878d07322
709-
Instabug: 2a314dc5c7a6d5d07f7cb20f21c98dab72ec2387
709+
Instabug: f582dcf7a4099acca604fa7ffa3bf4eda295317f
710710
instabug-reactnative-ndk: 960119a69380cf4cbe47ccd007c453f757927d17
711711
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
712712
OCMock: 589f2c84dacb1f5aaf6e4cec1f292551fe748e74
@@ -750,14 +750,14 @@ SPEC CHECKSUMS:
750750
ReactCommon: 3ccb8fb14e6b3277e38c73b0ff5e4a1b8db017a9
751751
RNCClipboard: 41d8d918092ae8e676f18adada19104fa3e68495
752752
RNGestureHandler: 6e46dde1f87e5f018a54fe5d40cd0e0b942b49ee
753-
RNInstabug: 8e7eb1df3f35b935dda661f5bb475f37cef595e6
753+
RNInstabug: 514b187e5b884939fd337eefb3244ea75e7e34f8
754754
RNReanimated: ab2e96c6d5591c3dfbb38a464f54c8d17fb34a87
755755
RNScreens: b21dc57dfa2b710c30ec600786a3fc223b1b92e7
756756
RNSVG: 80584470ff1ffc7994923ea135a3e5ad825546b9
757757
RNVectorIcons: 8b5bb0fa61d54cd2020af4f24a51841ce365c7e9
758758
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
759759
Yoga: 8796b55dba14d7004f980b54bcc9833ee45b28ce
760760

761-
PODFILE CHECKSUM: 406d29e19cb1ac67c149111d9ea23ee7bbf9db83
761+
PODFILE CHECKSUM: afd54e1cb156d7b63f6e1beca2ba1f66fa30be0f
762762

763763
COCOAPODS: 1.15.2

examples/default/src/App.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ export const App: React.FC = () => {
3737
// networkData.url = networkData.url + '/iOS/obfuscated';
3838
// return networkData;
3939
// });
40-
NetworkLogger.setRequestFilterExpression('true');
40+
NetworkLogger.setRequestFilterExpression(
41+
"network.requestHeaders['content-type'] === 'application/json'",
42+
);
4143
});
4244
CrashReporting.setNDKCrashesEnabled(true);
4345

ios/RNInstabug/InstabugNetworkLoggerBridge.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ typedef NS_ENUM(NSInteger, NetworkListenerType) {
2828

2929
- (void) registerNetworkLogsListener:(NetworkListenerType)listenerType;
3030

31-
//- (void) registerNetworkLogsListener;
32-
3331
- (void) updateNetworkLogSnapshot: (NSString * _Nonnull)jsonString;
3432

3533
- (void) setNetworkLoggingRequestFilterPredicateIOS:(NSString * _Nonnull) callbackID : (BOOL)value;

ios/RNInstabug/InstabugNetworkLoggerBridge.m

Lines changed: 4 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -95,68 +95,6 @@ -(void)stopObserving {
9595
break;
9696
}
9797
}
98-
//RCT_EXPORT_METHOD(registerNetworkLogsListener) {
99-
// [IBGNetworkLogger setRequestAsyncObfuscationHandler:^(NSURLRequest * _Nonnull requestToBeObfuscated,
100-
// void (^ _Nonnull completion)(NSURLRequest * _Nonnull)) {
101-
// NSString *callbackID = [[[NSUUID alloc] init] UUIDString];
102-
// self.requestObfuscationCompletionDictionary[callbackID] = completion;
103-
//
104-
// // Ensure the URL, HTTP body, and headers are in the correct format
105-
// NSString *urlString = requestToBeObfuscated.URL.absoluteString ?: @"";
106-
// NSString *bodyString = [[NSString alloc] initWithData:requestToBeObfuscated.HTTPBody encoding:NSUTF8StringEncoding] ?: @"";
107-
// NSDictionary *headerDict = requestToBeObfuscated.allHTTPHeaderFields ?: @{};
108-
//
109-
// // Create the dictionary to send
110-
// NSDictionary *dict = @{
111-
// @"callbackID": callbackID,
112-
// @"url": urlString,
113-
// @"requestBody": bodyString,
114-
// @"requestHeader": headerDict
115-
// };
116-
//
117-
// // Send the event
118-
// [self sendEventWithName:@"IBGNetworkLoggerHandler" body:dict];
119-
//
120-
// }];
121-
//
122-
//
123-
// [IBGNetworkLogger setResponseObfuscationHandler:^(NSData * _Nullable responseData, NSURLResponse * _Nonnull response, NetworkObfuscationCompletionBlock _Nonnull completion) {
124-
//
125-
// NSString *callbackID = [[[NSUUID alloc] init] UUIDString];
126-
// self.responseObfuscationCompletionDictionary[callbackID] = completion;
127-
//
128-
//
129-
// // MARK: TODO: Convert Response To Dictionary & Pass it To React Native
130-
//
131-
// }];
132-
//
133-
//
134-
//
135-
// [IBGNetworkLogger setRequestFilteringHandler:^(NSURLRequest * _Nonnull request, void (^ _Nonnull completion)(BOOL)) {
136-
//
137-
// NSString *callbackID = [[[NSUUID alloc] init] UUIDString];
138-
// self.requestFilteringCompletionDictionary[callbackID] = completion;
139-
//
140-
//
141-
// // MARK: TODO: Convert Request To Dictionary & Pass it To React Native
142-
//
143-
// }];
144-
//
145-
//
146-
// [IBGNetworkLogger setResponseFilteringHandler:^(NSURLResponse * _Nonnull request, void (^ _Nonnull completion)(BOOL)) {
147-
//
148-
// NSString *callbackID = [[[NSUUID alloc] init] UUIDString];
149-
// self.responseFilteringCompletionDictionary[callbackID] = completion;
150-
//
151-
//
152-
// // MARK: TODO: Convert Request To Dictionary & Pass it To React Native
153-
//
154-
// }];
155-
//
156-
//
157-
//
158-
//
159-
//}
16098

16199

162100
RCT_EXPORT_METHOD(updateNetworkLogSnapshot:(NSString * _Nonnull)jsonString) {
@@ -195,33 +133,6 @@ -(void)stopObserving {
195133
} else {
196134
NSLog(@"Not Available Completion");
197135
}
198-
//
199-
//
200-
// // MARK: Might need to moved this into another method.
201-
// NSURLResponse *response; // Must be initialized from React Native Objects
202-
// NSData *responseData; // Must be initialized from React Native Objects
203-
// if ([callbackID isKindOfClass:[NSString class]] && self.responseObfuscationCompletionDictionary[callbackID] != nil) {
204-
//
205-
// ((NetworkObfuscationCompletionBlock)self.responseObfuscationCompletionDictionary[callbackID])(responseData, response);
206-
// } else {
207-
// NSLog(@"Not Available Completion");
208-
// }
209-
//
210-
//
211-
//
212-
// if ([callbackID isKindOfClass:[NSString class]] && self.responseFilteringCompletionDictionary[callbackID] != nil) {
213-
// // ⬇️ YES == Response will be saved, NO == will be ignored
214-
// ((IBGURLRequestResponseAsyncFilteringCompletedHandler)self.responseFilteringCompletionDictionary[callbackID])(YES);
215-
// } else {
216-
// NSLog(@"Not Available Completion");
217-
// }
218-
//
219-
// if ([callbackID isKindOfClass:[NSString class]] && self.requestFilteringCompletionDictionary[callbackID] != nil) {
220-
// // ⬇️ YES == Request will be saved, NO == will be ignored
221-
// ((IBGURLRequestResponseAsyncFilteringCompletedHandler)self.requestFilteringCompletionDictionary[callbackID])(YES);
222-
// } else {
223-
// NSLog(@"Not Available Completion");
224-
// }
225136

226137
}
227138

@@ -240,7 +151,7 @@ -(void)stopObserving {
240151

241152
// Set up the filtering handler
242153
- (void)setupRequestFilteringHandler {
243-
[IBGNetworkLogger setRequestFilteringHandler:^(NSURLRequest * _Nonnull request, void (^ _Nonnull completion)(BOOL)) {
154+
[IBGNetworkLogger setCPRequestFilteringHandler:^(NSURLRequest * _Nonnull request, void (^ _Nonnull completion)(BOOL)) {
244155
NSString *callbackID = [[[NSUUID alloc] init] UUIDString];
245156
self.requestFilteringCompletionDictionary[callbackID] = completion;
246157

@@ -254,7 +165,7 @@ - (void)setupRequestFilteringHandler {
254165

255166
// Set up the obfuscation handler
256167
- (void)setupRequestObfuscationHandler {
257-
[IBGNetworkLogger setRequestAsyncObfuscationHandler:^(NSURLRequest * _Nonnull request, void (^ _Nonnull completion)(NSURLRequest * _Nonnull)) {
168+
[IBGNetworkLogger setCPRequestAsyncObfuscationHandler:^(NSURLRequest * _Nonnull request, void (^ _Nonnull completion)(NSURLRequest * _Nonnull)) {
258169
NSString *callbackID = [[[NSUUID alloc] init] UUIDString];
259170
self.requestObfuscationCompletionDictionary[callbackID] = completion;
260171

@@ -272,11 +183,11 @@ - (void)setupRequestFilteringAndObfuscationHandler {
272183

273184
NSString *callbackID = [[[NSUUID alloc] init] UUIDString];
274185

275-
[IBGNetworkLogger setRequestAsyncObfuscationHandler:^(NSURLRequest * _Nonnull request, void (^ _Nonnull completion)(NSURLRequest * _Nonnull)) {
186+
[IBGNetworkLogger setCPRequestAsyncObfuscationHandler:^(NSURLRequest * _Nonnull request, void (^ _Nonnull completion)(NSURLRequest * _Nonnull)) {
276187
self.requestObfuscationCompletionDictionary[callbackID] = completion;
277188
}];
278189

279-
[IBGNetworkLogger setRequestAsyncObfuscationHandler:^(NSURLRequest * _Nonnull request, void (^ _Nonnull completion)(NSURLRequest * _Nonnull)) {
190+
[IBGNetworkLogger setCPRequestAsyncObfuscationHandler:^(NSURLRequest * _Nonnull request, void (^ _Nonnull completion)(NSURLRequest * _Nonnull)) {
280191
self.requestObfuscationCompletionDictionary[callbackID] = completion;
281192

282193
NSDictionary *dict = [self createNetworkRequestDictForRequest:request callbackID:callbackID];

ios/RNInstabug/Util/IBGNetworkLogger+CP.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ NS_ASSUME_NONNULL_BEGIN
3131
generatedW3CTraceparent:(NSString * _Nullable)generatedW3CTraceparent
3232
caughtedW3CTraceparent:(NSString * _Nullable)caughtedW3CTraceparent;
3333

34-
+ (void)setRequestAsyncObfuscationHandler:(void (^)(NSURLRequest * requestToBeObfuscated, void (^ completion)(NSURLRequest * obfuscatedRequest)))asyncObfuscationHandler;
35-
+ (void)setRequestFilteringHandler:(void (^)(NSURLRequest * request, void (^completion)(BOOL keep)))requestFilteringHandler;
36-
+ (void)setResponseFilteringHandler:(void (^)(NSURLResponse * response, void (^completion)(BOOL keep)))responseFilteringHandler;
34+
+ (void)setCPRequestAsyncObfuscationHandler:(void (^)(NSURLRequest * requestToBeObfuscated, void (^ completion)(NSURLRequest * obfuscatedRequest)))asyncObfuscationHandler;
35+
+ (void)setCPRequestFilteringHandler:(void (^)(NSURLRequest * request, void (^completion)(BOOL keep)))requestFilteringHandler;
36+
+ (void)setCPResponseFilteringHandler:(void (^)(NSURLResponse * response, void (^comppletion)(BOOL keep)))responseFilteringHandler;
3737

3838
@end
3939

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.4.2' }
1+
$instabug = { :version => '13.4.3' }
22

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

src/modules/NetworkLogger.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,17 @@ const _registerNetworkLogsListener = (
163163
}
164164

165165
if (_networkListener == null) {
166+
// set new listener.
166167
_networkListener = type;
167168
} else {
169+
// attach a new listener to the existing one.
168170
_networkListener = NetworkListenerType.both;
169171
}
170172
console.log(`Andrew: new NetworkLogsListener (${_networkListener}) attached`);
171173
NetworkLoggerEmitter.addListener(
172174
NativeNetworkLoggerEvent.NETWORK_LOGGER_HANDLER,
173175
(networkSnapshot) => {
176+
// Mapping the data [Native -> React-Native].
174177
const { id, url, requestHeader, requestBody, responseHeader, response, responseCode } =
175178
networkSnapshot;
176179

0 commit comments

Comments
 (0)