Skip to content

Commit

Permalink
Merge pull request #847 from alleslabs/feat/proposal-detail-amp
Browse files Browse the repository at this point in the history
Add Amplitude tracking on proposal details page
  • Loading branch information
songwongtp authored Mar 26, 2024
2 parents f66daea + f3d1663 commit 867cbc9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Features

- [#847](https://github.com/alleslabs/celatone-frontend/pull/847) Add Amplitude tracking on Proposal details page
- [#840](https://github.com/alleslabs/celatone-frontend/pull/840) Add chip total count in instantiated by me title
- [#837](https://github.com/alleslabs/celatone-frontend/pull/837) Voting power in validator detail overview
- [#836](https://github.com/alleslabs/celatone-frontend/pull/836) Add recent 100 blocks chart
Expand Down
2 changes: 2 additions & 0 deletions src/lib/amplitude/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ export enum AmpEvent {
USE_FILTER_MY_PROPOSALS = "Use Filter My Proposals",
USE_FILTER_PROPOSALS_STATUS = "Use Filter Proposals Status",
USE_FILTER_PROPOSALS_TYPE = "Use Filter Proposals Types",
USE_SEE_VALIDATOR_VOTES = "Use See Validator Votes",
USE_SEE_VOTES = "Use See Votes",
USE_FILTER_POOL_TYPE = "Use Filter Pool Types",
USE_PAGINATION_PAGE_SIZE = "Use Pagination Page Size",
USE_PAGINATION_NAVIGATION = "Use Pagination Navigation",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { isNull } from "lodash";
import type { ReactNode } from "react";

import type { VoteDetailsProps } from "..";
import { AmpEvent, track } from "lib/amplitude";
import { useMobile } from "lib/app-provider";
import { CustomIcon } from "lib/components/icon";
import { TableTitle } from "lib/components/table";
Expand All @@ -24,6 +25,8 @@ import { ProposalVotesTable } from "./votes-table";
import { VotingQuorum } from "./VotingQuorum";
import { VotingThreshold } from "./VotingThreshold";

type VoterVariant = "validator" | "all";

const ContentContainer = ({
children,
transparent = false,
Expand Down Expand Up @@ -55,13 +58,20 @@ export const VotingPeriod = ({ proposalData, ...props }: VoteDetailsProps) => {

const isProposalResolved = !isNull(proposalData?.resolvedHeight);

const toggleDisclosure = (
disclosure: typeof validatorVoteDisclosure | typeof allVoteDisclosure
) => {
const toggleDisclosure = (voter: VoterVariant) => {
let disclosure = validatorVoteDisclosure;
let ampEvent = AmpEvent.USE_SEE_VALIDATOR_VOTES;

if (voter === "all") {
disclosure = allVoteDisclosure;
ampEvent = AmpEvent.USE_SEE_VOTES;
}

if (disclosure.isOpen) {
disclosure.onClose();
} else {
disclosure.onOpen();
track(ampEvent);
}

const windowPosition = scrollYPosition();
Expand Down Expand Up @@ -116,7 +126,7 @@ export const VotingPeriod = ({ proposalData, ...props }: VoteDetailsProps) => {
/>
<Button
variant="ghost-primary"
onClick={() => toggleDisclosure(validatorVoteDisclosure)}
onClick={() => toggleDisclosure("validator")}
rightIcon={<CustomIcon name="chevron-right" boxSize={3} />}
isDisabled={!answers?.validator.total}
>
Expand All @@ -143,9 +153,7 @@ export const VotingPeriod = ({ proposalData, ...props }: VoteDetailsProps) => {
fullVersion={false}
isProposalResolved={isProposalResolved}
onViewMore={
isMobile
? () => toggleDisclosure(validatorVoteDisclosure)
: undefined
isMobile ? () => toggleDisclosure("validator") : undefined
}
/>
</ContentContainer>
Expand All @@ -161,7 +169,7 @@ export const VotingPeriod = ({ proposalData, ...props }: VoteDetailsProps) => {
/>
<Button
variant="ghost-primary"
onClick={() => toggleDisclosure(allVoteDisclosure)}
onClick={() => toggleDisclosure("all")}
rightIcon={<CustomIcon name="chevron-right" boxSize={3} />}
isDisabled={!answers?.all.total}
>
Expand All @@ -173,9 +181,7 @@ export const VotingPeriod = ({ proposalData, ...props }: VoteDetailsProps) => {
answers={answers?.all}
fullVersion={false}
onViewMore={
isMobile
? () => toggleDisclosure(allVoteDisclosure)
: undefined
isMobile ? () => toggleDisclosure("all") : undefined
}
/>
</ContentContainer>
Expand Down

0 comments on commit 867cbc9

Please sign in to comment.