decord/alpha/source/modules/badges/trackBadgeDirectoryAction.tsx
github-actions c6aa9eb120 chore: update source for alpha 349.3
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/05xxx/module_5030.js (118.4 MB)
2026-10-01 06:55:13 +00:00

84 lines
2.5 KiB
TypeScript

// Module ID: 10971
// Function ID: 10972
// Name: trackBadgeDirectoryAction
// Dependencies: [1372, 7819, 1074, 1241, 2]
// Exports: default
// Module 10971 (trackBadgeDirectoryAction)
import AnalyticsUtilsDefault from "AnalyticsUtils" /* 1241 */;
import UserStore from "UserStore" /* 1372 */;
import BadgeDirectoryStore from "BadgeDirectoryStore" /* 7819 */;
const AnalyticEvents = fn(1074).AnalyticEvents;
const size = fn(2);
const result = size.fileFinishedImporting("modules/badges/trackBadgeDirectoryAction.tsx");
export default function trackBadgeDirectoryAction(arg0) {
({ badge, displayedUserId } = arg0);
({ actionName, isSociallyNavigated } = arg0);
const currentUser = UserStore.getCurrentUser();
if (currentUser != null) {
const id = currentUser.id;
}
let badgeById;
if (null != badge) {
if (null != id) {
badgeById = BadgeDirectoryStore.getBadgeById(badge.badge_id, id);
}
}
let remainingToNextTier;
if (null != badge) {
if (null != id) {
remainingToNextTier = BadgeDirectoryStore.getRemainingToNextTier(badge.badge_id, id);
}
}
let length;
if (null != displayedUserId) {
const badges = BadgeDirectoryStore.getBadges(displayedUserId);
length = badges.filter((owned) => owned.owned).length;
}
const obj2 = { badge_action: actionName, badge_id: null, badge_tier: null, badge_owner_id: null, is_owned: null, progress_to_next_tier: null, is_earnable: null, is_socially_navigated: null, total_badges_owned: null };
let badge_id;
if (badge != null) {
badge_id = badge.badge_id;
}
obj2.badge_id = badge_id;
let tmp9;
if (null != badge) {
let tmp10 = badge.owned ? badge.current_tier : badge.next_tier;
if (tmp10 == null) {
const tiers = badge.tiers;
let key;
if (tiers != null) {
const first = tiers[0];
if (first != null) {
key = first.key;
}
}
tmp10 = key;
}
tmp9 = tmp10;
}
obj2.badge_tier = tmp9;
obj2.badge_owner_id = displayedUserId;
let flag;
if (badgeById != null) {
flag = badgeById.owned;
}
if (flag == null) {
flag = false;
}
obj2.is_owned = flag;
obj2.progress_to_next_tier = remainingToNextTier;
let flag2;
if (badge != null) {
flag2 = badge.is_earnable;
}
if (flag2 == null) {
flag2 = false;
}
obj2.is_earnable = flag2;
obj2.is_socially_navigated = isSociallyNavigated;
obj2.total_badges_owned = length;
AnalyticsUtilsDefault.track(AnalyticEvents.BADGE_DIRECTORY_ACTION, obj2);
};