Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the start of recording/intercepting support #95

Merged
merged 15 commits into from
May 8, 2022

Conversation

sdg9
Copy link
Collaborator

@sdg9 sdg9 commented May 7, 2022

Partially implements #94

High level

  • Monkey patch react native's "fetch" (and RN fetch is really an XMLHttpRequest polyfill) so that requests/responses can be intercepted
  • Display captured network traffic in Mezzo's web GUI
  • [Future state, out of scope from PR] Friendly UI to convert captured network response to persisted mock data

Under the hood mezzo uses sockets to communicate from RN <--> Mezzo server <--> Mezzo admin web.
Large concepts and even chunks of code were used from Reactotron (MIT license) in the RN integration layer as it is exactly what they do to capture network traffic.

Capture3

It's a hefty PR and in many ways still a work in progress but if anyone wants to run with UI I don't anticipate any serious need to change the interfaces or data structures so we can always get this in while I continue polishing.

sdg9 added 15 commits May 6, 2022 23:19
nx g @nrwl/node:lib utils-logger --publishable --importPath @caribou-crew/mezzo-utils-logger
Currently it is a REST based instead of socket based way to capture and it doesn't monkeypatch
Consider moving most of the server side logic here to better distinguish
between core-client and core-server (hosting vs making REST or socket requests)
Core could then potentially be shared between both
@sdg9 sdg9 requested review from NSwanson1 and Gonzalo8642 and removed request for NSwanson1 May 7, 2022 19:51
@@ -0,0 +1,4 @@
{
"name": "@caribou-crew/mezzo-core-client",
"version": "0.0.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a huge issue, but react, react-dom and react-test-renderer all have the same version number. I can only assume this is so they can make sure everything is compatible with each other. Might be a good idea to do the same if we think we'll spend time writing migration/compatibility guides. I don't think we'll need to actively maintain both of these at the same time. So maybe it's not as important

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's chat more im not ready to publish this package to npm yet anyway

@sdg9 sdg9 marked this pull request as ready for review May 7, 2022 21:51
@sdg9 sdg9 merged commit 55d503f into main May 8, 2022
@sdg9 sdg9 deleted the sdg9/recordingDeepDiveReactotron branch May 8, 2022 02:21
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.

2 participants