このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

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.eventCountsEventCounts マップで、イベント型ごとに配信されたイベントの数を含みます。

すべてのイベント型が公開されているわけではありません。 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

ブラウザーの互換性

関連情報