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

Map Metrics #207

Merged
merged 26 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
18a766b
Add GA Tagging service
akhuoa Apr 26, 2024
0ec7336
Add page view tracking for maps
akhuoa Apr 29, 2024
d015add
Add event tracking for species change
akhuoa Apr 29, 2024
1009630
Refactor tagging sendevent code
akhuoa Apr 29, 2024
56f6c41
Add event tracking for sidebar filter from map action
akhuoa Apr 29, 2024
26d3964
Update map sidebar search and filter events
akhuoa Apr 29, 2024
2014421
Merge branch 'ABI-Software:main' into feature/google-analytics
akhuoa Apr 29, 2024
2c52696
Add map popup action click event tracking
akhuoa Apr 29, 2024
a82df82
Add event tracking for map on display search
akhuoa Apr 29, 2024
f3c26b9
Update map filter event tracking
akhuoa May 1, 2024
94872c5
Add map sidebar gallery click event tracking
akhuoa May 1, 2024
103dbe8
Add sidebar gallery dataset button click event
akhuoa May 2, 2024
dc7d2bf
Add dataset_id in event tracking
akhuoa May 2, 2024
f453acb
Set debugging mode for tagging
akhuoa May 2, 2024
f49cfc1
Merge branch 'ABI-Software:main' into feature/google-analytics
akhuoa May 2, 2024
5da7b5d
Add missing semicolons
akhuoa May 2, 2024
8f4f828
Rename dataset click to datalink click
akhuoa May 3, 2024
766433e
Add file path information
akhuoa May 3, 2024
eab36d6
Add flatmapvuer pathway selection change event tracking
akhuoa May 6, 2024
e4b084a
Add connectivity tracking on clicking nerve
akhuoa May 6, 2024
2fd990a
Add open pubmed button click event
akhuoa May 6, 2024
afc6c06
Add featured dataset marker click search event
akhuoa May 7, 2024
c03602c
Update flatmapvuer versioon
akhuoa May 15, 2024
7424c78
Move gallery action click tracking to actionClick
akhuoa May 15, 2024
f710d3c
Add open new map event in tracking
akhuoa May 15, 2024
f7ab764
Update map-side-bar version
akhuoa May 15, 2024
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
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"*.js"
],
"dependencies": {
"@abi-software/flatmapvuer": "1.0.1",
"@abi-software/map-side-bar": "2.0.1",
"@abi-software/flatmapvuer": "1.0.2",
"@abi-software/map-side-bar": "2.1.0",
"@abi-software/plotvuer": "1.0.0",
"@abi-software/scaffoldvuer": "1.0.1",
"@abi-software/simulationvuer": "1.0.0",
Expand Down
10 changes: 10 additions & 0 deletions src/components/MapContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

<script>
/* eslint-disable no-alert, no-console */
import Tagging from '../services/tagging.js';
import SplitFlow from './SplitFlow.vue';
import EventBus from './EventBus';
import { mapStores } from 'pinia';
Expand Down Expand Up @@ -246,6 +247,15 @@ export default {
* This event emit when the component is mounted.
*/
this.$emit("isReady");

// GA Tagging
// Page view tracking for maps' buttons click on portal
// category: AC | FC | WholeBody
Tagging.sendEvent({
'event': 'interaction_event',
'event_name': 'portal_maps_page_view',
'category': this.startingMap
});
},
},
computed: {
Expand Down
130 changes: 128 additions & 2 deletions src/components/SplitFlow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
@tabClicked="tabClicked"
@search-changed="searchChanged($event)"
@contextUpdate="contextUpdate($event)"
@datalink-clicked="datalinkClicked($event)"
/>
<SplitDialog
:entries="entries"
Expand All @@ -42,12 +43,18 @@

<script>
/* eslint-disable no-alert, no-console */
import Tagging from '../services/tagging.js';
import DialogToolbarContent from "./DialogToolbarContent.vue";
import EventBus from "./EventBus";
import SplitDialog from "./SplitDialog.vue";
// import contextCards from './context-cards'
import { SideBar } from "@abi-software/map-side-bar";
import { capitalise, getNewMapEntry, initialDefaultState } from "./scripts/utilities.js";
import {
capitalise,
getNewMapEntry,
initialDefaultState,
intersectArrays,
} from "./scripts/utilities.js";
import { mapStores } from 'pinia';
import { useEntriesStore } from '../stores/entries';
import { useSettingsStore } from '../stores/settings';
Expand Down Expand Up @@ -85,6 +92,8 @@ export default {
startUp: true,
search: '',
activeDockedId : 1,
filterTriggered: false,
availableFacets: [],
}
},
watch: {
Expand All @@ -109,12 +118,34 @@ export default {
this.openSearch([action.filter], action.label);
} else {
this.openSearch([], action.term);
// GA Tagging
// Event tracking for map action search/filter data
const eventName = action.featuredDataset
? 'portal_maps_featured_dataset_search'
: 'portal_maps_action_search';
Tagging.sendEvent({
'event': 'interaction_event',
'event_name': eventName,
'category': action.term || 'filter',
'location': 'map_location_pin'
});
this.filterTriggered = true;
}
} else if (action.type == "URL") {
window.open(action.resource, "_blank");
} else if (action.type == "Facet") {
if (this.$refs.sideBar) {
this.$refs.sideBar.addFilter(action);
const { facet } = action;
// GA Tagging
// Event tracking for map action search/filter data
Tagging.sendEvent({
'event': 'interaction_event',
'event_name': 'portal_maps_action_filter',
'category': facet || 'filter',
'location': 'map_location_pin'
});
this.filterTriggered = true;
}
} else if (action.type == "Facets") {
const facets = [];
Expand All @@ -140,12 +171,46 @@ export default {
);
if (this.$refs.sideBar) {
this.$refs.sideBar.openSearch(facets, "");

const filterValuesArray = intersectArrays(this.availableFacets, action.labels);
const filterValues = filterValuesArray.join(', ');
// GA Tagging
// Event tracking for map action search/filter data
Tagging.sendEvent({
'event': 'interaction_event',
'event_name': 'portal_maps_action_filter',
'category': filterValues || 'filter',
'location': 'map_popup_button'
});
}
} else {
this.trackGalleryClick(action);
this.createNewEntry(action);
}
}
},
trackGalleryClick: function (action) {
const categoryValues = [];
const { label, type, datasetId, resource } = action;
let filePath = '';
if (label) categoryValues.push(label);
if (type) categoryValues.push(type);
if (datasetId) categoryValues.push('(' + datasetId + ')');
if (resource) {
filePath = resource.share_link;
}

// GA Tagging
// Event tracking for map sidebar gallery click
Tagging.sendEvent({
'event': 'interaction_event',
'event_name': 'portal_maps_gallery_click',
'category': categoryValues.join(' '),
'location': 'map_sidebar_gallery',
'dataset_id': datasetId ? datasetId + '' : '', // change to string format
'file_path': filePath,
});
},
onDisplaySearch: function (payload) {
let searchFound = false;
//Search all active viewers when global callback is on
Expand All @@ -159,6 +224,15 @@ export default {
});
}
this.$refs.dialogToolbar.setFailedSearch(searchFound ? undefined : payload.term);

// GA Tagging
// Event tracking for map on display search
Tagging.sendEvent({
'event': 'interaction_event',
'event_name': 'portal_maps_display_search',
'category': payload.term,
'location': 'map_toolbar'
});
},
fetchSuggestions: function(payload) {
const suggestions = [];
Expand All @@ -177,14 +251,46 @@ export default {
searchChanged: function (data) {
if (data && data.type == "query-update") {
this.search = data.value;
if (this.search && !this.filterTriggered) {
// GA Tagging
// Event tracking for map action search/filter data
Tagging.sendEvent({
'event': 'interaction_event',
'event_name': 'portal_maps_action_search',
'category': this.search,
'location': 'map_sidebar_search'
});
}
this.filterTriggered = false; // reset for next action
}
if (data && data.type == "filter-update") {
this.settingsStore.updateFacets(data.value);

// Remove filter event from maps' popup
if (!this.filterTriggered) {
const { value } = data;
const filterValuesArray = value.filter((val) =>
val.facet && val.facet.toLowerCase() !== 'show all'
).map((val) => val.facet);
const filterValues = filterValuesArray.join(', ');

// GA Tagging
// Event tracking for map action search/filter data
Tagging.sendEvent({
'event': 'interaction_event',
'event_name': 'portal_maps_action_filter',
'category': filterValues || 'filter',
'location': 'map_sidebar_filter'
});
}
this.filterTriggered = false; // reset for next action
}
if (data && data.type == "available-facets") {
this.settingsStore.updateFacetLabels(data.value.labels);
this.settingsStore.updateMarkers(data.value.uberons);
EventBus.emit("markerUpdate");

this.availableFacets = data.value.labels
}
},
getNewEntryId: function() {
Expand Down Expand Up @@ -323,7 +429,27 @@ export default {
},
contextUpdate: function (payload) {
EventBus.emit("contextUpdate", payload);
}
},
datalinkClicked: function (payload) {
// payload is dataset URL
const datasetURL = payload || '';
const substringA = 'datasets/';
const substringB = '?type=dataset';
const datasetId = datasetURL.substring(
datasetURL.indexOf(substringA) + substringA.length,
datasetURL.indexOf(substringB)
);

// GA Tagging
// Event tracking for map sidebar gallery dataset click
Tagging.sendEvent({
'event': 'interaction_event',
'event_name': 'portal_maps_gallery_click',
'category': datasetURL,
'location': 'map_sidebar_gallery',
'dataset_id': datasetId || ''
});
},
},
created: function () {
this._facets = [];
Expand Down
28 changes: 26 additions & 2 deletions src/components/scripts/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,36 @@ const getBodyScaffoldInfo = async (sparcApi, species) => {
return {url, datasetInfo};
}

export {
// Array intersection
const intersectArrays = (arr1, arr2) => {
return arr1.filter((x) => arr2.includes(x));
};

// Not using URLSearchParams to avoid encoding spaces
const transformObjToString = (obj) => {
return Object.keys(obj)
.map((key) => `${key}=${obj[key]}`)
.join('&');
};

const transformStringToObj = (str) => {
const params = new URLSearchParams(str);
const obj = {};
for (const [key, value] of params) {
obj[key] = value;
}
return obj;
};

export {
availableSpecies,
capitalise,
findSpeciesKey,
initialState,
initialDefaultState,
getBodyScaffoldInfo,
getNewMapEntry
getNewMapEntry,
intersectArrays,
transformObjToString,
transformStringToObj,
}
31 changes: 31 additions & 0 deletions src/components/viewers/Flatmap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
:flatmapAPI="flatmapAPI"
:sparcAPI="apiLocation"
@open-map="openMap"
@pathway-selection-changed="onPathwaySelectionChanged"
/>
</template>

Expand All @@ -26,6 +27,7 @@ import { FlatmapVuer } from "@abi-software/flatmapvuer";
import EventBus from "../EventBus";
import ContentMixin from "../../mixins/ContentMixin";
import DynamicMarkerMixin from "../../mixins/DynamicMarkerMixin";
import { transformObjToString } from '../scripts/utilities';
import "@abi-software/flatmapvuer/dist/style.css";

export default {
Expand All @@ -50,6 +52,24 @@ export default {
flatmaprResourceSelected: function (type, resource) {
this.$refs.flatmap.resourceSelected(
type, resource, (this.$refs.map.viewingMode === "Exploration"));

if (resource.eventType === 'click' && resource.feature.type === 'feature') {
const eventData = {
label: resource.label || '',
id: resource.feature.id || '',
featureId: resource.feature.featureId || '',
taxonomy: resource.taxonomy || '',
resources: resource.resource.join(', ')
};
const paramString = transformObjToString(eventData);
// `transformStringToObj` function can be used to change it back to object
Tagging.sendEvent({
'event': 'interaction_event',
'event_name': 'portal_maps_connectivity',
'category': paramString,
"location": type + ' ' + this.$refs.map.viewingMode
});
}
},
flatmapReadyCall: function (flatmap) {
let provClone = {id: this.entry.id, prov: this.getFlatmapImp().provenance}; //create clone of provenance and add id
Expand All @@ -60,6 +80,17 @@ export default {
this.flatmapReadyForMarkerUpdates(flatmap);
}
},
onPathwaySelectionChanged: function (data) {
const { label, property, checked, selectionsTitle } = data;
// GA Tagging
// Event tracking for maps' pathway selection change
Tagging.sendEvent({
'event': 'interaction_event',
'event_name': 'portal_maps_pathway_change',
'category': label + ' [' + property + '] ' + checked,
'location': selectionsTitle
});
},
highlightFeatures: function(info) {
let name = info.name;
const flatmap = this.$refs.flatmap.mapImp;
Expand Down
Loading