Implement EventCounts Web Performance API for React Native (#36181)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36181

[Changelog][Internal]

Implements EventCounts API (`Performance.eventCounts`) for Web Performance, according to the W3C standard, see the specs here: https://www.w3.org/TR/event-timing/#eventcounts

The rationale for why we need it is to support some advanced metrics computations, such as a ratio of "slow events" to total event count, per event type.

Reviewed By: rubennorte

Differential Revision: D43285073

fbshipit-source-id: 2c53d04d9a57c1301e37f2a5879072c8d33efbbf
This commit is contained in:
Ruslan Shestopalyuk
2023-02-16 06:21:43 -08:00
committed by Facebook GitHub Bot
parent 8486e191a1
commit 581357bc9b
10 changed files with 233 additions and 3 deletions
@@ -51,4 +51,12 @@ void NativePerformanceObserver::logRawEntry(
PerformanceEntryReporter::getInstance().logEntry(entry);
}
std::vector<std::pair<std::string, uint32_t>>
NativePerformanceObserver::getEventCounts(jsi::Runtime &rt) {
const auto &eventCounts =
PerformanceEntryReporter::getInstance().getEventCounts();
return std::vector<std::pair<std::string, uint32_t>>(
eventCounts.begin(), eventCounts.end());
}
} // namespace facebook::react