Skip to content

Commit

Permalink
chore: add analytics to cg marker gene sets (#814)
Browse files Browse the repository at this point in the history
  • Loading branch information
atarashansky authored Mar 7, 2024
1 parent 0d204de commit 49f8bc9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion client/src/analytics/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ export enum EVENTS {
EXPLORER_COLORBY_GENE_BUTTON_CLICKED = "EXPLORER_COLORBY_GENE_BUTTON_CLICKED",
EXPLORER_SUGGEST_MENU_ITEM_CLICKED = "EXPLORER_SUGGEST_MENU_ITEM_CLICKED",
EXPLORER_GENESET_EXPAND_BUTTON_CLICKED = "EXPLORER_GENESET_EXPAND_BUTTON_CLICKED",
EXPLORER_CG_MARKER_GENE_SETS_HEADING_EXPANDED = "EXPLORER_CG_MARKER_GENE_SETS_HEADING_EXPANDED",
EXPLORER_COLORBY_CG_MARKER_GENE_SET_CLICKED = "EXPLORER_COLORBY_CG_MARKER_GENE_SET_CLICKED",
EXPLORER_GENESET_HEADING_EXPAND_BUTTON_CLICKED = "EXPLORER_GENESET_HEADING_EXPAND_BUTTON_CLICKED",
EXPLORER_MARKER_GENESET_HEADING_EXPAND_BUTTON_CLICKED = "EXPLORER_MARKER_GENESET_HEADING_EXPAND_BUTTON_CLICKED",
EXPLORER_HANDLE_ADD_NEW_GENE_TO_GENESET_BUTTON_CLICKED = "EXPLORER_HANDLE_ADD_NEW_GENE_TO_GENESET_BUTTON_CLICKED",
EXPLORER_SEE_ACTIONS_BUTTON_CLICKED = "EXPLORER_SEE_ACTIONS_BUTTON_CLICKED",
EXPLORER_COLOR_BY_ENTIRE_GENESET_BUTTON_CLICKED = "EXPLORER_COLOR_BY_ENTIRE_GENESET_BUTTON_CLICKED",
Expand Down
1 change: 1 addition & 0 deletions client/src/components/geneExpression/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const MARKER_GENE_SUFFIX_IDENTIFIER = " - marker genes";
5 changes: 2 additions & 3 deletions client/src/components/geneExpression/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import CreateGenesetDialogue from "./menus/createGenesetDialogue";
import { track } from "../../analytics";
import { EVENTS } from "../../analytics/events";
import { Dataframe, DataframeValue } from "../../util/dataframe";

const MARKER_GENE_SUFFIX_IDENTIFIER = " - marker genes";
import { MARKER_GENE_SUFFIX_IDENTIFIER } from "./constants";

// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
type State = any;
Expand Down Expand Up @@ -153,7 +152,7 @@ class GeneExpression extends React.Component<{}, State> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
this.setState((state: any) => {
if (!state.markerGeneSetsExpanded) {
track(EVENTS.EXPLORER_MARKER_GENESET_HEADING_EXPAND_BUTTON_CLICKED);
track(EVENTS.EXPLORER_CG_MARKER_GENE_SETS_HEADING_EXPANDED);
}

return {
Expand Down
9 changes: 7 additions & 2 deletions client/src/components/geneExpression/menus/genesetMenus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import actions from "../../../actions";
import AddGeneToGenesetDialogue from "./addGeneToGenesetDialogue";
import { track } from "../../../analytics";
import { EVENTS } from "../../../analytics/events";
import { MARKER_GENE_SUFFIX_IDENTIFIER } from "../constants";

// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
type State = any;
Expand Down Expand Up @@ -64,11 +65,15 @@ class GenesetMenus extends React.PureComponent<{}, State> {
handleColorByEntireGeneset = (event: React.MouseEvent): void => {
event.preventDefault();

track(EVENTS.EXPLORER_COLOR_BY_ENTIRE_GENESET_BUTTON_CLICKED);

// @ts-expect-error ts-migrate(2339) FIXME: Property 'dispatch' does not exist on type 'Readon... Remove this comment to see the full error message
const { dispatch, geneset } = this.props;

if (geneset.includes(MARKER_GENE_SUFFIX_IDENTIFIER)) {
track(EVENTS.EXPLORER_COLORBY_CG_MARKER_GENE_SET_CLICKED);
} else {
track(EVENTS.EXPLORER_COLOR_BY_ENTIRE_GENESET_BUTTON_CLICKED);
}

dispatch({
type: "color by geneset mean expression",
geneset,
Expand Down

0 comments on commit 49f8bc9

Please sign in to comment.