Skip to content

Commit

Permalink
DCJ-519: Log dataset and study selection/unselection events to Bard (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rushtong authored Jul 30, 2024
1 parent feaf2d3 commit d08051f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
14 changes: 12 additions & 2 deletions src/components/data_search/DatasetSearchTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import { groupBy, isEmpty, concat, compact, map } from 'lodash';
import CollapsibleTable from '../CollapsibleTable';
import TableHeaderSection from '../TableHeaderSection';
import DatasetExportButton from './DatasetExportButton';
import { TerraDataRepo } from '../../libs/ajax/TerraDataRepo';
import { DataSet } from '../../libs/ajax/DataSet';
import { DAR } from '../../libs/ajax/DAR';
import eventList from '../../libs/events';
import { Config } from '../../libs/config';
import DatasetFilterList from './DatasetFilterList';
import { Metrics } from '../../libs/ajax/Metrics';
import { Notifications } from '../../libs/utils';
import { Styles } from '../../libs/theme';
import { TerraDataRepo } from '../../libs/ajax/TerraDataRepo';
import isEqual from 'lodash/isEqual';
import TranslatedDulModal from '../modals/TranslatedDulModal';

Expand Down Expand Up @@ -166,7 +168,7 @@ export const DatasetSearchTable = (props) => {



const selectHandler = (event, data, selector) => {
const selectHandler = async (event, data, selector) => {
let idsToModify = [];
if (selector === 'all') {
data.rows.forEach((row) => {
Expand All @@ -175,10 +177,18 @@ export const DatasetSearchTable = (props) => {
});
});
} else if (selector === 'row') {
const rowIds = data.subtable.rows.map(row => row.id);
const isRowSelected = rowIds.every(id => selected.includes(id));
isRowSelected ?
await Metrics.captureEvent(eventList.dataLibrary, {'action': 'study-unselected'}) :
await Metrics.captureEvent(eventList.dataLibrary, {'action': 'study-selected'});
data.subtable.rows.forEach((row) => {
idsToModify.push(row.id);
});
} else if (selector === 'subrow') {
selected.includes(data.id) ?
await Metrics.captureEvent(eventList.dataLibrary, {'action': 'dataset-unselected'}) :
await Metrics.captureEvent(eventList.dataLibrary,{'action': 'dataset-selected'});
idsToModify.push(data.id);
}

Expand Down
6 changes: 1 addition & 5 deletions src/libs/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ const eventList = {
userSignIn: 'user:signin',

pageView: 'page:view',
dataLibrary: 'page:view:dataLibrary',
dataLibraryBrand: (brand) => {
const cleanKey = brand.replaceAll('/', '');
return `page:view:dataLibrary:${cleanKey}`;
},
dataLibrary: 'page:view:data-library',
dar: 'page:view:dar'
};

Expand Down
2 changes: 1 addition & 1 deletion src/pages/DatasetSearch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export const DatasetSearch = (props) => {
const init = async () => {
key === '/datalibrary' ?
await Metrics.captureEvent(eventList.dataLibrary) :
await Metrics.captureEvent(eventList.dataLibraryBrand(key));
await Metrics.captureEvent(eventList.dataLibrary, {'brand': key.replaceAll('/', '').toLowerCase()});
};
init();
}, [key]);
Expand Down

0 comments on commit d08051f

Please sign in to comment.