decord/beta/source/modules/app_analytics/useTrackImpression.tsx

158 lines
4.8 KiB
TypeScript
Raw Normal View History

// Module ID: 8230
// Function ID: 8231
// Name: useTrackImpression
// Dependencies: [19, 2045, 2099, 4655, 1242, 1249, 1241, 573, 5016, 1331, 5040, 5298, 2]
// Exports: default
// Module 8230 (useTrackImpression)
import DispatcherDefault from "Dispatcher" /* 573 */;
import AnalyticsUtils2 from "AnalyticsUtils" /* 1241 */;
import _modDef1331 from "module_1331" /* 1331 */;
import AppAnalyticsUtils from "AppAnalyticsUtils" /* 5016 */;
2026-10-01 14:13:23 +00:00
import uniqueIdDefault from "uniqueId" /* 5040 */;
import react_mod from "react" /* 19 */;
import ChannelStore from "ChannelStore" /* 2045 */;
import SelectedChannelStore from "SelectedChannelStore" /* 2099 */;
import SelectedGuildStore from "SelectedGuildStore" /* 4655 */;
2026-10-01 14:13:23 +00:00
import ImpressionStore from "ImpressionStore" /* 1242 */;
import AnalyticsUtils from "discord_common/AnalyticsUtils" /* 1249 */;
import size from "module_2" /* 2 */;
2026-10-01 14:13:23 +00:00
let dependencyMap;
let c10;
let c9;
let metroImportAll;
let metroImportDefault;
let unpackModuleId;
function trackImpression(type, disableTrack, arg2) {
2026-10-01 14:13:23 +00:00
let name;
let properties;
let flag = disableTrack;
if (disableTrack === undefined) {
flag = false;
}
let flag2 = arg2;
if (arg2 === undefined) {
flag2 = false;
}
({ name, type, properties } = type);
2026-10-01 14:13:23 +00:00
if (type.type === AnalyticsUtils.ImpressionTypes.MODAL) {
if (null == type.name) {
2026-10-01 14:13:23 +00:00
unpackModuleId();
}
}
if (!flag2) {
2026-10-01 14:13:23 +00:00
metroImportDefault(type);
}
let guild_id;
if (properties != null) {
guild_id = properties.guild_id;
}
if (guild_id == null) {
guild_id = SelectedGuildStore.getGuildId();
}
let channel_id;
if (properties != null) {
channel_id = properties.channel_id;
}
if (channel_id == null) {
channel_id = SelectedChannelStore.getChannelId(guild_id);
}
2026-10-01 14:13:23 +00:00
const expandEventProperties = AnalyticsUtils2.expandEventProperties;
const tmpResult = AnalyticsUtils2;
2026-10-01 14:13:23 +00:00
const obj2 = { impression_type: type, location: authStore() };
const tmpResult4 = AppAnalyticsUtils;
2026-10-01 14:13:23 +00:00
const merged = Object.assign(tmpResult4.collectGuildAnalyticsMetadata(guild_id));
const tmpResult5 = AppAnalyticsUtils;
const merged1 = Object.assign(tmpResult5.collectChannelAnalyticsMetadata(ChannelStore.getChannel(channel_id)));
const merged2 = Object.assign(properties);
2026-10-01 14:13:23 +00:00
const result = expandEventProperties(obj2);
if (flag) {
2026-10-01 14:13:23 +00:00
React4(null, null);
} else {
2026-10-01 14:13:23 +00:00
const tmp16 = null != name && null != type;
if (tmp16) {
const tmpResult6 = AnalyticsUtils2;
tmpResult6.debugLogEvent(name, result);
closure_12(name, result);
}
2026-10-01 14:13:23 +00:00
React4(name, result);
}
}
2026-10-01 14:13:23 +00:00
let react = react_mod;
({ setCurrentImpression: metroImportDefault, cleanupImpression: metroImportAll, setDebugTrackedData: c9, getLocation: c10, getImpressionStack: unpackModuleId } = ImpressionStore);
let obj = { analyticEventConfigs: AnalyticsUtils2.AnalyticEventConfigs, dispatcher: DispatcherDefault, TRACK_ACTION_NAME: "TRACK" };
let closure_12 = AnalyticsUtils.trackMaker(obj);
let result = size.fileFinishedImporting("modules/app_analytics/useTrackImpression.tsx");
2026-10-01 14:13:23 +00:00
export default function useTrackImpression(current) {
let closure_2;
let ref;
let obj = arg1;
if (arg1 === undefined) {
obj = { disableTrack: false, trackOnInitialLoad: false };
}
2026-10-01 14:13:23 +00:00
dependencyMap = arg2;
react = undefined;
react = react.useRef(undefined);
const ref2 = react.useRef(undefined);
const tmp = obj(5298)(() => {
if (obj.trackOnInitialLoad) {
2026-10-01 14:13:23 +00:00
let fn;
const tmp6 = _modDef1331(ref.current, current);
const tmp4 = ref;
const tmp7 = !tmp6;
if (tmp7) {
tmp4.current = current;
}
2026-10-01 14:13:23 +00:00
const tmp11 = !_modDef1331(ref2.current, closure_2);
const tmp8 = ref2;
const tmp9 = closure_2;
if (tmp11) {
tmp8.current = tmp9;
}
if (!tmp6) {
2026-10-01 14:13:23 +00:00
obj = { sequenceId: uniqueIdDefault("impression_") };
const merged = Object.assign(tmp5);
trackImpression(obj, tmp.disableTrack);
2026-10-01 14:13:23 +00:00
fn = () => {
if (null != obj) {
closure_2_8(tmp);
}
};
}
return fn;
}
});
2026-10-01 14:13:23 +00:00
const effect = react.useEffect(() => {
if (!obj.trackOnInitialLoad) {
2026-10-01 14:13:23 +00:00
let fn;
const tmp6 = _modDef1331(ref.current, current);
const tmp4 = ref;
const tmp7 = !tmp6;
if (tmp7) {
tmp4.current = current;
}
2026-10-01 14:13:23 +00:00
const tmp11 = !_modDef1331(ref2.current, closure_2);
const tmp8 = ref2;
const tmp9 = closure_2;
if (tmp11) {
tmp8.current = tmp9;
}
if (!tmp6) {
2026-10-01 14:13:23 +00:00
obj = { sequenceId: tmp2(5040)("impression_") };
const merged = Object.assign(tmp5);
trackImpression(obj, tmp.disableTrack);
2026-10-01 14:13:23 +00:00
fn = () => {
if (null != obj) {
closure_2_8(tmp);
}
};
}
return fn;
}
});
};
export { trackImpression };