Commit Graph

52 Commits

Author SHA1 Message Date
Chaiwat Ekkaewnumchai
705ba8eaa8 Convert Flipper plugin "Network" to TypeScript
Summary: _typescript_

Reviewed By: danielbuechele

Differential Revision: D17155509

fbshipit-source-id: 45ae3e2de8cd7b3cdf7271905ef7c318d4289391
2019-09-05 02:51:40 -07:00
Chaiwat Ekkaewnumchai
0a53cccb40 Convert Flipper plugin "Network" to TypeScript
Summary: _typescript_

Reviewed By: jknoxville

Differential Revision: D17155508

fbshipit-source-id: 2452b023dd3a5f0063e4b6b6294ed00670ec9022
2019-09-05 02:51:40 -07:00
Chaiwat Ekkaewnumchai
4781f04ca4 Convert Flipper plugin "Network" to TypeScript
Summary: _typescript_

Reviewed By: danielbuechele

Differential Revision: D17053118

fbshipit-source-id: 1ad6e9db7e6338165070c782ab9e7d2d600a62b7
2019-09-05 02:51:40 -07:00
Ram N
0e1c49b6b4 Use a stable sorting algorithm for network plugin
Reviewed By: danielbuechele

Differential Revision: D6982276

fbshipit-source-id: 7a3f01ccaa3557fab24d8a4937d9fb30cc012f20
2019-08-16 11:50:37 -07:00
John Knox
3bfb7faf0a Convert plugin.js to plugin.tsx
Summary:
* Deletes plugin.js
* Adds plugin.tsx
* Adds plugin flow-typed module that has the old flow types

Reviewed By: passy

Differential Revision: D16668067

fbshipit-source-id: b2f0ce47c4cf7125b4e352821e921b97675d12a9
2019-08-08 12:06:11 -07:00
Pascal Hartig
c588b650ae Prefer const wherever possible
Summary:
Non-final identifiers make code harder to understand.
This is particularly true for JavaScript where even the *type*
can change as a value gets reassigned later.

This enforces to use `const` whereever possible, but doesn't
"outlaw" `let`. Mixed destructuring is also still allowed.

Used `eslint --fix` to change all existing cases.

Reviewed By: jknoxville

Differential Revision: D16131329

fbshipit-source-id: 2eceaca7c603b71b36e005be5d135e1849f2518d
2019-07-10 03:28:25 -07:00
henry_zheng
1b3ae77c40 fix network stackoverflow #215 (#474)
Summary:
fixed issue: https://github.com/facebook/flipper/issues/215

## Changelog

1. use pako to inflate direct to unicode string to avoid 'stack size limit exceed' problem
Pull Request resolved: https://github.com/facebook/flipper/pull/474

Test Plan:
Tested with Meetup trace that crashes reproducibly without this fix:
{F165395994}

Tested gzipped body with fb4a:

{F165396053}

Reviewed By: jknoxville

Differential Revision: D16090209

Pulled By: passy

fbshipit-source-id: 64b8a61fa9d80d9e8b62105b3f1dc3289a29cc07
2019-07-04 05:15:22 -07:00
John Knox
9c99211221 Rename regexSupported to allowRegexSearch
Summary: This was annoying me so I thought I'd rename it before anyone else starts to use the prop.

Reviewed By: danielbuechele

Differential Revision: D15919159

fbshipit-source-id: c351503797cedc5c11a158cec62515b1eb791a70
2019-06-20 06:29:10 -07:00
Pritesh Nandgaonkar
3307576cb7 Use Buffer.bytelenght for calculating the length
Summary:
This diff fixes the bug which showed the length of characters as the byte length when the response headers didn't have `content-length` in it.

This diff uses `Buffer.bytelength` api to calculate the same.

Reviewed By: danielbuechele

Differential Revision: D15899547

fbshipit-source-id: 29f4e8a741f4dd550b9191cc31bf6930065653b3
2019-06-20 04:08:30 -07:00
John Knox
0e7aaaacff Add regex search to network plugin
Reviewed By: danielbuechele

Differential Revision: D15899077

fbshipit-source-id: 92f2edf31925d73be252128afa851bb3fcb633a5
2019-06-20 02:50:20 -07:00
Daniel Büchele
48b690169e Copy request details
Summary: Copying/Creating a Paste from a network request only copied the domain. Now we are including all request/response data.

Reviewed By: jknoxville

Differential Revision: D15898038

fbshipit-source-id: 570ca5bb76e65b90b2b467856e6d3747682cc20d
2019-06-19 09:00:59 -07:00
Arthur Kushka
1444946afa Added retries information to Insights tab of Networking plugin
Summary:
In React VR we doing automatic retries in cases when request takes too much time. It helps in cases when network quality is poor. As long as this implicit for developer, we would like to highlight this information in insights. It helps to explain why request were so long.

This diff adds one more field to insights which displays amount of time spent on retries, count and limit of them.

https://pxl.cl/CntV

Reviewed By: passy

Differential Revision: D15845598

fbshipit-source-id: 3e0d1baf93b6be5c4d1c6c1d2b64c05852b843b7
2019-06-17 03:05:40 -07:00
Arthur Kushka
1e700b944c Implemented insights tab in sidebar of networking plugin
Summary:
https://pxl.cl/Cd84

In React VR we got a case to explain developers why their requests took so long. To do this we export timings from Curl and send them in Flipper. This diff added visualization for this data. Any other platforms can use this feature by extending json which they send to Flipper.

Reviewed By: jknoxville

Differential Revision: D15804247

fbshipit-source-id: 9deea5c9f5f7c5416b42c476f7f0ed431c8dea04
2019-06-14 09:29:34 -07:00
Pritesh Nandgaonkar
38f3132b66 Fix the export metrics format
Summary: Fix the format of the export. Due to unknown reason the changes done in the D14933499 was [reverted back](https://our.intern.facebook.com/intern/diff/D14933499/?src_number=80619316) on the same diff. Thus this diff fixes the format of the metrics export

Reviewed By: passy

Differential Revision: D15239653

fbshipit-source-id: b9416f89e1b0022000d6201eb08ca1f456d5ed2e
2019-05-07 08:30:49 -07:00
Pritesh Nandgaonkar
afd729deb6 Added metrics argument to headless inorder to export metrics
Summary:
This diff makes headless flipper accept `metrics` argument. Once this is passed. The headless flipper will terminate to export the metrics of the plugins, the type of the export looks like the following.

```
export type MetricType = {[metricName: string]: number};
type MetricPluginType = {[pluginID: string]: MetricType};
export type ExportMetricType = {[clientID: string]: MetricPluginType};

```

This diff, uses the store to export the metrics. I will modify the logic to accept the data which gets exported through `exportData`

Reviewed By: passy

Differential Revision: D14933499

fbshipit-source-id: dade5b7bc59ea4beb6d16c5ef471737e8597358a
2019-04-25 07:41:34 -07:00
Benny Wong
d9d1346c12 Add copy as cURL for network requests (#415)
Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/415

This diff adds a context menu item for network request rows that allows the user to copy the request as a curl command. The logic for the command generation was inspired by [`FLEXNetworkCurlLogger`](https://github.com/Flipboard/FLEX/blob/master/Classes/Network/FLEXNetworkCurlLogger.m)

Resolves #406

Reviewed By: passy

Differential Revision: D14973754

fbshipit-source-id: a57c31190d7615ca5377308e0bfad521b645b2e4
2019-04-23 07:05:19 -07:00
Benny Wong
01e4d694b5 Refactor types and util functions
Summary: Separating out the types and utils for work I'm doing on https://github.com/facebook/flipper/pull/415 / D14973754. This will make the request to curl utility function much cleaner

Reviewed By: jknoxville

Differential Revision: D14976747

fbshipit-source-id: cc15c10103ea75945d0a2ebaaa6d32a376192961
2019-04-17 12:23:51 -07:00
Pascal Hartig
c244946be3 Catch malformed URI content
Summary:
As seen in https://our.intern.facebook.com/intern/bug/653953588368620/,
the network plugin can crash if content doesn't look like a URI.

Ideally, we'd be more granular in catching this, but for now skipping
that content seems better than crashing the entire plugin page.

Reviewed By: danielbuechele

Differential Revision: D14971610

fbshipit-source-id: 2708e5c0d4d1f584419d24c7dc38438009015565
2019-04-17 10:24:48 -07:00
Jiyue Wang
614f48dda3 Show server execution time in network plugin
Summary: the simpliest approach to render this metadata for debugging purpose

Reviewed By: bcuccioli

Differential Revision: D14974129

fbshipit-source-id: d816d1ef8dcd1bc333c4d0cdf70d6d9fb925bc03
2019-04-17 10:08:20 -07:00
JianyingLi
06e2379a78 Add contentType application/hal+json support
Summary: Pull Request resolved: https://github.com/facebook/flipper/pull/402

Differential Revision: D14663823

Pulled By: passy

fbshipit-source-id: 873a286f7d2e73c5cee4b9586adeadffa0292e43
2019-03-28 03:55:31 -07:00
JianyingLi
2564bce5a0 Fix DataInspector Component diff some problems. (#397)
Summary:
1. In `diffMetadataExtractor` function, when the `data` or `diff` is `null`, it diff view does not display correctly.

```jsx

<Panel floating={false} heading={'Test'}>
  <ManagedDataInspector
    diff={{
      auth: null
    }}
    data={{
      auth: {
        user: {
          name: 'JianyingLi'
        }
      }
    }}
    expandRoot={true}
  />
</Panel>
```

Before:
![2561552808023_ pic](https://user-images.githubusercontent.com/3889523/54486986-db383b80-48ca-11e9-9869-a008f72f4324.jpg)

After:
![2551552807969_ pic](https://user-images.githubusercontent.com/3889523/54486992-ea1eee00-48ca-11e9-90b0-7fd043f1c2bd.jpg)

2. Status `added`(green) and `removed`(red) should be the opposite

```jsx
<ManagedDataInspector
  diff={{
    user: {
      name: 'Leo'
    }
  }}
  data={{
    user: {
      name: 'JianyingLi'
    }
  }}
  expandRoot={true}
/>
```

Before:
![2591552808195_ pic](https://user-images.githubusercontent.com/3889523/54487019-35390100-48cb-11e9-8c20-1526aeae52a1.jpg)

After:
![2581552808145_ pic](https://user-images.githubusercontent.com/3889523/54487022-3c600f00-48cb-11e9-9ea9-75a8c8490c22.jpg)
Pull Request resolved: https://github.com/facebook/flipper/pull/397

Reviewed By: danielbuechele

Differential Revision: D14505757

Pulled By: passy

fbshipit-source-id: 35ca1bf8721468fdde13f3a9ede75cb72a59caea
2019-03-19 17:04:15 -07:00
Daniel Büchele
2c05fdf347 correctly handle gzipped unicode fixes 394
Summary:
For gzipped requests, the decoding of unicode characters was failing, because it was was done, before decompressing the response payload.

In this diff, the payload is first decompressed and decoded afterwards. For the calculation of the response size, this is removed, because it doesn't matter for the calculation of the size to correctly decode unicode characters. However, there might be a problem with displaying the correct size. This is tracked in T41427687.

Reviewed By: jknoxville

Differential Revision: D14366841

fbshipit-source-id: e375df1ec44505f6315dedbe71b3b62eac0f281a
2019-03-07 10:08:29 -08:00
Pascal Hartig
83c9d3399f Add missing title attributes
Summary:
Extended the linter to check for the title attribute, too, and fixed
all violations. Linter will follow in next diff.

Reviewed By: jknoxville

Differential Revision: D14366410

fbshipit-source-id: b4de3592f2537e2bb16d4c2af231e5bee45346e4
2019-03-07 09:44:25 -08:00
JianyingLi
f4b2ce9a2b Support Chinese characters
Summary: Pull Request resolved: https://github.com/facebook/flipper/pull/377

Reviewed By: passy

Differential Revision: D14299674

Pulled By: danielbuechele

fbshipit-source-id: 6b10370a4a367ae6e58415b8eeb5aef0864354f4
2019-03-04 05:16:00 -08:00
John Knox
d5dc3f9c2a Add timestamp columns to network inspector
Summary: Adds requestTimestamp, and responseTimestamp which is hidden by default.

Reviewed By: passy

Differential Revision: D14088403

fbshipit-source-id: c451a428d8068c5bfce199cda5502361c12d1667
2019-02-15 04:57:38 -08:00
Daniel Büchele
1fc73ad2fb update plugin's package.json
Summary:
For all plugins:
- move static fields `title`, `id` and `icon` to `package.json`
- adds "bugs" field for all plugins containing links to support groups/oncalls.

Reviewed By: priteshrnandgaonkar

Differential Revision: D13417286

fbshipit-source-id: 7b341176915f3ed7b473b95c1d879f21d7d634ef
2018-12-18 10:36:35 -08:00
John Knox
bbdbb94415 Fix network plugin bug
Summary:
Some network requests are yielding error: e.getMessage() is not a function.
It shouldn't be .getMessage(), it should be .message

Reviewed By: priteshrnandgaonkar

Differential Revision: D13137334

fbshipit-source-id: 72c782376c8e62a05c5e9ce1b956566ce1fc5bf0
2018-11-20 06:43:58 -08:00
Daniel Büchele
bf7c35387c Report notifications not useful
Summary:
* adds a button to hide notifications by category
* adds a quick action to report notifications as not helpful
* fixes type of network plugin's notifications to be string instead of number

Reviewed By: jknoxville

Differential Revision: D12999883

fbshipit-source-id: 32be5bde5931cca4a27ab1ad34418300196452cc
2018-11-12 01:49:48 -08:00
John Knox
bdc3abacbd Isolate BodyFormatter exceptions
Summary: If one throws an exception, we'd skip all the other ones. I don't think that's the behaviour we want.

Reviewed By: passy

Differential Revision: D12958926

fbshipit-source-id: dd82b750197b6fc1380496be4147fe63454d39da
2018-11-07 10:35:38 -08:00
Sveinung Bakken
a56d7d5d72 Add HTML formatter to Network plugin
Summary:
Currently HTML renders as a blank response panel which is not helpful for seeing erros.
Adding a formatter for `text/html` so we can see error responses, or other HTML responses, correctly.

Note, this adds the xml beautifier package from npm.

Reviewed By: danielbuechele

Differential Revision: D12883274

fbshipit-source-id: c49b60984f10bba471b5bbb8aabcb385a171d0d6
2018-11-07 08:51:45 -08:00
Daniel Büchele
8ab52839fb UI fixes
Summary:
This is a collection of small UI fixes for the network plugin:

- image maxWidth is set to 100% to not cause vertical scrolling
- Panels now have horizontal scrollbars, if their content overflows
- fixing missing icon for failed network requests
- removing position sticky from table headers as it was not used and causing some rendering issues and performance problems
- Adding a `label` and `grow` option to the `Select`-component which is used in the sidebar of the network plugin.

Reviewed By: passy

Differential Revision: D12956336

fbshipit-source-id: 6e7e9cf97c058a2ff626576d4afdc6df65007ea1
2018-11-07 06:27:33 -08:00
Jiyue Wang
f88aa99d2a Show the streaming response correctly in Flipper
Summary: make Sonar network tab work nicely with GraphQL streaming response

Reviewed By: danielbuechele

Differential Revision: D12841335

fbshipit-source-id: efcae3428c42957cbce27d467180ccbc10dc2ae9
2018-10-31 08:07:54 -07:00
Daniel Büchele
086ab0188b rename fill attribute
Summary:
We were using `fill={true}` as an attribute to make flexbox containers fill the entire available space.

However, `fill` is an HTML attribute (see: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill) This caused warnings printed to the console.

This diff renames the attribute to `grow` with is also more in line with the Flexbox terminology.

Reviewed By: priteshrnandgaonkar

Differential Revision: D10488389

fbshipit-source-id: ed8553c6203cdf6df94d26c731164ecec4c9fbd2
2018-10-22 09:54:59 -07:00
Daniel Büchele
61d80b4bb9 network deeplink
Summary: Deep link from the QPL plugin into the network plugin

Reviewed By: passy

Differential Revision: D10462528

fbshipit-source-id: cc044863191fc4375390165f6b7b7d5c5e9c77e3
2018-10-19 08:39:51 -07:00
Daniel Büchele
a8a512fe44 network defaultPersistedState
Summary: using defaultPersistedState in network plugin to remove unnecessary null check

Reviewed By: passy

Differential Revision: D10446988

fbshipit-source-id: b0290e4b678c36c031ecd0fba88cdb9add24b46e
2018-10-19 05:14:17 -07:00
John Knox
d48f93edea Add method field to persistedStateReducer
Summary:
When sending a message from the mobile side, you call something like:

`send(method: string, params: Object)`

But when receiving it in the reducer, you only get the params. Adding method so you can distinguish them.

Reviewed By: passy

Differential Revision: D10447890

fbshipit-source-id: f1fe925e82355866f86b322ecd3c72c604ae86af
2018-10-19 03:37:59 -07:00
Daniel Büchele
f973bdd455 add notification API to network plugin
Summary: Trigger notifications for all network requests having an error status code.

Reviewed By: passy

Differential Revision: D10401402

fbshipit-source-id: 8fa63cbc251457142abd71845fb6f1c735b247cc
2018-10-18 02:47:53 -07:00
Daniel Mueller
12a2c0ee70 Add option to display network response as copyable json
Summary: This is meant to reduce the friction of getting network response payloads. Simple switch allows developers to go to "formatted" body ui which shows the json in a text blob.

Reviewed By: passy

Differential Revision: D10378877

fbshipit-source-id: 87aeff5318f0c2c6d3d91d7e3b491595794e69bf
2018-10-16 03:55:43 -07:00
Pascal Hartig
01020edbf2 Restore computeNotifications
Summary:
Restore the logic for setting and computing notifications that was
partially removed with D10300838.

Reviewed By: jknoxville

Differential Revision: D10361547

fbshipit-source-id: 4d229d5f4dbeda3139463e1c348909b9c5dba66f
2018-10-13 04:18:11 -07:00
Pritesh Nandgaonkar
396e385651 Handle empty state for background plugin
Summary: Handles the case when persisted state is undefined which will be the case when the initially selected plugin is not the one running in background

Reviewed By: danielbuechele

Differential Revision: D10269073

fbshipit-source-id: b7a17b0daa37a486cc7f456338cb97123ad813b7
2018-10-11 15:23:22 -07:00
Pritesh Nandgaonkar
5adc0d0625 make network plugin running in background
Summary: implements `persistedStateReducer` for the network plugins to merge messages into the persistedState even when the plugin is not running.

Reviewed By: danielbuechele

Differential Revision: D10256311

fbshipit-source-id: 53011a2123342825e8404b1c2c798aeb550c596d
2018-10-11 15:23:22 -07:00
Daniel Büchele
78252b2ef2 adding UI
Summary:
- Adds the Flipper notifications UI from the hackweek
- The notifications plugin is hidden behind a GK `flipper_notifications`
- Plugins currently can not dispatch any notifications

Reviewed By: jknoxville, passy

Differential Revision: D10300838

fbshipit-source-id: 2a3a823f09fee3370ce725b506b162e57751c382
2018-10-10 10:41:09 -07:00
John Knox
49e7f2dc8b Add notifications for failed network requests
Summary: Also acts as a model for using the computeNotifications api.

Reviewed By: passy

Differential Revision: D10240659

fbshipit-source-id: 610512de7484e10c9c0ed8e661913c2fe10869da
2018-10-09 08:27:06 -07:00
Daniel Büchele
df0a0da744 DetailSidebar
Summary:
- rename `SonarSidebar` to `DetailSidebar`
- rename portal id from `#sonarSidebar` to `#detailSidebar`

Reviewed By: passy

Differential Revision: D9851703

fbshipit-source-id: 2d904d17b0c6255a2ec3a79f0ada9bf621693c2e
2018-09-18 07:01:16 -07:00
Daniel Büchele
3bea3c88e6 flipper-plugin-*
Summary: rename plugin packages from `sonar-plugin-*` to `flipper-plugin-*`.

Reviewed By: passy

Differential Revision: D9851211

fbshipit-source-id: bdac568ede0a4a9308138a6c3d60728bb6195a72
2018-09-18 07:01:16 -07:00
Daniel Büchele
66e77075be Rename package to 'flipper'
Summary:
- rename package `'sonar'` > `'flipper'`
- rename package `'sonar-static'` > `'flipper-static'`
- rename package export from `window.Sonar` to `window.Flipper`

Reviewed By: passy

Differential Revision: D9851181

fbshipit-source-id: 34d4447c3b287496b3d20ddb54471ce777ec74e1
2018-09-18 07:01:16 -07:00
Daniel Büchele
2e2924c979 SonarPlugin > FlipperPlugin
Summary:
Renaming:
- `SonarPlugin` > `FlipperPlugin`
- `SonarBasePlugin` > `FlipperBasePlugin`
- `SonarDevicePlugin` > `FlipperDevicePlugin`

Reviewed By: passy

Differential Revision: D9851075

fbshipit-source-id: d59df6952a42eb493c86c38895216c9985f1e14b
2018-09-18 07:01:16 -07:00
Daniel Büchele
726966fdc0 convert to emotion
Summary:
My benchmarks have shown react-emotion to be faster than the current implementation of `styled`. For this reason, I am converting all styling to [emotion](https://emotion.sh).

Benchmark results:
{F136839093}

The syntax is very similar between the two libraries. The main difference is that emotion only allows a single function for the whole style attribute, whereas the old implementation had functions for every style-attirbute.

Before:
```
{
  color: props => props.color,
  fontSize: props => props.size,
}
```

After:
```
props => ({
  color: props.color,
  fontSize: props.size,
})
```

Reviewed By: jknoxville

Differential Revision: D9479893

fbshipit-source-id: 2c39e4618f7e52ceacb67bbec8ae26114025723f
2018-08-23 09:42:18 -07:00
Arvind Menon
c8c2cfa16f Ignore header case to determine if content is gzipped (#143)
Summary:
This PR updates the Network plugin's response parser to ignore the case of the `Content-Encoding` header in the response. This was preventing responses that are gzipped from being uncompressed. I tested this with gzipped responses through the OkHttp interceptor on Android. This could potentially address #79 as I was experiencing that issue before this change.

![sonar](https://user-images.githubusercontent.com/1328587/42414919-284b80bc-8238-11e8-8cf9-d9e9b9bea133.jpg)
Pull Request resolved: https://github.com/facebook/Sonar/pull/143

Differential Revision: D8780509

Pulled By: danielbuechele

fbshipit-source-id: 1a2d86226a8a0204ff43eb5f9394a56c04fd2d8d
2018-07-10 06:17:28 -07:00
Daniel Büchele
c239fcac01 persist network plugin state
Summary:
This saved the state of the network plugin even when switching between plugins using persistedState.
A bug in the Android implementation didn't clear the events that were already sent to the desktop.

Reviewed By: jknoxville

Differential Revision: D8752098

fbshipit-source-id: 152ec5da83958ad8124686f780d39983cbce563f
2018-07-10 02:33:51 -07:00