decord/source/modules/game_detection/GameAnalyticsUtils.tsx

118 lines
3.8 KiB
TypeScript
Raw Normal View History

// Module ID: 4735
// Function ID: 4736
// Name: GameAnalyticsUtils
// Dependencies: [1931, 4736, 1115, 2]
2026-09-03 10:05:34 +00:00
// Exports: getGameAnalyticsMetadata, getRunningGameAnalytics, isVerifiedGameExecutable, removeExecutablePathPrefix
2026-07-20 16:05:17 +00:00
// Module 4735 (GameAnalyticsUtils)
import PlatformUtils from "PlatformUtils" /* 1115 */;
import RobloxSubgameUtils from "RobloxSubgameUtils" /* 4736 */;
import DetectableGameStore from "DetectableGameStore" /* 1931 */;
2026-07-23 10:11:24 +00:00
require = fn;
const size = fn(2);
const result = size.fileFinishedImporting("modules/game_detection/GameAnalyticsUtils.tsx");
2026-07-29 08:29:29 +00:00
export const removeExecutablePathPrefix = function removeExecutablePathPrefix(exePath) {
const formatted = exePath.toLowerCase();
let str = formatted;
2026-07-20 16:05:17 +00:00
if (formatted.endsWith("/")) {
2026-07-29 08:29:29 +00:00
str = formatted.slice(0, -1);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const parts = str.split("/");
2026-07-20 16:05:17 +00:00
const substr = parts.slice(-2);
return substr.join("/");
2026-07-29 08:29:29 +00:00
};
2026-07-20 16:05:17 +00:00
export const getRunningGameAnalytics = function getRunningGameAnalytics(streamApplication) {
if (null == streamApplication) {
return { gameName: "Array", gameId: "call", exe: "Math", distributor: "values", sku: "disabled", gameMetadata: "o", rawExePath: "isArray" };
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
const str = "exePath" in streamApplication ? streamApplication.exePath : streamApplication.exe;
const id = streamApplication.id;
const obj = { id, name: null, exePath: null, cmdLine: null, lastFocused: 0 };
2026-07-20 16:05:17 +00:00
const name = streamApplication.name;
obj.name = name;
2026-07-29 08:29:29 +00:00
let str2 = str;
if (str == null) {
str2 = "";
2026-07-20 16:05:17 +00:00
}
obj.exePath = str2;
2026-07-29 08:29:29 +00:00
let str3 = str;
if (str == null) {
str3 = "";
2026-07-20 16:05:17 +00:00
}
obj.cmdLine = str3;
const findGameResult = DetectableGameStore.findGame(obj);
2026-07-20 16:05:17 +00:00
const name2 = streamApplication.name;
const obj2 = { gameName: name2, gameId: null, exe: null, distributor: null, sku: null, gameMetadata: null, rawExePath: null };
2026-07-20 16:05:17 +00:00
let id2 = streamApplication.id;
2026-07-29 08:29:29 +00:00
if (id2 == null) {
let id1;
2026-07-29 08:29:29 +00:00
if (findGameResult != null) {
id1 = findGameResult.id;
2026-07-20 16:05:17 +00:00
}
id2 = id1;
2026-07-20 16:05:17 +00:00
}
obj2.gameId = id2;
2026-07-29 08:29:29 +00:00
let joined;
if (null != str) {
const formatted = str.toLowerCase();
let str5 = formatted;
if (formatted.endsWith("/")) {
str5 = formatted.slice(0, -1);
}
const parts = str5.split("/");
const substr = parts.slice(-2);
joined = substr.join("/");
2026-07-20 16:05:17 +00:00
}
obj2.exe = joined;
2026-07-20 16:05:17 +00:00
const distributor = streamApplication.distributor;
obj2.distributor = distributor;
2026-07-20 16:05:17 +00:00
const sku = streamApplication.sku;
obj2.sku = sku;
2026-07-20 16:05:17 +00:00
let subgameMetadata;
if (null != streamApplication) {
subgameMetadata = RobloxSubgameUtils.getSubgameMetadata(streamApplication);
2026-07-20 16:05:17 +00:00
}
obj2.gameMetadata = subgameMetadata;
obj2.rawExePath = str;
return obj2;
2026-07-20 16:05:17 +00:00
}
};
export const getGameAnalyticsMetadata = function getGameAnalyticsMetadata(currentGameForAnalytics, arg1, detected_game_id) {
2026-09-03 10:05:34 +00:00
if (arg1) {
if (null != detected_game_id) {
2026-09-03 10:05:34 +00:00
const _JSON = JSON;
const obj2 = { detected_game_id };
let json = JSON.stringify(obj2);
2026-09-03 10:05:34 +00:00
}
return json;
}
json = RobloxSubgameUtils.getSubgameMetadata(currentGameForAnalytics);
2026-09-03 10:05:34 +00:00
};
2026-07-29 08:29:29 +00:00
export const isVerifiedGameExecutable = function isVerifiedGameExecutable(str, arr) {
if (null != str) {
2026-07-20 16:05:17 +00:00
if (null != arr) {
2026-07-29 08:29:29 +00:00
const formatted = str.toLowerCase();
let substr = formatted;
if (formatted.endsWith("/")) {
substr = formatted.slice(0, -1);
}
const platformName = PlatformUtils.getPlatformName();
2026-07-20 16:05:17 +00:00
return arr.some((os) => {
let tmp = os.os === closure_1;
if (tmp) {
let endsWithResult;
2026-07-29 08:29:29 +00:00
if (substr != null) {
endsWithResult = obj.endsWith(os.name);
2026-07-20 16:05:17 +00:00
}
tmp = endsWithResult;
2026-07-29 08:29:29 +00:00
obj = substr;
2026-07-20 16:05:17 +00:00
}
return tmp;
});
}
}
return false;
};