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
@@ -47,7 +47,12 @@ GetPendingEntriesResult PerformanceEntryReporter::popPendingEntries() {
}
void PerformanceEntryReporter::logEntry(const RawPerformanceEntry &entry) {
if (!isReportingType(static_cast<PerformanceEntryType>(entry.entryType))) {
const auto entryType = static_cast<PerformanceEntryType>(entry.entryType);
if (entryType == PerformanceEntryType::EVENT) {
eventCounts_[entry.name]++;
}
if (!isReportingType(entryType)) {
return;
}