mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
581357bc9b
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
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow strict
|
|
* @format
|
|
*/
|
|
|
|
import type {TurboModule} from '../TurboModule/RCTExport';
|
|
|
|
import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
|
|
|
|
export type RawPerformanceEntryType = number;
|
|
|
|
export type RawPerformanceEntry = {|
|
|
name: string,
|
|
entryType: RawPerformanceEntryType,
|
|
startTime: number,
|
|
duration: number,
|
|
// For "event" entries only:
|
|
processingStart?: number,
|
|
processingEnd?: number,
|
|
interactionId?: number,
|
|
|};
|
|
|
|
export type GetPendingEntriesResult = {|
|
|
entries: $ReadOnlyArray<RawPerformanceEntry>,
|
|
droppedEntriesCount: number,
|
|
|};
|
|
|
|
export interface Spec extends TurboModule {
|
|
+startReporting: (entryType: RawPerformanceEntryType) => void;
|
|
+stopReporting: (entryType: RawPerformanceEntryType) => void;
|
|
+popPendingEntries: () => GetPendingEntriesResult;
|
|
+setOnPerformanceEntryCallback: (callback?: () => void) => void;
|
|
+logRawEntry: (entry: RawPerformanceEntry) => void;
|
|
+getEventCounts: () => $ReadOnlyArray<[string, number]>;
|
|
}
|
|
|
|
export default (TurboModuleRegistry.get<Spec>(
|
|
'NativePerformanceObserverCxx',
|
|
): ?Spec);
|