-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.mjs
31 lines (27 loc) · 720 Bytes
/
index.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
export class TraceEvents {
_eventObjects;
_observer;
constructor() {
this._eventObjects = [];
this._observer = new PerformanceObserver((perfEntryList) => {
const measures = perfEntryList.getEntriesByType('measure');
measures.forEach((measure) => {
this._eventObjects.push({
name: measure.name,
cat: measure.entryType,
ph: "X",
pid: 1,
ts: Math.round(measure.startTime * 1000),
dur: Math.round(measure.duration * 1000),
});
});
});
this._observer.observe({ type: 'measure', buffered: true });
}
destroy() {
this._observer.disconnect();
}
getEvents() {
return this._eventObjects;
}
}