decord/alpha/source/modules/app_analytics/AppAnalyticsManager.tsx

150 lines
6.7 KiB
TypeScript
Raw Normal View History

// Module ID: 17089
// Function ID: 17090
// Name: AppAnalyticsManager
// Dependencies: [2000, 1993, 4859, 5591, 5731, 4860, 1074, 1091, 6539, 2040, 5016, 16565, 4966, 2]
2026-07-20 16:05:17 +00:00
// Module 17089 (AppAnalyticsManager)
import DurationsDefault from "Durations" /* 1091 */;
import Timers from "Timers" /* 2040 */;
import RobloxSubgameUtils from "RobloxSubgameUtils" /* 4966 */;
import AppAnalyticsUtils from "AppAnalyticsUtils" /* 5016 */;
import getGamePlatformDefault from "getGamePlatform" /* 16565 */;
import RunningGameStore from "RunningGameStore" /* 2000 */;
import MediaEngineStore from "MediaEngineStore" /* 1993 */;
import RTCConnectionStore from "RTCConnectionStore" /* 4859 */;
import SelfPresenceStore from "SelfPresenceStore" /* 5591 */;
import SpeakingStore from "SpeakingStore" /* 5731 */;
import SortedVoiceStateStore from "SortedVoiceStateStore" /* 4860 */;
import AutomaticLifecycleManager from "AutomaticLifecycleManager" /* 6539 */;
2026-07-23 10:11:24 +00:00
require = fn;
const Constants = fn(1074);
({ AnalyticEvents: closure_9, ActivityTypes: c10 } = Constants);
const MINUTE = DurationsDefault.Millis.MINUTE;
2026-07-29 08:29:29 +00:00
class AppAnalyticsManager extends tmp3 {
constructor() {
applyArgumentsResult = HermesBuiltin.applyArguments(new.target, new.target);
closure_0 = applyArgumentsResult;
applyArgumentsResult._currentUserSpeaking = false;
applyArgumentsResult._anyoneElseSpeaking = false;
applyArgumentsResult._handleRTCConnectionStoreChanged = function _handleRTCConnectionStoreChanged() {
const channelId = RTCConnectionStore.getChannelId();
2026-07-29 08:29:29 +00:00
if (applyArgumentsResult._voiceChannelId !== channelId) {
obj._voiceChannelId = channelId;
if (null != channelId) {
if (null == obj._reportInterval) {
const interval = new Timers.Interval();
2026-07-29 08:29:29 +00:00
obj._reportInterval = interval;
const _reportInterval = obj._reportInterval;
_reportInterval.start(MINUTE, () => {
closure_1_0._trackStartSpeaking();
closure_1_0._trackStartListening();
2026-07-29 08:29:29 +00:00
});
}
} else {
obj._reset();
}
}
};
applyArgumentsResult._handleSpeakingStoreChanged = function _handleSpeakingStoreChanged() {
const result = SpeakingStore.isCurrentUserSpeaking();
2026-07-29 08:29:29 +00:00
if (applyArgumentsResult._currentUserSpeaking !== result) {
obj2._currentUserSpeaking = result;
obj2._trackStartSpeaking();
}
const isAnyoneElseSpeakingResult = SpeakingStore.isAnyoneElseSpeaking();
2026-07-29 08:29:29 +00:00
if (applyArgumentsResult._anyoneElseSpeaking !== isAnyoneElseSpeakingResult) {
obj2._anyoneElseSpeaking = isAnyoneElseSpeakingResult;
obj2._trackStartListening();
}
};
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
const prototype = AppAnalyticsManager.prototype;
prototype["_initialize"] = function _initialize() {
const self = this;
const result = new Map().set(SpeakingStore, () => self._handleSpeakingStoreChanged());
this.stores = result.set(RTCConnectionStore, () => self._handleRTCConnectionStoreChanged());
2026-07-29 08:29:29 +00:00
this._reset();
};
prototype["_reset"] = function _reset() {
const self = this;
this._currentUserSpeaking = false;
this._anyoneElseSpeaking = false;
if (null != this._reportInterval) {
const _reportInterval = self._reportInterval;
_reportInterval.stop();
self._reportInterval = null;
}
};
prototype["_trackStartSpeaking"] = function _trackStartSpeaking() {
const self = this;
if (this._currentUserSpeaking) {
const channelId = RTCConnectionStore.getChannelId();
const guildId = RTCConnectionStore.getGuildId();
const obj2 = { mode: MediaEngineStore.getMode(), priority: SpeakingStore.isCurrentUserPrioritySpeaking(), channel: channelId, server: guildId, channel_id: channelId, guild_id: guildId, rtc_connection_id: RTCConnectionStore.getRTCConnectionId(), media_session_id: RTCConnectionStore.getMediaSessionId(), voice_state_count: SortedVoiceStateStore.countVoiceStatesForChannel(self._voiceChannelId) };
2026-07-29 08:29:29 +00:00
const merged = Object.assign(self.getGameMetadata());
const merged1 = Object.assign(RTCConnectionStore.getPacketStats());
AppAnalyticsUtils.trackWithMetadata(constants.START_SPEAKING, obj2);
2026-07-29 08:29:29 +00:00
}
};
prototype["_trackStartListening"] = function _trackStartListening() {
if (!MediaEngineStore.isDeaf()) {
2026-07-29 08:29:29 +00:00
const self = this;
if (this._anyoneElseSpeaking) {
const channelId = RTCConnectionStore.getChannelId();
const guildId = RTCConnectionStore.getGuildId();
const obj3 = { mute: MediaEngineStore.isMute(), anyone_priority: SpeakingStore.isAnyonePrioritySpeaking(), channel: channelId, server: guildId, channel_id: channelId, guild_id: guildId, rtc_connection_id: RTCConnectionStore.getRTCConnectionId(), media_session_id: RTCConnectionStore.getMediaSessionId(), voice_state_count: SortedVoiceStateStore.countVoiceStatesForChannel(self._voiceChannelId) };
2026-07-29 08:29:29 +00:00
const merged = Object.assign(self.getGameMetadata());
AppAnalyticsUtils.trackWithMetadata(constants.START_LISTENING, obj3);
2026-07-29 08:29:29 +00:00
}
}
};
prototype["_terminate"] = function _terminate() {
this._reset();
SpeakingStore.removeChangeListener(this._handleSpeakingStoreChanged);
RTCConnectionStore.removeChangeListener(this._handleRTCConnectionStoreChanged);
2026-07-29 08:29:29 +00:00
};
prototype["getGameMetadata"] = function getGameMetadata() {
const findActivityResult = SelfPresenceStore.findActivity((type) => type.type === constants.PLAYING);
const currentGameForAnalytics = RunningGameStore.getCurrentGameForAnalytics();
2026-08-24 06:08:38 +00:00
const obj = { game_platform: getGamePlatformDefault(findActivityResult), game_name: null, game_exe_name: null, game_id: null, game_distributor: null, game_distributor_game_id: null, game_metadata: null };
2026-07-29 08:29:29 +00:00
let name = null;
if (null != findActivityResult) {
name = findActivityResult.name;
}
obj.game_name = name;
2026-07-29 08:29:29 +00:00
let exeName = null;
if (null != currentGameForAnalytics) {
exeName = currentGameForAnalytics.exeName;
}
obj.game_exe_name = exeName;
2026-07-29 08:29:29 +00:00
let application_id = null;
if (null != findActivityResult) {
application_id = findActivityResult.application_id;
}
obj.game_id = application_id;
2026-07-29 08:29:29 +00:00
let distributor = null;
if (null != currentGameForAnalytics) {
distributor = currentGameForAnalytics.distributor;
}
obj.game_distributor = distributor;
2026-07-29 08:29:29 +00:00
let sku = null;
if (null != currentGameForAnalytics) {
sku = currentGameForAnalytics.sku;
}
obj.game_distributor_game_id = sku;
2026-07-29 08:29:29 +00:00
let subgameMetadata = null;
if (null != currentGameForAnalytics) {
subgameMetadata = RobloxSubgameUtils.getSubgameMetadata(currentGameForAnalytics);
2026-07-29 08:29:29 +00:00
}
obj.game_metadata = subgameMetadata;
2026-07-29 08:29:29 +00:00
return obj;
};
const appAnalyticsManager = new AppAnalyticsManager();
const size = fn(2);
let result = size.fileFinishedImporting("modules/app_analytics/AppAnalyticsManager.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default appAnalyticsManager;