mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-24 04:24:52 +08:00
chore(docs): prettier & gen new typedocs
This commit is contained in:
@@ -71,7 +71,7 @@ axios.interceptors.response.use(
|
||||
|
||||
// Ensure failed requests throw after interception
|
||||
return Promise.reject(error);
|
||||
}
|
||||
},
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ you can follow the manual installation steps for [iOS](/perf/usage/installation/
|
||||
|
||||
## Add the Performance Monitoring Plugin
|
||||
|
||||
On Android, you need to install the Google Performance Monitoring Plugin which enables automatic
|
||||
On Android, you need to install the Google Performance Monitoring Plugin which enables automatic
|
||||
HTTPs network request monitoring.
|
||||
|
||||
Add the plugin to your `/android/build.gradle` file as a dependency:
|
||||
@@ -54,13 +54,13 @@ It provides a simple API to track custom trace and HTTP request metrics.
|
||||
|
||||
<Youtube id="0EHSPFvH7vk" />
|
||||
|
||||
Review and analyze that data in the Firebase console. Performance Monitoring helps you to understand where and when the
|
||||
Review and analyze that data in the Firebase console. Performance Monitoring helps you to understand where and when the
|
||||
performance of your app can be improved so that you can use that information to fix performance issues.
|
||||
|
||||
Performance Monitoring package automatically traces events and metrics which are sent to Firebase. For more information
|
||||
on the automatic traces, please see the Firebase Performance Monitoring [documentation](https://firebase.google.com/docs/perf-mon/auto_duration-traces-metrics_ios-android).
|
||||
Performance Monitoring package automatically traces events and metrics which are sent to Firebase. For more information
|
||||
on the automatic traces, please see the Firebase Performance Monitoring [documentation](https://firebase.google.com/docs/perf-mon/auto_duration-traces-metrics_ios-android).
|
||||
The package also allows you to performance monitor custom aspects to your application like network requests & task specific
|
||||
app code. All performance metrics are available on your Firebase [console](https://console.firebase.google.com/u/0/) performance tab.
|
||||
app code. All performance metrics are available on your Firebase [console](https://console.firebase.google.com/u/0/) performance tab.
|
||||
|
||||
# Usage
|
||||
|
||||
@@ -70,15 +70,15 @@ Below is how you would measure the amount of time it would take to complete a sp
|
||||
|
||||
```jsx
|
||||
import perf from '@react-native-firebase/perf';
|
||||
|
||||
|
||||
async function customTrace() {
|
||||
// Define & start a trace
|
||||
const trace = await perf().startTrace('custom_trace');
|
||||
|
||||
|
||||
// Define trace meta details
|
||||
trace.putAttribute('user', 'abcd');
|
||||
trace.putMetric('credits', 30);
|
||||
|
||||
|
||||
// Stop the trace
|
||||
await trace.stop();
|
||||
}
|
||||
@@ -90,29 +90,29 @@ Below illustrates you would measure the latency of a HTTP request.
|
||||
|
||||
```jsx
|
||||
import perf from '@react-native-firebase/perf';
|
||||
|
||||
|
||||
async function getRequest(url) {
|
||||
// Define the network metric
|
||||
const metric = await perf().newHttpMetric(url, 'GET');
|
||||
|
||||
|
||||
// Define meta details
|
||||
metric.putAttribute('user', 'abcd');
|
||||
|
||||
|
||||
// Start the metric
|
||||
await metric.start();
|
||||
|
||||
|
||||
// Perform a HTTP request and provide response information
|
||||
const response = await fetch(url);
|
||||
metric.setHttpResponseCode(response.status);
|
||||
metric.setResponseContentType(response.headers.get('Content-Type'));
|
||||
metric.setResponsePayloadSize(response.headers.get('Content-Length'));
|
||||
|
||||
|
||||
// Stop the metric
|
||||
await metric.stop();
|
||||
|
||||
|
||||
return response.json();
|
||||
}
|
||||
|
||||
|
||||
// Call API
|
||||
getRequest('https://api.com').then(json => {
|
||||
console.log(json);
|
||||
|
||||
@@ -56,4 +56,3 @@ Once the above steps have been completed, rebuild your Android project:
|
||||
```bash
|
||||
npx react-native run-android
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user