setup.mdx (SetUp - Crash Reporter and Images)

Summary:
Restyle of pages, including changes to spelling, grammar, links, and structure (where relevant):

Crash Reporter
Images

Reviewed By: lblasa

Differential Revision: D36316967

fbshipit-source-id: aa91459f858e650cb7195436f94239e630373747
This commit is contained in:
Kevin Strider
2022-05-12 07:54:19 -07:00
committed by Facebook GitHub Bot
parent afcc695edf
commit 16a0a27672
2 changed files with 21 additions and 20 deletions

View File

@@ -1,11 +1,17 @@
import useBaseUrl from '@docusaurus/useBaseUrl'; import useBaseUrl from '@docusaurus/useBaseUrl';
import Link from '@docusaurus/Link'; import Link from '@docusaurus/Link';
You do not have to instantiate it in your app in order to use its basic functionality mentioned <Link to={useBaseUrl("/docs/features/plugins/crash-reporter")}>here</Link>. You can also use crash reporter plugin to send the notifications for the exception which you suppress in your Android application. You could even use it to send the notifications when the [Litho Error Boundary](https://fblitho.com/docs/error-boundaries) is triggered. In order to send your custom notification you will have to follow the following steps. You don't have to instantiate the <Link to={useBaseUrl("/docs/features/plugins/crash-reporter")}>Crash Reporter plugin</Link> in your app in order to use its basic functionality.
You can use the Crash Reporter plugin to send notifications for exceptions that are suppressed in your Android application.
You could even use it to send notifications when the [Litho Error Boundary](https://www.internalfb.com/intern/staticdocs/litho/docs/mainconcepts/use-error-boundary/) is triggered.
In order to send custom notifications, take the steps detailed below.
## Android ## Android
Instantiate and add the plugin in `FlipperClient`. Instantiate and add the plugin in `FlipperClient`.
```java ```java
import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
@@ -16,5 +22,6 @@ Use the following API to trigger your custom crash notification.
```java ```java
import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
CrashReporterPlugin.getInstance().sendExceptionMessage(Thread.currentThread(), error); CrashReporterPlugin.getInstance().sendExceptionMessage(Thread.currentThread(), error);
``` ```

View File

@@ -1,9 +1,13 @@
Currently, the images plugin only supports [Fresco](https://frescolib.org/) for Android as backend, but just like the network plugin, support for other image loading libraries import useBaseUrl from '@docusaurus/useBaseUrl';
could easily be added. Send us a PR! import Link from '@docusaurus/Link';
Currently, the <Link to={useBaseUrl("/docs/features/plugins/fresco")}>Image plugin</Link> only supports [Fresco](https://frescolib.org/) for Android as backend.
If you'd like to see support for other image loading libraries, please post your request in the [Flipper Support](https://fb.workplace.com/groups/flippersupport) Workplace group.
## Fresco and Android ## Fresco and Android
The Fresco images plugin is shipped as a separate Maven artifact: The Fresco Images plugin is shipped as a separate Maven artifact:
```groovy ```groovy
dependencies { dependencies {
@@ -11,8 +15,7 @@ dependencies {
} }
``` ```
After including the plugin in your dependencies, you can add it to the After including the plugin in your dependencies, you can add it to the client:
client:
```java ```java
import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
@@ -20,9 +23,7 @@ import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
client.addPlugin(new FrescoFlipperPlugin()); client.addPlugin(new FrescoFlipperPlugin());
``` ```
The `FrescoFlipperPlugin` constructor offers a whole lot of configuration options which The `FrescoFlipperPlugin` constructor offers a range of configuration options that can be useful if you have an advanced setup of Fresco in your application:
can be useful if you have an advanced setup of Fresco in your application:
```java ```java
FrescoFlipperPlugin( FrescoFlipperPlugin(
@@ -37,13 +38,9 @@ FrescoFlipperPlugin(
### Leak Tracking ### Leak Tracking
The Flipper plugin can help you track down `CloseableReferences` who have not had The Flipper plugin can help you track down `CloseableReferences` that have not had `close()` called on them. However, this can have a negative impact on the performance of your application.
`close()` called on them. This can have a negative impact on the performance of
your application.
To enable this functionality, you need to create a `CloseableReferenceLeakTracker` To enable this functionality, you need to create a `CloseableReferenceLeakTracker` and set it in both your `ImagePipelineConfig` for Fresco and the `FrescoPluginPlugin` on creation:
and set it in both your `ImagePipelineConfig` for Fresco and the `FrescoPluginPlugin`
on creation.
```java ```java
import com.facebook.imagepipeline.debug.FlipperCloseableReferenceLeakTracker; import com.facebook.imagepipeline.debug.FlipperCloseableReferenceLeakTracker;
@@ -70,9 +67,7 @@ client.addPlugin(new FrescoFlipperPlugin(
### Attribution ### Attribution
In order to annotate images with the context they are used in, you have to set a In order to annotate images with the context they are used in, you have to set a caller context when loading the image. This can be any object; for the simplest case, a String will suffice, as shown below:
caller context when loading the image. This can be any object, so for the simplest
case, a String will suffice.
```java ```java
String callerContext = "my_feature"; String callerContext = "my_feature";
@@ -89,5 +84,4 @@ DataSource<CloseableReference<CloseableImage>>
dataSource = imagePipeline.fetchDecodedImage(imageRequest, callerContext); dataSource = imagePipeline.fetchDecodedImage(imageRequest, callerContext);
``` ```
If a caller context is supplied, the image will be properly attributed in the If a caller context is supplied, the image will be properly attributed in the Flipper image plugin.
Flipper image plugin.