This EAP site is no longer maintained. See the official Firebase Documentation site for the latest documentation and information about the Firebase JS SDK.
import{ trace }from"firebase/performance";asyncfunctiongetInventory(inventoryIds){const t =trace(perf,"inventoryRetrieval");// Tracks the number of IDs fetched (the metric could help you to optimize in the future)
t.incrementMetric("numberOfIds", inventoryIds.length);// Measures the time it takes to request inventory based on the amount of inventory
t.start();const inventoryData =awaitretrieveInventory(inventoryIds);
t.stop();return inventoryData;}
User Timing API usage
const performance = window.performance;
performance.mark("measurementStart");// Code that you want to trace // ...
performance.mark("measurementStop");
performance.measure("customTraceName","measurementStart","measurementStop");