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

313 lines
12 KiB
TypeScript
Raw Permalink Normal View History

2026-10-10 08:08:14 +00:00
// Module ID: 5107
// Function ID: 5108
// Name: AppAnalyticsUtils
2026-10-13 12:43:34 +00:00
// Dependencies: [2069, 502, 2065, 4748, 5020, 2125, 2119, 2087, 2012, 4750, 5108, 5110, 4760, 2116, 4939, 5113, 1085, 2072, 4755, 1097, 14398, 1265, 12, 2]
2026-10-08 09:57:35 +00:00
// Exports: collectChannelAnalyticsMetadataFromId, collectStaticChannelRouteAnalyticsMetadata, collectVoiceAnalyticsMetadata, getCustomStatusMetadata, getRecipientFriendCounts, getVoiceStateMetadata, trackWithMetadata
2026-07-20 16:05:17 +00:00
2026-10-10 08:08:14 +00:00
// Module 5107 (AppAnalyticsUtils)
2026-10-03 08:58:59 +00:00
import BigFlagUtilsAll from "BigFlagUtils" /* 1097 */;
2026-10-09 10:00:15 +00:00
import AnalyticsUtilsDefault from "AnalyticsUtils" /* 1265 */;
2026-10-10 08:08:14 +00:00
import ChannelRecord from "ChannelRecord" /* 2069 */;
import ChannelConstants from "ChannelConstants" /* 2072 */;
import PermissionUtilsAll from "PermissionUtils" /* 4755 */;
import AuthenticationStore from "AuthenticationStore" /* 502 */;
2026-10-10 08:08:14 +00:00
import ChannelStore from "ChannelStore" /* 2065 */;
import GuildChannelStore_mod from "GuildChannelStore" /* 4748 */;
import GuildMemberCountStore from "GuildMemberCountStore" /* 5020 */;
import GuildMemberStore from "GuildMemberStore" /* 2125 */;
import GuildRoleStore from "GuildRoleStore" /* 2119 */;
import GuildStore from "GuildStore" /* 2087 */;
2026-10-09 10:00:15 +00:00
import MediaEngineStore from "MediaEngineStore" /* 2012 */;
2026-10-10 08:08:14 +00:00
import PermissionStore from "PermissionStore" /* 4750 */;
import PresenceStore from "PresenceStore" /* 5108 */;
import RTCConnectionStore from "RTCConnectionStore" /* 5110 */;
import RelationshipStore from "RelationshipStore" /* 4760 */;
import SelectedChannelStore from "SelectedChannelStore" /* 2116 */;
import SelectedGuildStore from "SelectedGuildStore" /* 4939 */;
import VoiceStateStore from "VoiceStateStore" /* 5113 */;
2026-10-03 08:58:59 +00:00
import Constants from "Constants" /* 1085 */;
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
2026-10-08 09:57:35 +00:00
let closure_22;
let closure_23;
let closure_24;
2026-10-03 08:58:59 +00:00
let closure_25;
let metroImportAll;
let metroImportDefault;
2026-07-20 16:05:17 +00:00
function collectGuildAnalyticsMetadata(guildId) {
2026-10-03 08:58:59 +00:00
let NONE;
let _String;
let features;
let num;
let num4;
2026-07-20 16:05:17 +00:00
if (null == guildId) {
return null;
} else {
const guild = GuildStore.getGuild(guildId);
2026-07-20 16:05:17 +00:00
if (null == guild) {
return null;
} else {
const numRoles = GuildRoleStore.getNumRoles(guild.id);
const member = GuildMemberStore.getMember(guildId, AuthenticationStore.getId());
const channels = GuildChannelStore.getChannels(guildId);
const voiceStates = VoiceStateStore.getVoiceStates(guildId);
2026-10-03 08:58:59 +00:00
const obj = { guild_id: guild.id, guild_size_total: GuildMemberCountStore.getMemberCount(guildId), guild_num_channels: channels[metroImportDefault].length + channels[metroImportAll].length, guild_num_text_channels: channels[metroImportDefault].length, guild_num_voice_channels: channels[metroImportAll].length, guild_num_roles: numRoles, guild_member_num_roles: num, guild_member_perms: _String(NONE), guild_is_vip: features.has(constants.VIP_REGIONS), is_member: null != member, num_voice_channels_active: num4 };
num = 0;
2026-07-20 16:05:17 +00:00
if (null != member) {
num = member.roles.length;
}
2026-10-03 08:58:59 +00:00
_String = String;
NONE = PermissionStore.getGuildPermissions(guild);
2026-07-29 08:29:29 +00:00
if (NONE == null) {
NONE = PermissionUtilsAll.NONE;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
features = guild.features;
2026-07-29 08:29:29 +00:00
let num3 = 0;
2026-10-03 08:58:59 +00:00
num4 = 0;
2026-07-29 08:29:29 +00:00
const keys = Object.keys();
if (keys !== undefined) {
num4 = num3;
while (keys[tmp] !== undefined) {
num3 = num3 + 1;
continue;
}
}
2026-07-20 16:05:17 +00:00
return obj;
}
}
}
function collectChannelAnalyticsMetadata(channel) {
2026-10-03 08:58:59 +00:00
let NONE;
let _String;
let num;
2026-07-20 16:05:17 +00:00
if (null == channel) {
return null;
} else {
const guildId = channel.getGuildId();
2026-10-03 08:58:59 +00:00
let flag3 = false;
if (null != guildId) {
let flag;
if (THREAD_CHANNEL_TYPES.has(channel.type)) {
if (null != channel.parent_id) {
channel = ChannelStore.getChannel(channel.parent_id);
let flag2 = false;
if (null != guildId) {
flag2 = false;
if (null != channel) {
let hasItem = null != tmp9;
if (hasItem) {
const obj2 = BigFlagUtilsAll;
2026-10-08 09:57:35 +00:00
hasItem = obj2.has(tmp9.deny, constants3.VIEW_CHANNEL);
2026-10-03 08:58:59 +00:00
}
flag2 = hasItem;
2026-07-29 08:29:29 +00:00
}
}
2026-10-03 08:58:59 +00:00
flag = flag2;
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
flag3 = flag;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
flag = false;
2026-07-29 08:29:29 +00:00
if (null != guildId) {
2026-10-03 08:58:59 +00:00
flag = false;
2026-07-29 08:29:29 +00:00
if (null != channel) {
2026-10-03 08:58:59 +00:00
let hasItem1 = null != tmp2;
2026-07-29 08:29:29 +00:00
if (hasItem1) {
2026-10-03 08:58:59 +00:00
const obj = BigFlagUtilsAll;
2026-10-08 09:57:35 +00:00
hasItem1 = obj.has(tmp2.deny, constants3.VIEW_CHANNEL);
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
flag = hasItem1;
2026-07-29 08:29:29 +00:00
}
}
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
({ id: obj3.channel_id, type: obj3.channel_type } = channel);
const obj4 = { channel_id: null, channel_type: null, channel_size_total: num, channel_member_perms: _String(NONE), channel_hidden: flag3 };
num = 0;
if (channel.isPrivate()) {
num = channel.recipients.length;
}
_String = String;
if (null != guildId) {
let NONE2 = PermissionStore.getChannelPermissions(channel);
if (NONE2 == null) {
NONE2 = PermissionUtilsAll.NONE;
}
NONE = NONE2;
} else {
NONE = PermissionUtilsAll.NONE;
}
return obj4;
2026-07-20 16:05:17 +00:00
}
}
2026-10-03 08:58:59 +00:00
function trackWithMetadata(TEXT_AREA_CTA_CLICKED, fileSizeLimitEventProperties, hasItem) {
2026-07-29 08:29:29 +00:00
let obj = fileSizeLimitEventProperties;
if (fileSizeLimitEventProperties === undefined) {
2026-07-20 16:05:17 +00:00
obj = {};
}
2026-07-29 08:29:29 +00:00
let flag = hasItem;
if (hasItem === undefined) {
2026-07-20 16:05:17 +00:00
flag = false;
}
2026-10-03 08:58:59 +00:00
const obj2 = AnalyticsUtilsDefault;
if (!obj2.isThrottled(TEXT_AREA_CTA_CLICKED)) {
let guild_id;
let channel_id;
let tmp12;
2026-07-20 16:05:17 +00:00
if ("guild_id" in obj) {
2026-10-03 08:58:59 +00:00
guild_id = obj.guild_id;
2026-07-20 16:05:17 +00:00
} else {
guild_id = null;
2026-10-03 08:58:59 +00:00
if (!("location" in obj) || obj.location !== constants2.GUILD_CREATE_INVITE_SUGGESTION) {
guild_id = SelectedGuildStore.getGuildId();
2026-07-20 16:05:17 +00:00
}
}
if ("channel_id" in obj) {
2026-10-03 08:58:59 +00:00
channel_id = obj.channel_id;
2026-07-20 16:05:17 +00:00
} else {
channel_id = null;
2026-10-03 08:58:59 +00:00
if (!("location" in obj) || obj.location !== constants2.GUILD_CREATE_INVITE_SUGGESTION) {
channel_id = SelectedChannelStore.getChannelId(guild_id);
2026-07-20 16:05:17 +00:00
}
}
const channel = ChannelStore.getChannel(channel_id);
2026-07-20 16:05:17 +00:00
if (null == channel) {
2026-10-03 08:58:59 +00:00
let tmp14 = guild_id;
2026-07-29 08:29:29 +00:00
if (guild_id == null) {
2026-10-03 08:58:59 +00:00
tmp14 = null;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
tmp12 = tmp14;
2026-07-20 16:05:17 +00:00
} else {
2026-10-03 08:58:59 +00:00
tmp12 = null;
2026-07-20 16:05:17 +00:00
if (!channel.isPrivate()) {
let guildId = channel.getGuildId();
2026-07-29 08:29:29 +00:00
if (guildId == null) {
guildId = guild_id;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (guildId == null) {
guildId = null;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
tmp12 = guildId;
2026-07-20 16:05:17 +00:00
}
}
const obj3 = {};
2026-07-20 16:05:17 +00:00
const merged = Object.assign(obj);
2026-10-03 08:58:59 +00:00
const merged1 = Object.assign(collectGuildAnalyticsMetadata(tmp12));
2026-07-20 16:05:17 +00:00
if (null != guild_id) {
if (null != channel_id) {
2026-10-03 08:58:59 +00:00
let tmp23;
if (isStaticChannelRoute(channel_id)) {
tmp23 = { channel_static_route: channel_id, channel_hidden: false };
const obj4 = { channel_static_route: channel_id, channel_hidden: false };
}
const merged2 = Object.assign(tmp23);
const obj5 = { flush: flag };
const tmpResult = AnalyticsUtilsDefault;
tmpResult.track(TEXT_AREA_CTA_CLICKED, obj3, obj5);
2026-07-20 16:05:17 +00:00
}
}
2026-10-03 08:58:59 +00:00
tmp23 = collectChannelAnalyticsMetadata(channel);
2026-07-20 16:05:17 +00:00
}
}
function getVoiceStateMetadata(guildId, channelId, videoEnabled) {
2026-10-03 08:58:59 +00:00
let closure_0 = channelId;
2026-07-23 10:11:24 +00:00
const obj = { voice_state_count: 0, video_stream_count: 0, video_enabled: videoEnabled };
2026-07-29 08:29:29 +00:00
const tmp = obj(12);
2026-10-03 08:58:59 +00:00
const tmpResult = tmp(VoiceStateStore.getVoiceStates(guildId));
const found = tmpResult.filter((channelId) => channelId.channelId === id);
2026-07-29 08:29:29 +00:00
const found1 = found.filter((userId) => userId.userId !== id.getId());
2026-07-20 16:05:17 +00:00
const item = found1.forEach((selfVideo) => {
obj3.voice_state_count = obj3.voice_state_count + 1;
2026-10-03 08:58:59 +00:00
const tmp2 = selfVideo.selfVideo || selfVideo.selfStream;
2026-07-29 08:29:29 +00:00
if (tmp2) {
2026-10-03 08:58:59 +00:00
obj3.video_stream_count = obj3.video_stream_count + 1;
2026-07-20 16:05:17 +00:00
}
});
return obj;
}
const THREAD_CHANNEL_TYPES = ChannelRecord.THREAD_CHANNEL_TYPES;
let GuildChannelStore = GuildChannelStore_mod;
2026-10-03 08:58:59 +00:00
({ GUILD_SELECTABLE_CHANNELS_KEY: metroImportDefault, GUILD_VOCAL_CHANNELS_KEY: metroImportAll } = GuildChannelStore);
GuildChannelStore = GuildChannelStore_mod;
2026-10-08 09:57:35 +00:00
({ GuildFeatures: closure_22, AnalyticsLocations: closure_23, Permissions: closure_24, ActivityTypes: closure_25 } = Constants);
const isStaticChannelRoute = ChannelConstants.isStaticChannelRoute;
const result = size.fileFinishedImporting("modules/app_analytics/AppAnalyticsUtils.tsx");
2026-07-20 16:05:17 +00:00
export default { trackWithMetadata, getVoiceStateMetadata };
export { collectGuildAnalyticsMetadata };
2026-07-29 08:29:29 +00:00
export function collectStaticChannelRouteAnalyticsMetadata(arg0, channel_static_route) {
return { channel_static_route, channel_hidden: false };
}
2026-07-20 16:05:17 +00:00
export const collectChannelAnalyticsMetadataFromId = function collectChannelAnalyticsMetadataFromId(channelId) {
if (null == channelId) {
return null;
} else {
const channel = ChannelStore.getChannel(channelId);
2026-07-20 16:05:17 +00:00
let tmp3 = null;
if (null != channel) {
tmp3 = collectChannelAnalyticsMetadata(channel);
}
return tmp3;
}
};
export { collectChannelAnalyticsMetadata };
export const collectVoiceAnalyticsMetadata = function collectVoiceAnalyticsMetadata(id) {
2026-10-03 08:58:59 +00:00
let mediaSessionId;
2026-07-20 16:05:17 +00:00
if (null == id) {
return null;
} else {
const channel = ChannelStore.getChannel(id);
2026-07-20 16:05:17 +00:00
if (null == channel) {
return null;
} else {
2026-10-03 08:58:59 +00:00
let tmp2 = MediaEngineStore;
({ id: obj2.channel_id, type: obj2.channel_type } = channel);
2026-10-03 08:58:59 +00:00
const obj = { channel_id: null, channel_type: null, guild_id: channel.getGuildId(), media_session_id: mediaSessionId };
const isVideoEnabledResult = MediaEngineStore.isVideoEnabled();
mediaSessionId = RTCConnectionStore.getMediaSessionId();
2026-07-29 08:29:29 +00:00
id = channel.id;
2026-10-03 08:58:59 +00:00
const obj3 = { voice_state_count: 0, video_stream_count: 0, video_enabled: isVideoEnabledResult };
2026-07-29 08:29:29 +00:00
const guildId = channel.getGuildId();
const tmp9 = obj3(12);
2026-10-03 08:58:59 +00:00
const tmp9Result = tmp9(VoiceStateStore.getVoiceStates(guildId));
const found = tmp9Result.filter((channelId) => channelId.channelId === id);
2026-07-29 08:29:29 +00:00
const found1 = found.filter((userId) => userId.userId !== id.getId());
const item = found1.forEach((selfVideo) => {
obj3.voice_state_count = obj3.voice_state_count + 1;
2026-10-03 08:58:59 +00:00
const tmp2 = selfVideo.selfVideo || selfVideo.selfStream;
2026-07-29 08:29:29 +00:00
if (tmp2) {
2026-10-03 08:58:59 +00:00
obj3.video_stream_count = obj3.video_stream_count + 1;
2026-07-29 08:29:29 +00:00
}
});
const merged = Object.assign(obj3);
2026-10-13 12:43:34 +00:00
const obj4 = id(14398);
2026-10-03 08:58:59 +00:00
const merged1 = Object.assign(obj4.getVoiceAnalyticsMetadataAdditional());
2026-07-20 16:05:17 +00:00
return obj;
}
}
};
export { trackWithMetadata };
2026-10-08 09:57:35 +00:00
export const getRecipientFriendCounts = function getRecipientFriendCounts(recipients) {
let num = 0;
const tmp = recipients[Symbol.iterator]();
while (tmp !== undefined) {
if (RelationshipStore.isFriend(tmp2)) {
num = num + 1;
2026-07-20 16:05:17 +00:00
}
2026-10-08 09:57:35 +00:00
continue;
2026-07-20 16:05:17 +00:00
}
2026-10-08 09:57:35 +00:00
return { friendCount: num, nonFriendCount: recipients.length - num };
2026-07-20 16:05:17 +00:00
};
export { getVoiceStateMetadata };
2026-07-28 08:39:19 +00:00
export const getCustomStatusMetadata = function getCustomStatusMetadata(arg0, arg1) {
2026-10-03 08:58:59 +00:00
let closure_0 = arg1;
2026-07-20 16:05:17 +00:00
const obj = { custom_status_count: 0 };
2026-07-29 08:29:29 +00:00
let tmp = obj(12);
2026-10-03 08:58:59 +00:00
const tmpResult = tmp(VoiceStateStore.getVoiceStates(arg0));
const item = tmpResult.forEach((channelId) => {
const tmp = channelId.channelId === closure_0 && null != PresenceStore.findActivity(channelId.userId, (type) => type.type === constants.CUSTOM_STATUS);
2026-07-20 16:05:17 +00:00
if (tmp) {
obj.custom_status_count = obj.custom_status_count + 1;
}
});
return obj;
};