decord/alpha/source/modules/quests/EarnedDecisionRoundtripTracker.tsx

96 lines
3.7 KiB
TypeScript
Raw Permalink Normal View History

2026-10-12 06:59:38 +00:00
// Module ID: 9198
// Function ID: 9199
// Name: EarnedDecisionRoundtripTracker
2026-10-12 06:59:38 +00:00
// Dependencies: [5282, 1085, 7182, 1265, 7365, 7185, 2]
2026-07-22 07:54:56 +00:00
2026-10-12 06:59:38 +00:00
// Module 9198 (EarnedDecisionRoundtripTracker)
2026-10-03 08:58:59 +00:00
import Constants from "Constants" /* 1085 */;
2026-10-09 10:00:15 +00:00
import AnalyticsUtilsDefault from "AnalyticsUtils" /* 1265 */;
2026-10-12 06:59:38 +00:00
import NetStats from "NetStats" /* 7182 */;
import getDeviceMetadataDefault from "getDeviceMetadata" /* 7365 */;
2026-10-10 08:08:14 +00:00
import NetworkStore from "NetworkStore" /* 5282 */;
2026-10-03 08:58:59 +00:00
import size from "module_2" /* 2 */;
2026-07-20 16:05:17 +00:00
function trackRoundtrip(apiResponseTimestamp) {
2026-10-03 08:58:59 +00:00
let tmp2Result;
2026-07-20 16:05:17 +00:00
if (Math.random() <= 0.1) {
let diff = null;
if (null != apiResponseTimestamp.apiResponseTimestamp) {
diff = apiResponseTimestamp.apiResponseTimestamp - apiResponseTimestamp.initialSendTimestamp;
}
2026-10-03 08:58:59 +00:00
const obj = NetStats;
const signalStrength = obj.getSignalStrength();
const obj3 = { api_latency_ms: diff, mobile_network_type: NetworkStore.getType(), is_foregrounded: tmp2Result.isForegrounded() };
const track = AnalyticsUtilsDefault.track;
const EARNED_DECISION_ROUNDTRIP = AnalyticEvents.EARNED_DECISION_ROUNDTRIP;
AnalyticsUtilsDefault;
2026-08-24 06:08:38 +00:00
const merged = Object.assign(getDeviceMetadataDefault());
2026-10-03 08:58:59 +00:00
({ endpoint: obj2.endpoint, wasSuccessful: obj2.was_successful } = apiResponseTimestamp);
let tmp11 = null != signalStrength;
const tmp2 = require;
if (tmp11) {
tmp11 = { mobile_signal_strength_level: signalStrength };
const obj4 = { mobile_signal_strength_level: signalStrength };
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
const merged1 = Object.assign(tmp11);
({ callerSource: obj2.caller_source, requestId: obj2.request_id, fetchedAt: obj2.fetched_at } = apiResponseTimestamp);
2026-10-12 06:59:38 +00:00
tmp2Result = tmp2(7185);
2026-10-03 08:58:59 +00:00
track(EARNED_DECISION_ROUNDTRIP, obj3);
2026-07-20 16:05:17 +00:00
}
}
2026-10-03 08:58:59 +00:00
const AnalyticEvents = Constants.AnalyticEvents;
2026-07-29 08:29:29 +00:00
class EarnedDecisionRoundtripTracker {
constructor() {
2026-10-03 08:58:59 +00:00
const merged = Object.assign({ pendingRequests: null });
merged[0] = new Map();
new Map();
return merged;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
recordEarnedRequestAttempt(arg0, callerSource) {
const self = this;
let closure_0 = arg0;
let pendingRequests = this.pendingRequests;
const obj = { initialSendTimestamp: Date.now(), endpoint: "/quests/earned-decision", apiResponseTimestamp: null, wasSuccessful: false, callerSource, requestId: null, fetchedAt: null };
const result = pendingRequests.set(arg0, obj);
const timerId = setTimeout(() => {
const pendingRequests = self.pendingRequests;
const value = pendingRequests.get(closure_0);
const tmp = self;
const tmp2 = closure_0;
if (null != value) {
trackRoundtrip(value);
const pendingRequests2 = tmp.pendingRequests;
pendingRequests2.delete(tmp2);
}
}, 30000);
}
recordEarnedRequestApiResponse(get, requestId) {
requestId = requestId.requestId;
const wasSuccessful = requestId.wasSuccessful;
if (requestId === undefined) {
requestId = null;
}
let fetchedAt = requestId.fetchedAt;
if (fetchedAt === undefined) {
fetchedAt = null;
}
const pendingRequests = this.pendingRequests;
const value = pendingRequests.get(get);
2026-07-29 08:29:29 +00:00
if (null != value) {
2026-10-03 08:58:59 +00:00
const obj = { apiResponseTimestamp: Date.now(), wasSuccessful, requestId, fetchedAt };
const merged = Object.assign(value);
const _Date = Date;
trackRoundtrip(obj);
const pendingRequests2 = this.pendingRequests;
pendingRequests2.delete(get);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
}
const prototype = EarnedDecisionRoundtripTracker.prototype;
let merged = Object.assign({ pendingRequests: null });
2026-10-03 08:58:59 +00:00
const map = new Map();
merged[0] = map;
let result = size.fileFinishedImporting("modules/quests/EarnedDecisionRoundtripTracker.tsx");
2026-07-20 16:05:17 +00:00
export default merged;