diff --git a/src/redux-state/selectors/realm.ts b/src/redux-state/selectors/realm.ts index 1ae0eba20..89315f3b6 100644 --- a/src/redux-state/selectors/realm.ts +++ b/src/redux-state/selectors/realm.ts @@ -39,6 +39,8 @@ export const selectHasLoadedRealmData = createSelector( (realms) => Object.keys(realms).length !== 0 ) +export const selectDisplayedRealmName = selectDisplayedRealmProperty("name") + export const selectDisplayedRealmAddress = selectDisplayedRealmProperty( "realmContractAddress" ) diff --git a/src/ui/Island/RealmDetails/RealmBanners/BannerRewards.tsx b/src/ui/Island/RealmDetails/RealmBanners/BannerRewards.tsx index f309707e9..5e26677c1 100644 --- a/src/ui/Island/RealmDetails/RealmBanners/BannerRewards.tsx +++ b/src/ui/Island/RealmDetails/RealmBanners/BannerRewards.tsx @@ -11,6 +11,7 @@ import ClaimCongratulations from "ui/Claim/modals/ClaimCongratulations" import Tooltip from "shared/components/Tooltip" import { bigIntToDisplayUserAmount } from "shared/utils" import { LINKS } from "shared/constants" +import { usePostHog } from "posthog-js/react" import XpClaimModal from "../XpClaim/XpClaimModal" export default function BannerRewards({ @@ -20,6 +21,8 @@ export default function BannerRewards({ amount: bigint setJustClaimed: (hasClaimed: boolean) => void }) { + const posthog = usePostHog() + const realmId = useDappSelector(selectDisplayedRealmId) const realm = useDappSelector((state) => selectRealmById(state, realmId)) @@ -34,12 +37,22 @@ export default function BannerRewards({ const onClaim = useCallback(() => { setJustClaimed(true) // to keep the banner + congratulation modal open setCongratulationsModalOpen(true) - }, [setJustClaimed]) + posthog?.capture("Realm XP claim completed", { + realmName: realm?.name, + }) + }, [setJustClaimed, realm?.name, posthog]) const onClose = useCallback(() => { setIsClaimTransactionModalOpen(false) }, []) + const onOpen = useCallback(() => { + posthog?.capture("Realm XP claim started", { + realmName: realm?.name, + }) + setIsClaimTransactionModalOpen(true) + }, [posthog, realm?.name]) + if (!realmId || !realm) return null return ( @@ -72,7 +85,7 @@ export default function BannerRewards({