mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Gate network event reporting with feature flag (#51050)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/51050 Gate network event reporting on iOS (inputting into the network reporting subsystem), now that this is load-bearing with the Performance API. Changelog: [Internal] Reviewed By: vzaidman Differential Revision: D73995864 fbshipit-source-id: 65a15485cdae445eadff6c57148f3682af6de215
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c4a2cb9d90
commit
e1632da01c
@@ -16,6 +16,7 @@
|
||||
#import <React/RCTUtils.h>
|
||||
|
||||
#import <React/RCTHTTPRequestHandler.h>
|
||||
#import <react/featureflags/ReactNativeFeatureFlags.h>
|
||||
|
||||
#import "RCTInspectorNetworkReporter.h"
|
||||
#import "RCTNetworkPlugins.h"
|
||||
@@ -588,10 +589,12 @@ RCT_EXPORT_MODULE()
|
||||
id responseURL = response.URL ? response.URL.absoluteString : [NSNull null];
|
||||
NSArray<id> *responseJSON = @[ task.requestID, @(status), headers, responseURL ];
|
||||
|
||||
[RCTInspectorNetworkReporter reportResponseStart:task.requestID
|
||||
response:response
|
||||
statusCode:status
|
||||
headers:headers];
|
||||
if (facebook::react::ReactNativeFeatureFlags::enableNetworkEventReporting()) {
|
||||
[RCTInspectorNetworkReporter reportResponseStart:task.requestID
|
||||
response:response
|
||||
statusCode:status
|
||||
headers:headers];
|
||||
}
|
||||
[weakSelf sendEventWithName:@"didReceiveNetworkResponse" body:responseJSON];
|
||||
};
|
||||
|
||||
@@ -650,7 +653,9 @@ RCT_EXPORT_MODULE()
|
||||
NSArray *responseJSON =
|
||||
@[ task.requestID, RCTNullIfNil(error.localizedDescription), error.code == kCFURLErrorTimedOut ? @YES : @NO ];
|
||||
|
||||
[RCTInspectorNetworkReporter reportResponseEnd:task.requestID encodedDataLength:data.length];
|
||||
if (facebook::react::ReactNativeFeatureFlags::enableNetworkEventReporting()) {
|
||||
[RCTInspectorNetworkReporter reportResponseEnd:task.requestID encodedDataLength:data.length];
|
||||
}
|
||||
[strongSelf sendEventWithName:@"didCompleteNetworkResponse" body:responseJSON];
|
||||
[strongSelf->_tasksByRequestID removeObjectForKey:task.requestID];
|
||||
};
|
||||
@@ -667,9 +672,11 @@ RCT_EXPORT_MODULE()
|
||||
}
|
||||
_tasksByRequestID[task.requestID] = task;
|
||||
responseSender(@[ task.requestID ]);
|
||||
[RCTInspectorNetworkReporter reportRequestStart:task.requestID
|
||||
request:request
|
||||
encodedDataLength:task.response.expectedContentLength];
|
||||
if (facebook::react::ReactNativeFeatureFlags::enableNetworkEventReporting()) {
|
||||
[RCTInspectorNetworkReporter reportRequestStart:task.requestID
|
||||
request:request
|
||||
encodedDataLength:task.response.expectedContentLength];
|
||||
}
|
||||
}
|
||||
|
||||
[task start];
|
||||
|
||||
Reference in New Issue
Block a user