Performance: eventCounts プロパティ
Baseline
2025
Newly available
Since December 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
読み取り専用の performance.eventCounts は EventCounts マップで、イベント型ごとに配信されたイベントの数を含みます。
すべてのイベント型が公開されているわけではありません。 PerformanceEventTiming インターフェイスで対応しているイベント型のみカウントを取得することができます。
値
EventCounts のマップです。
(読み取り専用の Map で、clear()、delete()、set() メソッドがありません。)
例
>イベント型とその回数の報告
イベント回数をアナリティクスに送信したい場合は、 sendToEventAnalytics のような関数を実装して、 performance.eventCounts マップからイベント回数を取得し、フェッチ API を使用してデータをエンドポイントに送信します。
js
// 公開されるイベントをすべて報告
for (entry of performance.eventCounts.entries()) {
const type = entry[0];
const count = entry[1];
// sendToEventAnalytics(type, count);
}
// 特定のイベントの報告
const clickCount = performance.eventCounts.get("click");
// sendToEventAnalytics("click", clickCount);
// ある型に対してイベントカウントが公開されているか調べる
const isExposed = performance.eventCounts.has("mousemove"); // false
仕様書
| Specification |
|---|
| Event Timing API> # dom-performance-eventcounts> |