I have install Firebase Performance monitoring on my React Native app and integrate it successfully. After i want to track my network requests performance and go through as documentation.
const trackRequest = async (url,method) => {
// Define the network metric
const metric = await perf().newHttpMetric(url, method);
// Define meta details
metric.putAttribute('testAttr', 'testValue');
// 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 trace
await metric.stop();
return response.json();
};
I use this function from documentation and call it every network requests time
fetch("www.example.com")
trackRequest("www.example.com","GET")
Can anyone explain me what i were doing wrong ?