// Module ID: 7653 // Function ID: 7654 // Name: MonitoringAgent // Dependencies: [1074, 1115, 7654, 7655, 17, 7656, 7657, 1272, 2] // Module 7653 (MonitoringAgent) import Constants from "Constants" /* 1074 */; import HTTPUtils from "HTTPUtils" /* 1272 */; import NativeMetricMonitorModule from "NativeMetricMonitorModule" /* 7656 */; import MonitoringAgentUtils from "MonitoringAgentUtils" /* 7657 */; import get_ActivityIndicator from "module_17" /* 17 */; import PlatformUtils from "PlatformUtils" /* 1115 */; import size from "module_2" /* 2 */; const Endpoints = Constants.Endpoints; const set = new Set(["darwin", "linux", "win32", "ios", "android"]); const MetricType = { COUNT: "count", DISTRIBUTION: "distribution" }; class MonitoringAgent { constructor() { obj1 = Object.create(new.target.prototype); closure_0 = obj1; obj1._metrics = []; obj1._intervalId = setInterval(() => { obj2._flush(); }, 120000); tmp2 = closure_0; tmp3 = closure_1; tmp4 = closure_0(closure_1[4]); ({ NativeModules, NativeEventEmitter } = tmp4); obj = closure_0(closure_1[1]); if (obj.isAndroid()) { MetricMonitor = tmp2(tmp3[5]).default; } else { MetricMonitor = NativeModules.MetricMonitor; } nativeEventEmitter = new NativeEventEmitter(MetricMonitor); addListenerResult = nativeEventEmitter.addListener("logMetric", (arg0) => { obj2.increment(arg0, false); }); return obj1; } } const prototype = MonitoringAgent.prototype; prototype["_getMetricWithDefaults"] = function _getMetricWithDefaults(name, COUNT) { let tags = name.tags; obj = { name: name.name, type: COUNT, tags: MonitoringAgentUtils.getGlobalTagsArray() }; if (null != tags) { const item = tags.forEach((item) => { const tags = obj.tags; tags.push(item); }); } let str = "web"; if (!tmpResult.isWeb()) { const platformName = tmp(1115).getPlatformName(); let tmp6 = null; if (set.has(platformName)) { tmp6 = platformName; } str = tmp6; const tmpResult2 = tmp(1115); } if (null != str) { const tags1 = obj.tags; const _HermesInternal = HermesInternal; tags1.push("platform:" + str); } const CurrentReleaseChannel = tmp(7654).CurrentReleaseChannel; let tmp9 = null; if (null != CurrentReleaseChannel) { const ALL = tmp(7655).ReleaseChannelsSets.ALL; tmp9 = null; if (ALL.has(CurrentReleaseChannel)) { tmp9 = CurrentReleaseChannel; } } if (null != tmp9) { const tags2 = obj.tags; const _HermesInternal2 = HermesInternal; tags2.push("release_channel:" + tmp9); } return obj; }; prototype["increment"] = function increment(name) { let flag = arg1; if (arg1 === undefined) { flag = false; } const self = this; const _metrics = this._metrics; _metrics.push(this._getMetricWithDefaults(name, obj.COUNT)); if (!flag) { flag = self._metrics.length >= 100; } if (flag) { self._flush(); } }; prototype["distribution"] = function distribution(name, value) { let flag = arg2; if (arg2 === undefined) { flag = false; } const self = this; obj = {}; const merged = Object.assign(this._getMetricWithDefaults(name, obj.DISTRIBUTION)); obj.value = value; const _metrics = this._metrics; _metrics.push(obj); if (!flag) { flag = self._metrics.length >= 100; } if (flag) { self._flush(); } }; prototype["_flush"] = function _flush() { const self = this; if (this._metrics.length > 0) { let items = []; HermesBuiltin.arraySpread(self._metrics, 0); const HTTP = HTTPUtils.HTTP; const request = { url: Endpoints.METRICS_V2, body: null, retries: 1, rejectWithError: true }; const body = { metrics: items, client_info: { built_at: "1789017551964", build_number: "6393" } }; request.body = body; HTTP.post(request).catch(() => { if (self._metrics.length + items.length < 100) { items = []; HermesBuiltin.arraySpread(tmp2, HermesBuiltin.arraySpread(tmp._metrics, 0)); tmp._metrics = items; } }); const postResult = HTTP.post(request); } self._metrics = []; }; let obj2 = Object.create(MonitoringAgent.prototype); let closure_129_0 = obj2; obj2._metrics = []; obj2._intervalId = setInterval(() => { obj2._flush(); }, 120000); ({ NativeModules, NativeEventEmitter } = get_ActivityIndicator); if (PlatformUtils.isAndroid()) { let MetricMonitor = NativeMetricMonitorModule.default; } else { MetricMonitor = NativeModules.MetricMonitor; } let nativeEventEmitter = new NativeEventEmitter(MetricMonitor); nativeEventEmitter.addListener("logMetric", (arg0) => { obj2.increment(arg0, false); }); const result = size.fileFinishedImporting("modules/monitoring/MonitoringAgent.tsx"); export default obj2; export { MetricType };