Files
discord-decomp/sources/modules/network/NetStats.android.tsx
T
2026-07-28 01:06:53 +03:00

424 lines
24 KiB
TypeScript

/* Metro module 4873; source: modules/network/NetStats.android.tsx; dependencies: [5, 6, 7, 27, 4257, 4874, 1867, 661, 3, 1460, 1459, 4883, 672, 587, 694, 4014, 4875, 4884, 14, 2] */
import Module00005 from '../../by-id/module-00005.js'; /* Metro dependency 5 */
import ClassCallCheck from '../../by-id/module-00006-ClassCallCheck.js'; /* Metro dependency 6 */
import CreateClass from '../../by-id/module-00007-CreateClass.js'; /* Metro dependency 7 */
import Dispatcher from '../../Dispatcher.tsx'; /* Metro dependency 694 */
import GuildStore from '../../stores/GuildStore.tsx'; /* Metro dependency 1867 */
import GatewayConnectionStore from '../gateway/GatewayConnectionStore.tsx'; /* Metro dependency 4257 */
import AnalyticsTrackingStore from '../../stores/AnalyticsTrackingStore.tsx'; /* Metro dependency 4874 */
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ReactNativeModule from '../../by-id/module-00027-ReactNative.js'; /* Metro dependency 27 */
import * as StorageModule from '../../external/discord_common/js/packages/storage/Storage.tsx'; /* Metro dependency 587 */
import * as ConstantsModule from '../../Constants.tsx'; /* Metro dependency 661 */
import * as Module01460Module from '../../by-id/module-01460.js'; /* Metro dependency 1460 */
function _fun42678(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#42678, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:6, offset: 0x0113f70d, size: 599 bytes, params: 8, frame: 22
const env0_0 = require;
const receiveNetworkInfoformation2 = receiveNetworkInfoformation;
const updateNetworkUsage = function() {
if (NativeModules.SystemResourceManager.getNetworkUsage != null) {
NativeModules.SystemResourceManager.getNetworkUsage(_fun42681);
}
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
let value = ReactNativeModule;
const AppState = value.AppState;
const env0_6 = value.NativeModules;
value = importDefault(3) /* metro dependency 3: Logger */;
value = new value('NetStats');
const env0_12 = {'signalStrengthLevel': null, 'isNetworkRoaming': false, 'cellularReceiveBytes': 0,
'cellularSendBytes': 0, 'totalReceiveBytes': 0, 'totalSendBytes': 0, 'uidReceiveBytes': 0, 'uidSendBytes': 0,
'socketBytesReceived': 0, 'otaBytesReceived': 0, 'otaNumRequests': 0, 'xhrBytesReceived': 0,
'xhrNumRequests': 0, 'frescoBytesReceived': 0, 'frescoNumRequests': 0, 'downloadBytesReceived': 0,
'downloadNumRequests': 0, 'mediaPlayerBytesReceived': 0};
object = {'type': null, 'effectiveSpeed': null, 'serviceProvider': null};
const NetInfoStateType = (Module01460Module).NetInfoStateType;
object.type = NetInfoStateType.unknown;
const result = AppState.currentState === 'active';
(importDefault(1459) /* metro dependency 1459: NetworkUtils */).addChangeCallback(receiveNetworkInfoformation2);
value = importDefault(1459) /* metro dependency 1459: NetworkUtils */;
value = value.getNetworkInformation();
value.then(receiveNetworkInfoformation2);
value = _fun42682();
value = new value();
(Dispatcher).subscribe('APP_STATE_UPDATE', _fun42703);
(Dispatcher).subscribe('MESSAGE_CREATE', _fun42704);
(Dispatcher).subscribe('MESSAGE_SEND_FAILED', _fun42705);
(FileImportTrackerModule).fileFinishedImporting('modules/network/NetStats.android.tsx');
exports.isSlowNetwork = isSlowNetwork;
exports.getSignalStrength = getSignalStrength;
function receiveNetworkInfoformation(a0) { // fn#42679, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:763, offset: 0x0113f964, size: 36 bytes, params: 2, frame: 11
env0_14 = a0;
if (env0_15 == null) {
env0_15 = a0;
}
updateNetworkUsage();
}
function updateNetworkUsage() { // fn#42680, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:843, offset: 0x0113f988, size: 57 bytes, params: 1, frame: 11
const SystemResourceManager = NativeModules.SystemResourceManager;
const getNetworkUsage = SystemResourceManager.getNetworkUsage;
if (getNetworkUsage != null) {
NativeModules.SystemResourceManager.getNetworkUsage(_fun42681);
}
function _fun42681(a0) { // fn#42681, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:961, offset: 0x0113f9c1, size: 108 bytes, params: 2, frame: 15
const value = environment.__proto__;
env1_12 = a0;
if (env1_13 == null) {
env1_13 = a0;
}
const binding = env1_11;
const fileOnly = binding.fileOnly;
const object = {state: env1_14, nativeStats: env1_12};
object.rtc = (require(4883) /* metro dependency 4883: RTCBandwidthMonitor */).getRTCTotalBytes();
Reflect.apply(fileOnly, binding, ['Updating Network Info', object]);
}
}
function _fun42682() { // fn#42682, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:1208, offset: 0x0113fa2d, size: 170 bytes, params: 1, frame: 17
const EventTracker2 = EventTracker;
const items2 = [{key: 'handleAppStateChange', value: value_42689}];
const env0_2 = Module00005(_fun42693);
items2[1] = {key: 'writeExistingEventStorage', value: value_42694};
const env0_1 = Module00005(_fun42696);
items2[2] = {key: 'track', value: value_42699};
const env0_0 = Module00005(_fun42701);
items2[3] = {key: 'getQueuedEvent', value: value_42702};
return CreateClass(EventTracker2, items2);
function EventTracker() { // fn#42683, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:1229, offset: 0x0113fad7, size: 327 bytes, params: 1, frame: 19
var environment;
var trackExistingEvents;
let value = environment.__proto__;
env1_4(this, EventTracker);
const resultBinding = result;
const value3 = 0;
this.trackTimeout = resultBinding ? global.setTimeout(_fun42684,
1 * (importDefault(672) /* metro dependency 672: Durations */).Millis.MINUTE) : value3;
this.flushStorageInterval = result ? global.setInterval(_fun42685,
5 * (importDefault(672) /* metro dependency 672: Durations */).Millis.SECOND) : value3;
this.didEverTrack = false;
const Storage = (StorageModule).Storage;
this.existingEvents = Storage.get('previousNetStatsEvents') ?? [];
this.trackExistingEvents = trackExistingEvents;
const gatewayConnectionStoreBinding = GatewayConnectionStore;
if (gatewayConnectionStoreBinding.isConnected()) {
this.trackExistingEvents();
} else {
value = importDefault(694) /* metro dependency 694: Dispatcher */;
value.subscribe('CONNECTION_OPEN', this.trackExistingEvents);
}
function _fun42684() { // fn#42684, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:1312, offset: 0x0113fc1e, size: 18 bytes, params: 1, frame: 9
return env0_0.track();
}
function _fun42685() { // fn#42685, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:1399, offset: 0x0113fc30, size: 19 bytes, params: 1, frame: 9
return env0_0.writeExistingEventStorage();
}
function trackExistingEvents() { // fn#42686, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:1593, owner: EventTracker.trackExistingEvents, offset: 0x0113fc43, size: 89 bytes, params: 1, frame: 12
var environment;
var value2;
var analyticsTrackingStoreBinding;
var value;
if (env0_0.existingEvents.length > 0) {
value2 = environment.__proto__.__proto__;
analyticsTrackingStoreBinding = AnalyticsTrackingStore;
value = analyticsTrackingStoreBinding.submitEventsImmediately(env0_0.existingEvents);
value = value.then(_fun42687);
value.catch(_fun42688);
}
function _fun42687() { // fn#42687, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:1681, offset: 0x0113fc9c, size: 62 bytes, params: 1, frame: 14
const binding = env3_11;
const fileOnly = binding.fileOnly;
const binding2 = env1_0;
Reflect.apply(fileOnly, binding, ['Successfully logged existing network usage events', binding2.existingEvents]);
binding2.existingEvents = [];
binding2.writeExistingEventStorage();
}
function _fun42688(a0) { // fn#42688, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:1836, offset: 0x0113fcda, size: 68 bytes, params: 2, frame: 15
var binding;
var error;
let value = a0.status === 429;
if (value || false) {
value = environment.__proto__.__proto__.__proto__;
binding = env3_11;
error = binding.error;
value = environment.__proto__;
Reflect.apply(error, binding, ['Failed to log log existing network usage events', env1_0.existingEvents, a0]);
}
}
}
}
function value_42689(a0) { // fn#42689, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:2090, offset: 0x0113fd1e, size: 156 bytes, params: 2, frame: 16
var environment;
var value;
var resultBinding;
if (!this.didEverTrack) {
value = environment.__proto__;
resultBinding = result;
if (a0) {
if (!resultBinding) {
this.trackTimeout = global.setTimeout(_fun42690,
1 * (importDefault(672) /* metro dependency 672: Durations */).Millis.MINUTE);
this.flushStorageInterval = global.setInterval(_fun42691, 5000);
}
} else if (resultBinding) {
this.track();
}
}
function _fun42690() { // fn#42690, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:2163, offset: 0x0113fdba, size: 18 bytes, params: 1, frame: 9
return env2_21.track();
}
function _fun42691() { // fn#42691, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:2243, offset: 0x0113fc30, size: 19 bytes, params: 1, frame: 9
return env0_0.writeExistingEventStorage();
}
}
function* _fun42693() { // fn#42693, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:2351, offset: 0x0113fdd5, size: 202 bytes, params: 1, frame: 14
var value4;
let value = undefined;
if (false) {
return value;
}
if (this.didEverTrack) {
value = this.existingEvents.concat([]);
if (value.length === 0) {
value = environment.__proto__.__proto__;
env2_0(env2_2[13]).Storage.remove('previousNetStatsEvents');
} else {
value4 = environment.__proto__.__proto__;
env2_0(env2_2[13]).Storage.set('previousNetStatsEvents', value);
}
} else {
value = environment.__proto__.__proto__;
if (env2_16) {
yield this.getQueuedEvent();
value = undefined;
if (false) {
return value;
}
value = this.existingEvents.concat([value]);
if (value.length === 0) {
value = environment.__proto__.__proto__;
env2_0(env2_2[13]).Storage.remove('previousNetStatsEvents');
} else {
value4 = environment.__proto__.__proto__;
env2_0(env2_2[13]).Storage.set('previousNetStatsEvents', value);
}
return undefined;
}
value = this.existingEvents.concat([]);
if (value.length === 0) {
value = environment.__proto__.__proto__;
env2_0(env2_2[13]).Storage.remove('previousNetStatsEvents');
} else {
value4 = environment.__proto__.__proto__;
env2_0(env2_2[13]).Storage.set('previousNetStatsEvents', value);
}
}
}
function value_42694() { // fn#42694, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:2571, offset: 0x00d6b059, size: 30 bytes, params: 1, frame: 13
return env0_2.apply(this, arguments);
}
function* _fun42696() { // fn#42696, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:2667, offset: 0x0113fea8, size: 173 bytes, params: 1, frame: 15
var environment;
let value = undefined;
if (false) {
return value;
}
if (!this.didEverTrack) {
this.didEverTrack = true;
global.clearTimeout(this.trackTimeout);
global.clearInterval(this.flushStorageInterval);
var getQueuedEvent = this.getQueuedEvent;
yield Reflect.apply(getQueuedEvent, this, []);
value = undefined;
if (false) {
return value;
}
var items2 = [value];
value = environment.__proto__.__proto__;
value = env2_8.submitEventsImmediately(items2);
value = value.then(_fun42697);
value.catch(_fun42698);
}
function _fun42697() { // fn#42697, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:2867, offset: 0x0113ff55, size: 50 bytes, params: 1, frame: 14
env3_11.fileOnly('Successfully tracked latest network usage', env0_1);
env0_0.writeExistingEventStorage();
}
function _fun42698(a0) { // fn#42698, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:2973, offset: 0x0113ff87, size: 97 bytes, params: 2, frame: 15
var value;
if (a0.status !== 429) {
value = environment.__proto__.__proto__.__proto__;
env3_11.error('Failed to track latest network usage', env0_1, a0);
}
const binding = env0_0;
binding.existingEvents.push(env0_1[0]);
binding.writeExistingEventStorage();
}
}
function value_42699() { // fn#42699, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:3116, offset: 0x00c3b2ba, size: 30 bytes, params: 1, frame: 13
return env0_1.apply(this, arguments);
}
function* _fun42701() { // fn#42701, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:3201, offset: 0x0113fff1, size: 1173 bytes, params: 1, frame: 22
if (false) {
return undefined;
}
value = environment.__proto__.__proto__;
const value3 = undefined;
env2_22();
let binding = env2_1;
const value4 = binding(env2_2[15]);
const getAppFirstVisibleTimestamp = value4.getAppFirstVisibleTimestamp;
yield Reflect.apply(getAppFirstVisibleTimestamp, value4, []);
const value5 = undefined;
if (false) {
return value5;
}
const value7 = env2_0(env2_2[16]);
const getSession = value7.getSession;
yield Reflect.apply(getSession, value7, []);
const value8 = undefined;
if (false) {
return value8;
}
const object = {};
const APP_NETWORK_USAGE = env2_10.APP_NETWORK_USAGE;
object.type = APP_NETWORK_USAGE;
const object2 = {};
const value10 = env2_0(env2_2[17]);
const getDeviceMetadata = value10.getDeviceMetadata;
copyDataProperties(object2, Reflect.apply(getDeviceMetadata, value10, []), undefined);
const Date = global.Date;
object2['client_track_timestamp'] = Date.now();
object2['client_heartbeat_session_id'] = value8 == null ? value3 : value8.uuid;
binding = env2_0;
const binding2 = env2_2;
object2['load_id'] = binding(binding2[17]).currentLoadId();
object2['num_guilds'] = env2_9.getGuildCount();
binding = env2_1;
object2['was_authenticated'] = binding(binding2[18]).wasAuthenticated;
object2['did_background_app'] = binding(binding2[18]).didBackgroundApp;
object2['headless_task_ran'] = binding(binding2[18]).extraProperties.headless_task_ran;
object2['ready_payload_duration_ms'] = binding(binding2[18]).ready.serializeEnd(value5);
binding = env2_13;
object2['initial_signal_strength_level'] = (binding == null ? value3 : binding.signalStrengthLevel) ?? value3;
object2['final_signal_strength_level'] = env2_12.signalStrengthLevel ?? value3;
binding = env2_15;
object2['initial_network_type'] = (binding == null ? value3 : binding.type) ?? value3;
object2['final_network_type'] = env2_14.type;
binding = env2_15;
object2['initial_cellular_generation'] = (binding == null ? value3 : binding.effectiveSpeed) ?? value3;
object2['final_cellular_generation'] = env2_14.effectiveSpeed;
object2['is_network_roaming'] = env2_12.isNetworkRoaming;
object2['cellular_receive_bytes'] = env2_12.cellularReceiveBytes;
object2['cellular_send_bytes'] = env2_12.cellularSendBytes;
object2['total_receive_bytes'] = env2_12.totalReceiveBytes;
object2['total_send_bytes'] = env2_12.totalSendBytes;
object2['uid_receive_bytes'] = env2_12.uidReceiveBytes;
object2['uid_send_bytes'] = env2_12.uidSendBytes;
object2['socket_bytes_received'] = env2_12.socketBytesReceived;
object2['ota_bytes_received'] = env2_12.otaBytesReceived;
object2['ota_num_requests'] = env2_12.otaNumRequests;
object2['xhr_bytes_received'] = env2_12.xhrBytesReceived;
object2['xhr_num_requests'] = env2_12.xhrNumRequests;
object2['fresco_bytes_received'] = env2_12.frescoBytesReceived;
object2['fresco_num_requests'] = env2_12.frescoNumRequests;
object2['download_bytes_received'] = env2_12.downloadBytesReceived;
object2['download_num_requests'] = env2_12.downloadNumRequests;
object2['media_player_bytes_received'] = env2_12.mediaPlayerBytesReceived;
object2['rtc_bytes'] = env2_0(env2_2[11]).getRTCTotalBytes();
object2['num_message_sends'] = env2_17;
object2['max_message_send_duration'] = env2_17 === 0 ? value3 : env2_18;
object2['max_message_queue_length'] = env2_17 === 0 ? value3 : env2_19;
object2['num_message_send_fails'] = env2_20;
binding = env2_7;
const getSocket = binding.getSocket;
object2['num_identifies'] = Reflect.apply(getSocket, binding, []).identifyCount;
object2['render_latest_messages_duration_ms'] = env2_1(env2_2[18]).renderLatestMessages.serialize(value5);
object.properties = object2;
return object;
}
function value_42702() { // fn#42702, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:5112, offset: 0x00c3945f, size: 30 bytes, params: 1, frame: 13
return env0_0.apply(this, arguments);
}
}
function _fun42703({state}) { // fn#42703, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:5234, offset: 0x01140486, size: 38 bytes, params: 2, frame: 12
env0_21.handleAppStateChange(state === 'active');
}
function _fun42704(a0) { // fn#42704, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:5321, offset: 0x011404ac, size: 135 bytes, params: 2, frame: 17
var binding;
var Math;
var max;
let sendMessageOptions = a0.sendMessageOptions;
const value = undefined;
let sendAnalytics = sendMessageOptions == null ? value : sendMessageOptions.sendAnalytics;
if (sendAnalytics != null) {
binding = env0_17;
env0_17 = typeof binding === 'bigint' ? binding + 1n : +binding + 1;
Math = global.Math;
max = Math.max;
binding = env0_18;
sendMessageOptions = a0.sendMessageOptions;
sendAnalytics = sendMessageOptions.sendAnalytics;
env0_18 = Reflect.apply(max, Math, [binding, sendAnalytics.duration]);
Math = global.Math;
max = Math.max;
binding = env0_19;
sendMessageOptions = a0.sendMessageOptions;
sendAnalytics = sendMessageOptions.sendAnalytics;
env0_19 = Reflect.apply(max, Math, [binding, sendAnalytics.queueSize]);
}
return value;
}
function _fun42705() { // fn#42705, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:5562, offset: 0x01140533, size: 18 bytes, params: 1, frame: 2
const binding = env0_20;
env0_20 = typeof binding === 'bigint' ? binding + 1n : +binding + 1;
}
function isSlowNetwork() { // fn#42706, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:5662, offset: 0x01140545, size: 128 bytes, params: 1, frame: 13
var r1;
var r0;
const type = env0_14.type;
const NetInfoStateType = (Module01460Module).NetInfoStateType;
const value2 = type === NetInfoStateType.cellular;
if (value2) {
r1 = env0_12.signalStrengthLevel != null && env0_12.signalStrengthLevel <= 2;
r1 = !r1 ? env0_14.effectiveSpeed === '2g' : r1;
r1 = !r1 ? env0_12.isNetworkRoaming : r1;
r0 = r1;
} else {
r0 = value2;
}
return r0;
}
function getSignalStrength() { // fn#42707, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:5861, offset: 0x011405c5, size: 15 bytes, params: 1, frame: 1
return env0_12.signalStrengthLevel;
}
}
global.__d(_fun42678, 4873, [5, 6, 7, 27, 4257, 4874, 1867, 661, 3, 1460, 1459, 4883, 672, 587, 694, 4014, 4875,
4884, 14,
2]) /* metro module 4873, dependencies: [5, 6, 7, 27, 4257, 4874, 1867, 661, 3, 1460, 1459, 4883, 672, 587, 694, 4014, 4875, 4884, 14, 2] */;