Commit Graph

311 Commits

Author SHA1 Message Date
Daniel Büchele
771be72b3f remove window dependency
Summary:
Fixes required to be able to run Flipper in node.js:
* Adds checks if the `window`-object exists before using it, to allow running in node.
* Imports from within Flipper should directly reference the file they are requiring instead of `import from 'flipper'`. This was done in most of the places. Fixed a few occurrences where this wasn't the case. This is to prevent cyclic dependencies in node.
* shared packages (React, ReactDOM and Flipper) were exposed on the `window` before, changed this to `global` as this works in browser and node.
* Adds some missing methods to our electron stubs (used for testing and headless Flipper)

Reviewed By: passy

Differential Revision: D13786577

fbshipit-source-id: 145d560f1446e7d0bdec2acd8dd54dae983d7b36
2019-01-25 12:19:07 -08:00
Pritesh Nandgaonkar
978b14c3d3 Append and show errors which are caused due to jni/native crashes
Summary:
Before this diff, the crash reporteer plugin for android just used to show messages which were error and had tag as "AndroidRuntime". This diff fixes this and instead accepts multiple different tags which might be related to crashes.

The issue with triggering the notification for all kind of messages would be that, the user might get many. For the jni errors, the stack trace of it are shown as multiple entry instead of one entry in logcat. So to combine all the stack trace into one callstack message, this diff adds a timer of 10ms and combines the messages which occur in that timespan and then trigger the notification.

Reviewed By: danielbuechele

Differential Revision: D13772505

fbshipit-source-id: fec6f5a7f9f46948c9f9dc5b2a7b92690913c8aa
2019-01-25 09:52:43 -08:00
John Knox
dcfa412080 Explicitly start adb server
Summary:
We've only got about a 75% success rate at initializing an adb client: https://fburl.com/scuba/tr5tkehi

This is the second attempt to fix this. The first one D13487864 was reverted because it used 'adb' instead of the full path, and when run as a GUI app, you don't get the PATH variable typically set up in .bashrc files etc.

Fixing it by using the full $ANDROID_HOME path.

For facebook users, this will always be guessed correctly, but for OSS it could be installed anywhere, so we might get it wrong - it's common for $ANDROID_HOME to not be set at all on mac systems, and setting it for GUI apps is not exactly trivial: https://superuser.com/questions/476752/setting-environment-variables-in-os-x-for-gui-applications

Leaving the previous implementation as a fallback for OSS users and in case this method fails for some reason.

Metrics wrapped around each implementation as well as the entire thing, so we can see if it solves the issue.

Reviewed By: passy

Differential Revision: D13818981

fbshipit-source-id: d90bfd9ec80621526accc080778afc44f2a099d9
2019-01-25 09:34:50 -08:00
John Knox
dbb723f8a5 Add FLIPPER_PORTS env var to desktop app
Summary:
Part 3 and final part of adding customizable ports. To use this, the iOS / Android apps have to also be started with the same custom ports.

Example usage: `FLIPPER_PORTS=8189,8188 yarn start`

Reviewed By: passy

Differential Revision: D13801761

fbshipit-source-id: 3dd80a3001ed0855e54cc568fa94eb6fac5fc7f1
2019-01-25 07:24:13 -08:00
John Knox
c68e74c6a0 Fix server.device.js test
Summary:
After the LogManager interface change this file wasn't updated.
The test isn't enabled at the moment, but I don't know why flow didn't notice this.

Reviewed By: passy

Differential Revision: D13783861

fbshipit-source-id: 09d887f6567300aa9a16ec2a97b17a2d9de338d1
2019-01-23 09:08:38 -08:00
John Knox
e36b5d1ceb Fix flipper_errors_raw pipeline
Summary:
It turns out puma was erroring on the GK field inside the log json, because of improperly escaped " in the fields.

To simplify it I'm changing it to use simple comma separated key:value pairs, since they are always plain string and boolean values.
"gatekeepers":"TEST_PASSING_GK:false,TEST_FAILING_GK:false,devtools_sonar_team:false"

Reviewed By: passy

Differential Revision: D13782283

fbshipit-source-id: 3f331dc9189b1a57f69a2af0d4393baf45e1fa55
2019-01-23 06:55:30 -08:00
John Knox
ecd6935d18 Promisify server starting
Summary:
We had a promise for initializing the servers, but it wasn't rejected when server startup failed.
Fixed by resolving / rejecting based on the listen / error events fired from the server.

Reviewed By: passy

Differential Revision: D13762580

fbshipit-source-id: a0d1a56473f84dc416e5ce2de91a53b21574f452
2019-01-23 05:18:31 -08:00
John Knox
eeb40b5944 Record success rate of screenshot capture
Summary: Android and iOS each have a separate metric

Reviewed By: passy

Differential Revision: D13763758

fbshipit-source-id: f679360ec0ee008b434bfe12107ac6548d882a1f
2019-01-22 10:51:22 -08:00
Pascal Hartig
51ab27456a Add basic TitleBar test
Summary: Manually checked that the snapshot doesn't contain the auto updater.

Reviewed By: jknoxville

Differential Revision: D13715520

fbshipit-source-id: 720fed1e9952b788bce3311ecb508cfcfdc1758a
2019-01-18 08:57:18 -08:00
John Knox
dfe956ab39 Fix RecurringError::toString
Summary: RecurringError::toString wasn't including the message. Fixed.

Reviewed By: passy

Differential Revision: D13732258

fbshipit-source-id: 71f5edef19de4e59d1c6c5bd549822871e36ede4
2019-01-18 08:32:02 -08:00
Pascal Hartig
82f4d4ad95 Add --no-updater flag
Summary: Provide a `--no-updater` option that disables the in-app auto updater when passed.

Reviewed By: jknoxville

Differential Revision: D13713919

fbshipit-source-id: 49a647105fea1efa23f653e4a6ed452b3489879b
2019-01-18 08:01:05 -08:00
Pritesh Nandgaonkar
87f64c4535 Send crash notification when flipper cpp exceptions are suppressed
Summary: This diff adds support to send crash notification whenever the cpp exception of Flipper is suppressed. Also updated the tests regarding the same

Reviewed By: jknoxville

Differential Revision: D13635822

fbshipit-source-id: 01e4a57c391476e5b044e64946d337cb4582a527
2019-01-17 16:47:35 -08:00
John Knox
944a197cf6 Add GKs to logs and error reports
Summary: To allow comparisons between metrics/errors in and out of GKs.

Reviewed By: passy

Differential Revision: D13714754

fbshipit-source-id: 311a1cd7bd5a7b2332e20a32d37d0fb323d00569
2019-01-17 11:22:01 -08:00
John Knox
21dfe41fb4 Add sessionId to error messages
Summary: Will allow us to look into bad sessions if necessary.

Reviewed By: passy

Differential Revision: D13695386

fbshipit-source-id: 2cfc8ec28ef4cb387ef7a5a58b02aa77a367ae81
2019-01-17 03:43:16 -08:00
Daniel Sainati
9b985b1338 remove deprecated utilities
Summary: Remove `$Subtype` and `$Supertype` utilities. Replacement was done on a best-effort basis. In many cases it sufficed to replace `$Supertype<T>` and `$Subtype<T>` with `T`, but when this was not possible `any | T` and `any & T` were used instead.

Reviewed By: jbrown215

Differential Revision: D13624765

fbshipit-source-id: 82ee9d43cfc318ed4bd2d84e0f4c5c1d8f488a9c
2019-01-15 13:58:53 -08:00
John Knox
a254cef98d Add metrics for server cert generation and server start
Summary: Will provide some visibility on error rates.

Reviewed By: passy

Differential Revision: D13671492

fbshipit-source-id: 60971a7e8163c58dd4d6540e57e05b38c852744e
2019-01-15 09:46:11 -08:00
John Knox
7120bf1201 Use global logger in InteractionTracker
Summary: This tracker isn't really used, but at least now it can benefit from having the sessionId.

Reviewed By: passy

Differential Revision: D13671367

fbshipit-source-id: 3a79e843e3fabab191d0d7471d56a81b1a91a1e9
2019-01-15 09:46:11 -08:00
John Knox
3bcb079f87 Define global logger instance to be used for all logging
Summary:
The advantage of this is that anyone can now log without needing to carry around a Logger object.
Primary reason is for making metrics less intrusive in the codebase.

Reviewed By: passy

Differential Revision: D13671368

fbshipit-source-id: 162ab1351a124683aef13983fc3bcec01385cd1a
2019-01-15 09:46:11 -08:00
John Knox
f85dc14d07 Record success metric for adb client start
Summary: We've seen some flakiness here, so adding this to get better visibility on it.

Reviewed By: passy

Differential Revision: D13635051

fbshipit-source-id: 98d2dcc0bb11f3afb2f27942b9f4bf241808a4fc
2019-01-14 06:29:57 -08:00
John Knox
90de3c6868 Add recordSuccessMetric utility
Summary: Wraps a future and records the success rate. This will be stored along with the sessionId and the userId, so we can drill down and get the success rate at different levels.

Reviewed By: passy

Differential Revision: D13635049

fbshipit-source-id: 4e0e6bdc0f9b76b08cf37c5d9fe87909f7338534
2019-01-14 06:29:57 -08:00
John Knox
4a5dae8f4f Try out success rate metric on processing CSRs
Summary:
This is semi-explorative to see how far we can get with this approach, but I think it'l be useful. If it is, we can factor the code into a nicer utility, that perhaps wraps promises or even just has succeeded/failed methods.

Using 1 and 0 instead of true and false so we can do numerical aggregates on it, like average, which will give the success rate.

This will allow queries such as:
* What percentage of attempts fail? - Not very useful because they get retried if they fail.
* What percentage of sessions that attempt, encounter a failure? - More useful, but still not perfect because they could retry and succeed.
* What percentage of sessions attempt and don't ever succeed? - Better but still not perfect because one device might succeed and another fail, but this will be rare.

Reviewed By: passy

Differential Revision: D13625987

fbshipit-source-id: 2b9f45cc888247d068cc52281443e9ece7985da8
2019-01-11 03:57:47 -08:00
John Knox
005383f94b Add sessionId to redux store and Logger output
Summary:
I've left InteractionTracker without a store, so it doesn't know the sessionId. It really should have one, but that will have to be a different change.
We don't actually use the InteractionTracker at the moment so it's not a major deal for now.

The idea is to be able to get data like what percentage of sessions encounter an error, and how many errors sessions usually have etc.

Reviewed By: passy

Differential Revision: D13624031

fbshipit-source-id: 664e7ac5023166c2f72df3058c219901be7ff77a
2019-01-11 03:57:47 -08:00
Daniel Tse
0033de50ae Fixed typos in Flex* component documentation
Summary: Typos.

Reviewed By: danielbuechele

Differential Revision: D13625458

fbshipit-source-id: a2885fda1a27ab5c305445d54e1221cec215a16b
2019-01-11 02:58:16 -08:00
Pritesh Nandgaonkar
3b9253680f Refactor the type of os from String to an closest enum kind of thing
Summary: This diff updates the type of os in Store from string to a custom enum kind of type.

Reviewed By: passy

Differential Revision: D13622598

fbshipit-source-id: c57a1f2eedbe9e88d43c681c2fa6ca72b93e8808
2019-01-10 09:55:47 -08:00
Daniel Büchele
d868cd6405 PluginDebugger correct pluginPath
Summary:
The path where a plugin was loaded from was not displayed correctly before, but pointed to Flipper's cache directory.

Plugins that are bundled with Flippers application package are now marked as bundled. Dynamically loaded plugins show the path where they are loaded from.

Reviewed By: passy

Differential Revision: D13622148

fbshipit-source-id: 7951ecd37e45d2d4b3a55bd7dc126697367c7e69
2019-01-10 07:16:45 -08:00
Pritesh Nandgaonkar
972f8b91d6 Update logic to parse crash for android
Summary:
Updated the logic of parsing the crash log. Earlier the function written to parse crash log just expected the iOS crashes. Now it also gets android crash logs.

I have also written the tests for the same and updated the tests to accommodate for the API change

Reviewed By: passy

Differential Revision: D13612576

fbshipit-source-id: cf7e9d2bca4a425ad7338fc5ec15e29cf88e2e77
2019-01-10 06:36:39 -08:00
Daniel Büchele
cc0615c7d9 Sort plugins by name
Summary: Sort plugins in sidebar by name (or ID as fallback).

Reviewed By: passy

Differential Revision: D13621422

fbshipit-source-id: dd264bde64409a2cd81caa0b41af81bf614f9e62
2019-01-10 03:50:51 -08:00
Daniel Büchele
384529e97f Sheet component for plugins
Summary:
Exposing a `<Sheet>` component to plugins. This allows plugins to create sheets, by returning something like this from their render function:

```js
return <div>
  contents of my plugin
  <Sheet>{() => <div>content of my sheet</div>}
</div>
```

Reviewed By: passy

Differential Revision: D13597251

fbshipit-source-id: 9da6ba6d2036243ddd2d05b73d392bf24be8d375
2019-01-09 10:48:18 -08:00
Pritesh Nandgaonkar
0048fc6e4a Crash reporter plugin
Summary: This diff adds a static function `onRegisterDevice` which is being called whenever an  device gets registered. This callback is used to add loglisterner for android. I even moved the logic of iOS from `onRegisterPlugin` to this callback. The reason for not adding android log listener in `onRegisterPlugin` was that there were cases when baseDevice was not yet registered before calling `onRegisterPlugin`. For android, I want the instance of `BaseDevice` so that I can add logListener on it.

Reviewed By: danielbuechele

Differential Revision: D13563282

fbshipit-source-id: b5be40f3dbc808bdaeabae28423c563cf2345a22
2019-01-09 10:42:55 -08:00
Daniel Büchele
422ab99d29 no client/device
Summary:
Plugin debugger is now supporting 3 different scenarios:
- no devices connected
- device connected, but no app for the selected device is connected
- apps are connected

Added button to the sidebar to open plugin debugger.

Reviewed By: passy

Differential Revision: D13608749

fbshipit-source-id: d5ba04882590dace78e4ef0b17799d5a394dc3c4
2019-01-09 10:05:26 -08:00
Paulo Pinheiro
a033f583d1 Enable override of context menu on ManagedTable. (#352)
Summary:
This patch add a new prop on ManageTabled called buildContextMenuItems. It allows
to override the current context menu when right click on the ManagedTable rows.
Pull Request resolved: https://github.com/facebook/flipper/pull/352

Reviewed By: danielbuechele

Differential Revision: D13590258

Pulled By: passy

fbshipit-source-id: a90887a97136818611102a2628361c84988efeac
2019-01-09 03:52:56 -08:00
Pascal Hartig
7471dc6481 Fix emulator launching on Linux
Summary:
The Android SDK installation on Linux is really dumb. The emulator binary
is dynamically linked and ships with some `.so`s that need to be either in `LD_LIBRARY_PATH` or `$CWD`.
For some reason, there's no script, so you have to manually `cd` into the directory in order to
run it. ¯\_(ツ)_/¯

Reviewed By: jknoxville

Differential Revision: D13589660

fbshipit-source-id: e3bdd7468108f1fb1e52f23ae45e21cacc5480f9
2019-01-07 07:47:17 -08:00
Pritesh Nandgaonkar
470c770e97 Back out "[flipper] Explicitly start adb server"
Summary:
Original commit changeset: b1eae542aaa6

 This D13487864 has broken `adb start-server` command for the production builds, thus this diff backs out the changes done by that diff.

Reviewed By: danielbuechele

Differential Revision: D13532003

fbshipit-source-id: 1d169dcdab11a52f075187803219915f444952d6
2018-12-21 07:24:27 -08:00
Pritesh Nandgaonkar
9d4bb45dbc Refactor CrashReporter plugin
Summary: This diff refactors CrashReporter Plugin. The business logic of crash reporter plugin was placed in the `iOSDevice.js` as it gets the hook to the initialisation of iOSDevice. This diff moves the business logic to the Crash Reporter plugin files under the plugins folder. To get the hook, so that we can add our watcher, I have added a static function over `FlipperBasePlugin`, which if exists, will be called once `REGISTER_PLUGIN` event is dispatched

Reviewed By: danielbuechele

Differential Revision: D13529035

fbshipit-source-id: 28216b273b4032727859107d8a6751c6465af9ac
2018-12-21 07:03:21 -08:00
Daniel Büchele
780ac863b8 Adding PluginDebugger sheet
Summary: Adding a PluginDebugger that gives the user some information why a plugin might not be loaded.

Reviewed By: jknoxville

Differential Revision: D13465143

fbshipit-source-id: f5d7037850874ca9545ac1523fb4e0f18ede7273
2018-12-20 06:14:35 -08:00
Daniel Büchele
fa9b85b065 showing multiple sheets
Summary:
The sheet was only used for the bug-reporter before and we had an explicit boolean flag in the redux store to keep track if the bug reporter is shown.

Changing this it an `activeSheet` property, which allows us to show arbitrary sheets, while making sure to only show one at a time.

Reviewed By: jknoxville

Differential Revision: D13516985

fbshipit-source-id: 3e83f719e2b61d0b2229268ebfdc910123b403d2
2018-12-20 06:14:35 -08:00
Daniel Büchele
6827515329 storing information about failed plugins
Summary:
If a plugin was not loaded we used to ignore it. This diff still ignores the plugins that weren't loaded, but adds some information about them to the redux store. This information is used in the PluginDebugger.

These are the three reasons, why a plugin might not be loaded.

* `gatekeepedPlugins`: Plugin was ignored because of a GK
* `failedPlugins`: Plugin could not be requried/failed to parse
* `disabledPlugins`: Plugin disabled in `~/.flipper/config.json`

Information for each them is added to the redux store.

Reviewed By: passy

Differential Revision: D13516986

fbshipit-source-id: b7a55a159cb586d1a88fbb976248131c52a909c5
2018-12-20 06:14:35 -08:00
Pritesh Nandgaonkar
9748aba878 show crash notifications only for a particular device
Summary:
Before this diff we used to show crash notifications for all kind of crashes. This diff adds the check, which makes sure that only the crashes of a selected device is shown

Also added tests and updated few tests

Reviewed By: danielbuechele

Differential Revision: D13518019

fbshipit-source-id: 6d640d078a43480274242a5d86f2d135d875d630
2018-12-20 05:21:37 -08:00
Daniel Büchele
20e636865c generic Sheet component
Summary: this moves the `Sheet` into its own component, so it can be reused for other places than the bug reporter.

Reviewed By: passy

Differential Revision: D13468275

fbshipit-source-id: 5f6d07a54dda078bd08a4c4cd31a41c61b58a76f
2018-12-19 09:06:44 -08:00
Pritesh Nandgaonkar
ade6eabdb0 Fix the regressed deeplink support for crash reporter plugin
Summary: The deeplink from crash notification to crash reporter plugin was broken. It always showed the latest crash.With this diff the crashreporter plugin shows the correct crash information.

Reviewed By: danielbuechele

Differential Revision: D13487792

fbshipit-source-id: eee6826bb0a84d0aab9b432a1c9a04aa7d528402
2018-12-19 07:01:09 -08:00
Pritesh Nandgaonkar
3135c99cc5 Fix crash reporter plugin test
Summary: The test were broken, as the `CrashReporterPlugin.id` was empty. This value is populated when plugin is loaded, thus added a helper function for that. Also removed a duplicate test.

Reviewed By: danielbuechele

Differential Revision: D13517063

fbshipit-source-id: ffb99316933cd27068c6bce67cfa6e95633b6246
2018-12-19 06:33:29 -08:00
Pritesh Nandgaonkar
a12768539e Crashreporter plugin by adding a watchman for crash log
Summary:
This diff adds a watcher on `~/Library/Logs/Diagnostics/` library and fires a notification whenever a crash log is added there. This will only work for iOS crashes. With this change, for iOS we should be able to see all kind of crash notification be it due to uncaught exception or a native crash or signal errors.

For android, it will still show notifications due to uncaught exceptions. In upcoming diffs, I will change the logic for android too by parsing Logcat logs.

This diff doesn't support physical device crash reporting. The crashes for physical devices are synced to other folder and that too they are symbolicated.

Reviewed By: danielbuechele

Differential Revision: D13404648

fbshipit-source-id: 7219855ebc73451af87f77f90cc3ed0f2ab5287c
2018-12-18 13:42:40 -08:00
Pritesh Nandgaonkar
e3fb1e1d84 Disable crash reporter plugin for iOS and update callstack from array to string
Summary:
This diff does the following

- Comments out the code in iOS which sends the message to the desktop side
- Also comments out the part where signal handler is initialised, as we no longer need it. I will remove the iOS implementation completely in next few diffs
- Updated the JS side to expect call stack as a string instead of an array
- Updated the android side to send callstack as a string

I have commented out the code for crash reporter plugin of iOS as for iOS I will be adding a watchman  to a directory where crash logs are dumped. The diff related to this is in the stack

Reviewed By: passy

Differential Revision: D13424824

fbshipit-source-id: b1105da912292bf73cff948206c031de9b059abd
2018-12-18 13:42:40 -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
Daniel Büchele
c9b982b182 revamp UI + show oncall/group
Summary:
Redesigns the bug reporting dialog:
- show information from `package.json`'s `bugs` field, where we can link to support groups or name oncalls.
- adds show/hide animation
- uses new button style

Reviewed By: jknoxville

Differential Revision: D13417287

fbshipit-source-id: 2948794e9b1f42bbd895981d5e4b0578a9b8ee2e
2018-12-18 09:34:52 -08:00
Daniel Büchele
c540fe5529 adding primary and compact buttons
Summary: Adding a style for `primary` buttons

Reviewed By: priteshrnandgaonkar

Differential Revision: D13417284

fbshipit-source-id: 8ef46092d79ee0f9d39167aa2662a84caca9aa11
2018-12-18 08:37:28 -08:00
Daniel Büchele
6ffc027051 read infos from package.json
Summary:
Adding the properties from a plugin's `package.json` as static properties to the class.
The name from `package.json` is used as it's `id`.

This allows us in the future to add meta information about a plugin to it's package.json and still use the data inside the app.

Reviewed By: priteshrnandgaonkar

Differential Revision: D13417288

fbshipit-source-id: 3d0a62d4cb0115153cce1aaee677b9680fefebf4
2018-12-18 08:37:28 -08:00
Pascal Hartig
ee0b640c30 Fire-and-forget for openFile
Summary:
`xdg-open` is blocking on Linux. That means we won't do our cleanup steps
(or reset the button for that matter) until the user closes their viewer app.

This changes the call to be a `spawn`, so we can continue the chain. As no
one had actually used the value captured in the promise, this shouldn't
make a difference API-wise.

Reviewed By: danielbuechele

Differential Revision: D13465571

fbshipit-source-id: 5f698916157906d76ab983109deb9abe142baa9e
2018-12-18 03:18:21 -08:00
Pascal Hartig
4cb82c1f1d Avoid media indexing on Android
Summary:
Record Android screen captures into a separate directory with a `.nomedia`
file to avoid it from getting indexed before it gets removed after being
pulled.

Reviewed By: danielbuechele

Differential Revision: D13465448

fbshipit-source-id: 4449ff3a927cc8621b015b018d2b743cedc4ce8c
2018-12-18 03:18:21 -08:00
John Knox
cc5fba6975 Explicitly start adb server
Summary: We were relying on adbkit to do this, implicitly by calling listDevices(). However, this doesn't appear to be reliable, with retries, it usually succeeds, but sometimes still doesn't. I'm aiming to avoid all this entirely by just starting it directly using adb itself, which I expect to be much more reliable.

Reviewed By: danielbuechele

Differential Revision: D13487864

fbshipit-source-id: b1eae542aaa6ecb2b74b575a3582934093ccd588
2018-12-17 11:08:29 -08:00