Performance: eventCounts プロパティ

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used 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

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
eventCounts

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

関連情報