Skip to content

Commit

Permalink
Track additional click event in google analytics
Browse files Browse the repository at this point in the history
Track every toggle to the Variant Co-occurrence table on the Gene page, every time a genetic ancestry group is toggled on the Variant page frequency table, and every time a user clicks 'more info' for the multi nucleotide variant summary text
  • Loading branch information
rileyhgrant committed Mar 28, 2024
1 parent b671040 commit 7ad1402
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
18 changes: 15 additions & 3 deletions browser/src/GenePage/GenePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,15 @@ import {
CopyNumberVariant,
} from '../VariantPage/VariantPage'
import CopyNumberVariantsInGene from './CopyNumberVariantsInGene'
import { ControlPanel, Legend, LegendItemWrapper, Label, CheckboxInput, LegendSwatch } from '../ChartStyles'

import {
ControlPanel,
Legend,
LegendItemWrapper,
Label,
CheckboxInput,
LegendSwatch,
} from '../ChartStyles'
import { logButtonClick } from '../analytics'

export type Strand = '+' | '-'

Expand Down Expand Up @@ -183,7 +190,12 @@ const BaseTableSelector = styled.div<TableSelectorProps>

const TableSelector = BaseTableSelector.attrs(
({ setSelectedTableName, ownTableName }: TableSelectorProps) => ({
onClick: () => setSelectedTableName(ownTableName),
onClick: () => {
if (ownTableName === 'cooccurrence') {
logButtonClick('User selected variant co-occurrence table on Gene page')
}
setSelectedTableName(ownTableName)
},
})
)`
border: 1px solid black;
Expand Down
6 changes: 6 additions & 0 deletions browser/src/MNVPage/MNVSummaryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react'
import { Badge, List, ListItem } from '@gnomad/ui'

import Link from '../Link'
import { logButtonClick } from '../analytics'

type Props = {
multiNucleotideVariants: {
Expand Down Expand Up @@ -37,6 +38,11 @@ const MNVSummaryList = ({ multiNucleotideVariants }: Props) => (
in {mnv.n_individuals} individual{mnv.individuals !== 1 && 's'}
{mnv.changes_amino_acids && ', altering the amino acid sequence'}.{' '}
<Link
// onClick={(event: React.MouseEvent<HTMLAnchorElement>) => {
onClick={() => {
logButtonClick('User clicked "more info" in the MNV summary text')
// event.preventDefault()
}}
to={`/variant/${mnv.combined_variant_id}?dataset=gnomad_r2_1`}
preserveSelectedDataset={false}
>
Expand Down
6 changes: 5 additions & 1 deletion browser/src/VariantPage/PopulationsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { Component } from 'react'
import styled from 'styled-components'

import { BaseTable, TextButton, TooltipAnchor, TooltipHint } from '@gnomad/ui'
import { logButtonClick } from '../analytics'

const Table = styled(BaseTable)`
min-width: 100%;
Expand Down Expand Up @@ -160,7 +161,10 @@ export class PopulationsTable extends Component<PopulationsTableProps, Populatio
<TogglePopulationButton
// @ts-expect-error TS(2769) FIXME: No overload matches this call.
isExpanded={isExpanded}
onClick={() => this.togglePopulationExpanded(pop.name)}
onClick={() => {
logButtonClick(`User toggled ${pop.name} in variant page frequency table`)
this.togglePopulationExpanded(pop.name)
}}
>
{pop.name}
</TogglePopulationButton>
Expand Down

0 comments on commit 7ad1402

Please sign in to comment.