Files
discord-decomp/modules/emojis/useTrackOpenPopout.tsx
T
2026-11-01 12:12:55 +02:00

34 lines
1.3 KiB
TypeScript

// Metro module 9412 (f9413).
import { useRef } from "react";
import ChannelStore from "../../stores/ChannelStore";
import SelectedChannelStore from "../../stores/SelectedChannelStore";
import { EmojiInteractionPoint } from "./EmojiConstants";
import { AnalyticEvents } from "../../Constants";
import { collectChannelAnalyticsMetadata } from "../app_analytics/AppAnalyticsUtils";
import useMountEffect from "../../hooks/useMountEffect";
import { initiateEmojiInteraction } from "./EmojiActionCreators";
import AnalyticsUtils from "../../utils/AnalyticsUtils";
export const useTrackOpenPopout = ({ emojiId, currentGuildId, popoutData, nonce, demoMode }) => {
const current = useRef({
guild_id: currentGuildId,
emoji_id: emojiId,
...collectChannelAnalyticsMetadata(ChannelStore.getChannel(SelectedChannelStore.getChannelId(currentGuildId)))
}).current;
useMountEffect(() => {
initiateEmojiInteraction(EmojiInteractionPoint.TrackOpenPopoutUsed);
if (!demoMode) {
const OPEN_POPOUT = AnalyticEvents.OPEN_POPOUT;
let type = popoutData?.analyticsType;
if (type == null) {
type = "Standard Emoji Popout";
}
AnalyticsUtils.track(OPEN_POPOUT, {
type,
nonce,
...current
});
}
});
return current;
};