Skip to content

Conversation

@a7medev
Copy link
Contributor

@a7medev a7medev commented May 25, 2023

Description of the change

The current implementation of the network interceptor grabs the original XMLHttpRequest methods that we alter from the beginning (once you import instabug-reactnative) so that when the user wants to disable network interception/logging using NetworkLogger.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 before Instabug.init and NetworkLogger.setEnabled(true) and after NetworkLogger.setEnabled(false)).

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Related issues

Fixes #981

Checklists

Development

  • Lint rules pass locally
  • The code changed/added as part of this pull request has been covered with tests

Code review

  • This pull request has a descriptive title and information useful to a reviewer
  • Issue from task tracker has a link to this pull request

@a7medev a7medev requested a review from DavidMina96 May 25, 2023 17:40
@a7medev a7medev self-assigned this May 25, 2023
@InstabugCI
Copy link
Collaborator

Coverage Report

Label Coverage Status
JavaScript 96.5%
Android 47.8%
iOS 39.0%

Generated by 🚫 dangerJS against aa42fb3

@DavidMina96 DavidMina96 merged commit d4a6670 into dev May 30, 2023
@DavidMina96 DavidMina96 deleted the refactor/proper-network-logger-disable branch May 30, 2023 10:28
HeshamMegid pushed a commit that referenced this pull request May 30, 2023
)

Modify the XHR interceptor to get the original XMLHttpRequest methods when enabling it and not globally on import, allowing users to patch XHR when network interception is disabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants