[MOB-12425] Properly Disable Network Interception with Patched XHR #984
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the change
The current implementation of the network interceptor grabs the original
XMLHttpRequest
methods that we alter from the beginning (once you importinstabug-reactnative
) so that when the user wants to disable network interception/logging usingNetworkLogger.setEnabled(false)
it reassigns these methods back to their original version.The fact that we grab original XHR methods on import means that any changes done by the user after this import will get ignored even after disabling network logging.
This PR modifies the XHR interceptor to get the original
XMLHttpRequest
methods when enabling it and not globally on import. This will enable users to patch XHR when network interception is disabled (which includes beforeInstabug.init
andNetworkLogger.setEnabled(true)
and afterNetworkLogger.setEnabled(false)
).Type of change
Related issues
Fixes #981
Checklists
Development
Code review