Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(somatic): SKFP-1440 add google analytics #4208

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/uiKit/FilterList/CustomFilterContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type OwnProps = {
intervalDecimal?: number;
filterWithFooter?: boolean;
categoryIcon?: ReactNode;
analyticsName?: string;
};

const CustomFilterContainer = ({
Expand All @@ -59,6 +60,7 @@ const CustomFilterContainer = ({
intervalDecimal,
filterWithFooter = true,
categoryIcon,
analyticsName,
}: OwnProps) => {
const [isSearchVisible, setIsSearchVisible] = useState(false);
const [isOpen, setIsOpen] = useState(defaultOpen);
Expand All @@ -75,7 +77,7 @@ const CustomFilterContainer = ({
}, [filtersOpen]);

const onChange = (fg: IFilterGroup, f: IFilter[]) => {
trackFacetSearch(index, fg.field);
trackFacetSearch(analyticsName || index, fg.field);

updateActiveQueryFilters({
queryBuilderId,
Expand Down
3 changes: 3 additions & 0 deletions src/components/uiKit/FilterList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type OwnProps = {
filterInfo: FilterInfo;
filterWithFooter?: boolean;
filterMapper?: TCustomFilterMapper;
analyticsName?: string;
};

const { Text } = Typography;
Expand All @@ -45,6 +46,7 @@ const FilterList = ({
filterInfo,
filterWithFooter = true,
filterMapper,
analyticsName,
}: OwnProps) => {
const [filtersOpen, setFiltersOpen] = useState<boolean | undefined>(isAllFacetOpen(filterInfo));

Expand Down Expand Up @@ -98,6 +100,7 @@ const FilterList = ({
filterWithFooter={filterWithFooter}
categoryIcon={group.categoryIcon}
defaults={group.defaults?.[facet]}
analyticsName={analyticsName}
/>
) : (
<div key={i + ii} className={cx(styles.customFilterWrapper, styles.filter)}>
Expand Down
9 changes: 9 additions & 0 deletions src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ const en = {
placeholder: 'Search...',
results: 'Results',
},
googleAnalytics: {
biospecimenTab: 'Data Exploration biospecimen tab',
dashboard: 'Dashboard',
dataExploration: 'Data Exploration',
fileTab: 'Data Exploration file tab',
germline: 'Germline',
participantTab: 'Data Exploration participant tab',
somatic: 'Somatic',
},
},
maintenance: {
title: 'We are currently down for maintenance',
Expand Down
4 changes: 2 additions & 2 deletions src/services/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const trackVariantWorkbench = (action: string) => {
}
};

export const trackSetActions = (action: string, setType: SetType) => {
export const trackSetActions = (action: string, page: string, setType: SetType) => {
let message = '';
switch (action) {
case SetActionType.CREATE_SET:
Expand All @@ -113,7 +113,7 @@ export const trackSetActions = (action: string, setType: SetType) => {
if (isGaActive) {
ReactGA.event({
category: 'Sets',
action: `${message} - ${setType}`,
action: `${page} - ${message} - ${setType}`,
});
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ const CreateEditModal = ({
]);
} else {
if (saveSetActionType === SetActionType.UPDATE_SET && currentSaveSet) {
trackSetActions(SetActionType.UPDATE_SET, setType);
trackSetActions(
SetActionType.UPDATE_SET,
intl.get('global.googleAnalytics.dashboard'),
setType,
);
dispatch(
updateSavedSet({
onCompleteCb: onSuccessCreateCb,
Expand All @@ -90,7 +94,11 @@ const CreateEditModal = ({
}),
);
} else {
trackSetActions(SetActionType.CREATE_SET, setType);
trackSetActions(
SetActionType.CREATE_SET,
intl.get('global.googleAnalytics.dashboard'),
setType,
);
dispatch(
createSavedSet({
idField,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ const ListItem = ({ data, icon, queryBuilderId }: OwnProps) => {
cancelText: intl.get('components.savedSets.popupConfirm.delete.cancelText'),
okButtonProps: { danger: true },
onOk: () => {
trackSetActions(SetActionType.REMOVE_SET, data.setType);
trackSetActions(
SetActionType.REMOVE_SET,
intl.get('global.googleAnalytics.dashboard'),
data.setType,
);
dispatch(deleteSavedSet(data.id));
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ const BioSpecimenTab = ({ sqon }: OwnProps) => {
selectedAllResults={selectedAllResults}
type={SetType.BIOSPECIMEN}
selectedKeys={selectedKeys}
analyticsPage={intl.get('global.googleAnalytics.biospecimenTab')}
/>,
<Tooltip
title={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ const DataFilesTab = ({ sqon }: OwnProps) => {
type={SetType.FILE}
selectedKeys={selectedKeys}
key="file-set-management"
analyticsPage={intl.get('global.googleAnalytics.fileTab')}
/>,
<DownloadFileManifestModal
key="download-file-manifest"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ const ParticipantsTab = ({ sqon }: OwnProps) => {
sqon={getCurrentSqon()}
type={SetType.PARTICIPANT}
key="participant-set-management"
analyticsPage={intl.get('global.googleAnalytics.participantTab')}
/>,
<Tooltip
title={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type OwnProps = {
sqon?: ISqonGroupFilter;
setActionType: SetActionType;
type: SetType;
analyticsPage: string;
};

const finishButtonText = (type: string) => {
Expand Down Expand Up @@ -57,6 +58,7 @@ const AddRemoveSaveSetModal = ({
setActionType,
sqon,
type,
analyticsPage,
}: OwnProps) => {
const [form] = Form.useForm();
const [isVisible, setIsVisible] = useState(true);
Expand All @@ -78,7 +80,7 @@ const AddRemoveSaveSetModal = ({
switch (setActionType) {
case SetActionType.ADD_IDS:
case SetActionType.REMOVE_IDS:
trackSetActions(setActionType, type);
trackSetActions(setActionType, analyticsPage, type);
dispatch(
updateSavedSet({
id: setId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Props = {
selectedAllResults: boolean;
selectedKeys?: string[];
type: SetType;
analyticsPage: string;
};

export enum SetActionType {
Expand Down Expand Up @@ -113,6 +114,7 @@ const SetsManagementDropdown = ({
type,
selectedKeys = [],
selectedAllResults,
analyticsPage,
}: Props) => {
const [isEditDisabled, setIsEditDisabled] = useState(true);
const [modal, setModal] = useState<ModalState>(modals.hideAll);
Expand Down Expand Up @@ -159,6 +161,7 @@ const SetsManagementDropdown = ({
}}
userSets={savedSets}
type={type}
analyticsPage={analyticsPage}
/>
)}
<Tooltip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ const VariantsTable = ({
sqon={getCurrentSqon()}
type={SetType.VARIANT}
key="variants-set-management"
analyticsPage={intl.get('global.googleAnalytics.germline')}
/>,
],
}}
Expand Down
24 changes: 20 additions & 4 deletions src/views/Variants/components/PageContent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import copy from 'copy-to-clipboard';
import { useVariant } from 'graphql/variants/actions';
import { IVariantResultTree } from 'graphql/variants/models';
import { GET_VARIANT_COUNT } from 'graphql/variants/queries';
import { FilterActionType } from 'views/DataExploration/components/PageContent';
import {
DEFAULT_OFFSET,
DEFAULT_PAGE_INDEX,
Expand All @@ -29,6 +30,7 @@ import GenericFilters from 'components/uiKit/FilterList/GenericFilters';
import { FilterInfo } from 'components/uiKit/FilterList/types';
import { getNoDataOptionValue } from 'components/utils/filterUtils';
import useQBStateWithSavedFilters from 'hooks/useQBStateWithSavedFilters';
import { trackFilterActions } from 'services/analytics';
import { ArrangerApi } from 'services/api/arranger';
import { SavedFilterTag } from 'services/api/savedFilter/models';
import { globalActions } from 'store/global';
Expand Down Expand Up @@ -125,13 +127,27 @@ const PageContent = ({ variantMapping, filterGroups }: OwnProps) => {
)?.displayName || key;
};

const handleOnUpdateFilter = (filter: ISavedFilter) => dispatch(updateSavedFilter(filter));
const handleOnSaveFilter = (filter: ISavedFilter) =>
const handleOnUpdateFilter = (filter: ISavedFilter) => {
trackFilterActions(FilterActionType.UPDATE_FILTER, intl.get('global.googleAnalytics.germline'));
dispatch(updateSavedFilter(filter));
};
const handleOnSaveFilter = (filter: ISavedFilter) => {
trackFilterActions(FilterActionType.CREATE_FILTER, intl.get('global.googleAnalytics.germline'));
dispatch(createSavedFilter(addTagToFilter(filter)));
const handleOnDeleteFilter = (id: string) => dispatch(deleteSavedFilter(id));
const handleOnSaveAsFavorite = (filter: ISavedFilter) =>
};
const handleOnDeleteFilter = (id: string) => {
trackFilterActions(FilterActionType.REMOVE_FILTER, intl.get('global.googleAnalytics.germline'));
dispatch(deleteSavedFilter(id));
};
const handleOnSaveAsFavorite = (filter: ISavedFilter) => {
trackFilterActions(
FilterActionType.FAVORITE_FILTER,
intl.get('global.googleAnalytics.germline'),
);
dispatch(setSavedFilterAsDefault(addTagToFilter(filter)));
};
const handleOnShareFilter = (filter: ISavedFilter) => {
trackFilterActions(FilterActionType.SHARE_FILTER, intl.get('global.googleAnalytics.germline'));
copy(`${getCurrentUrl()}?${SHARED_FILTER_ID_QUERY_PARAM_KEY}=${filter.id}`);
dispatch(
globalActions.displayMessage({
Expand Down
11 changes: 7 additions & 4 deletions src/views/Variants/components/VariantGeneSearch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ import { ICustomSearchProps } from 'components/uiKit/search/GlobalSearch';
import SearchAutocomplete, {
OptionsType,
} from 'components/uiKit/search/GlobalSearch/Search/SearchAutocomplete';
import { trackFacetSearch } from 'services/analytics';
import { ArrangerApi } from 'services/api/arranger';
import { Suggestion, SuggestionType } from 'services/api/arranger/models';

import OptionItem from './OptionItem';

type OwnProps = ICustomSearchProps & {
analyticsName: string;
type: SuggestionType;
};

const getValue = (type: SuggestionType, option: Suggestion) =>
(type === SuggestionType.GENES ? option.symbol : option.locus) ?? '';

const VariantGeneSearch = ({ queryBuilderId, type }: OwnProps) => {
const VariantGeneSearch = ({ analyticsName, queryBuilderId, type }: OwnProps) => {
const [options, setOptions] = useState<OptionsType[]>([]);
const { activeQuery } = useQueryBuilderState(queryBuilderId);
const field =
Expand All @@ -43,15 +45,16 @@ const VariantGeneSearch = ({ queryBuilderId, type }: OwnProps) => {
return (
<SearchAutocomplete
onSearch={(value) => handleSearch(value)}
onSelect={(values) =>
onSelect={(values) => {
trackFacetSearch(analyticsName, field);
updateActiveQueryField({
queryBuilderId,
field,
value: values,
index: INDEXES.VARIANTS,
merge_strategy: MERGE_VALUES_STRATEGIES.OVERRIDE_VALUES,
})
}
});
}}
placeHolder={intl.get(`global.search.${type}.placeholder`)}
options={options}
selectedItems={
Expand Down
7 changes: 7 additions & 0 deletions src/views/Variants/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const filterGroups: {
key="variants"
type={SuggestionType.VARIANTS}
queryBuilderId={VARIANT_REPO_QB_ID}
analyticsName={intl.get('global.googleAnalytics.germline')}
/>,
],
groups: [
Expand Down Expand Up @@ -85,6 +86,7 @@ const filterGroups: {
key="genes"
type={SuggestionType.GENES}
queryBuilderId={VARIANT_REPO_QB_ID}
analyticsName={intl.get('global.googleAnalytics.germline')}
/>,
<GenesUploadIds key="genes_upload_ids" queryBuilderId={VARIANT_REPO_QB_ID} />,
],
Expand Down Expand Up @@ -218,6 +220,7 @@ const Variants = () => {
queryBuilderId={VARIANT_REPO_QB_ID}
extendedMappingResults={variantMappingResults}
filterInfo={filterGroups[FilterTypes.Participant]}
analyticsName={intl.get('global.googleAnalytics.germline')}
/>
),
},
Expand All @@ -233,6 +236,7 @@ const Variants = () => {
queryBuilderId={VARIANT_REPO_QB_ID}
extendedMappingResults={variantMappingResults}
filterInfo={filterGroups[FilterTypes.Variant]}
analyticsName={intl.get('global.googleAnalytics.germline')}
/>
),
},
Expand All @@ -248,6 +252,7 @@ const Variants = () => {
queryBuilderId={VARIANT_REPO_QB_ID}
extendedMappingResults={variantMappingResults}
filterInfo={filterGroups[FilterTypes.Gene]}
analyticsName={intl.get('global.googleAnalytics.germline')}
/>
),
},
Expand All @@ -263,6 +268,7 @@ const Variants = () => {
queryBuilderId={VARIANT_REPO_QB_ID}
extendedMappingResults={variantMappingResults}
filterInfo={filterGroups[FilterTypes.Pathogenicity]}
analyticsName={intl.get('global.googleAnalytics.germline')}
/>
),
},
Expand All @@ -278,6 +284,7 @@ const Variants = () => {
queryBuilderId={VARIANT_REPO_QB_ID}
extendedMappingResults={variantMappingResults}
filterInfo={filterGroups[FilterTypes.Frequency]}
analyticsName={intl.get('global.googleAnalytics.germline')}
/>
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ const VariantsTable = ({
sqon={getCurrentSqon()}
type={SetType.VARIANT}
key="variants-somatic-set-management"
analyticsPage={intl.get('global.googleAnalytics.somatic')}
/>,
],
}}
Expand Down
Loading