Files
discord-decomp/modules/quests/QuestBarRenderDelayTracker.tsx
T
2026-11-01 12:12:55 +02:00

65 lines
1.8 KiB
TypeScript

// Metro module 9476 (f9477).
import { AnalyticEvents } from "../../Constants";
import MonitoringAgent from "../monitoring/MonitoringAgent";
import { MetricEvents } from "../../_bundle/Module5872";
import AnalyticsUtils from "../../utils/AnalyticsUtils";
import DiscordAppState_native from "../app_state/DiscordAppState.native";
let c6250_4 = 30000;
class QuestBarRenderDelayTracker {
constructor() {
return {
__proto__: new.target.prototype,
startTime: null,
questId: null,
timeoutTimer: null
};
}
clearTimeoutTimer() {
if (this.timeoutTimer != null) {
clearTimeout(this.timeoutTimer);
this.timeoutTimer = null;
}
}
sendMetric(a0, a1, a2) {
if (!(Math.random() > 0.1)) {
MonitoringAgent.distribution({
name: MetricEvents.QUEST_BAR_RENDER_DELAY,
tags: [`quest_id:${a0}`, `timeout:${a1}`]
}, a2);
AnalyticsUtils.track(AnalyticEvents.QUEST_BAR_RENDER_DELAY, {
quest_id: a0,
timeout: a1,
duration: a2
});
}
}
startTracking(a0) {
this.clearTracking();
this.startTime = performance.now();
this.questId = a0;
this.timeoutTimer = setTimeout(() => {
this.stopTracking(a0, true);
}, c6250_4);
}
stopTracking(a0, r6 = false) {
if (this.startTime !== null && this.questId === a0) {
if (DiscordAppState_native.getState() === "active") {
this.sendMetric(a0, r6, Math.min(r6 ? c6250_4 : Math.round(performance.now() - this.startTime), c6250_4));
}
this.clearTracking();
}
}
clearTracking() {
this.clearTimeoutTimer();
this.startTime = null;
this.questId = null;
}
}
const prototype = QuestBarRenderDelayTracker.prototype;
export default {
__proto__: prototype,
startTime: null,
questId: null,
timeoutTimer: null
};