Performance: eventCounts プロパティ
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used 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 |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
eventCounts |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.