Skip to content

Commit

Permalink
fix google analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
bmesuere committed Jul 28, 2023
1 parent f7a3d3f commit 1b430fb
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
1 change: 1 addition & 0 deletions dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"roboto-fontface": "*",
"topojson-client": "^3.1.0",
"vue": "^3.2.0",
"vue-gtag-next": "^1.14.0",
"vue-router": "^4.0.0",
"vuetify": "^3.0.0",
"webfontloader": "^1.0.0"
Expand Down
6 changes: 3 additions & 3 deletions dashboard/src/components/StationCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ import { computed, PropType } from 'vue';
import { useVlinderStore } from '@/store/app';
//import { event } from 'vue-gtag';
import { useGtag } from 'vue-gtag-next';
import LandUseGraph from './LandUseGraph.vue';
Expand Down Expand Up @@ -117,8 +117,8 @@ const activeProperties = computed<WeatherProperty[]>(() => {
});
function removeFromList() {
// TODO
//event('station_deselect', { event_category: 'stations', value: props.station.id });
const { event } = useGtag()
event('station_deselect', { event_category: 'stations', value: props.station.id });
vlinderStore.deselectStationById(props.station.id);
}
</script>
8 changes: 5 additions & 3 deletions dashboard/src/components/StationsMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { computed, onMounted, ref, watch } from 'vue';
import { useVlinderStore } from '@/store/app';
//import { event } from 'vue-gtag';
import { useGtag } from 'vue-gtag-next';
import TooltipCard from './TooltipCard.vue';
Expand Down Expand Up @@ -73,7 +73,8 @@ onMounted(async () => {
// adds or removes a station to the list of selected stations
function toggleStation (stationId: string): void {
//event('station_toggle', { event_category: 'stations', value: stationId });
const { event } = useGtag();
event('station_toggle', { event_category: 'stations', value: stationId });
vlinderStore.toggleStationById(stationId);
}
Expand All @@ -86,7 +87,8 @@ watch(selectedStations, () => {
// when a different property is selected, we have to manually update the D3 map
watch(selectedProperty, () => {
//event('property_change', { event_category: 'properties', value: selectedProperty.value });
const { event } = useGtag();
event('property_change', { event_category: 'properties', value: selectedProperty.value });
if (map) {
map.updateProperty(selectedProperty.value);
}
Expand Down
6 changes: 6 additions & 0 deletions dashboard/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@ import { createApp } from 'vue'
// Plugins
import { registerPlugins } from '@/plugins'

import VueGtag from "vue-gtag-next";

import router from '@/router'

const app = createApp(App)

registerPlugins(app)

app.use(VueGtag, {
property: { id: 'G-YY7WRV394E' },
})

app.use(router)

app.mount('#app')
5 changes: 3 additions & 2 deletions dashboard/src/views/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import StationSelector from '@/components/StationSelector.vue';
import StationCard from '@/components/StationCard.vue';
import StationsMap from '@/components/StationsMap.vue';
import { useGtag } from 'vue-gtag-next';
import { weatherProperties as wp } from '../app/weatherProperties';
Expand Down Expand Up @@ -154,8 +155,8 @@ function scheduleFetch(f: Function): void {
}, 60000);
}
function removeFromList (id: string): void {
//TODO
//event('station_deselect', { event_category: 'stations', value: id });
const { event } = useGtag()
event('station_deselect', { event_category: 'stations', value: id });
vlinderStore.deselectStationById(id);
}
</script>
5 changes: 5 additions & 0 deletions dashboard/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1992,6 +1992,11 @@ vue-eslint-parser@^9.1.1, vue-eslint-parser@^9.3.0:
lodash "^4.17.21"
semver "^7.3.6"

vue-gtag-next@^1.14.0:
version "1.14.0"
resolved "https://registry.yarnpkg.com/vue-gtag-next/-/vue-gtag-next-1.14.0.tgz#793aef0b90dff4213b9f3a79827cd99b06e678dd"
integrity sha512-iJl+cOG2GU5NuxqzSSIpt03WVOvZqyKB9TOy7d55KiuvRklcnb2nlqxW5B/a3/sbIt7fla+XEkRyMCcoz0zAHw==

vue-router@^4.0.0:
version "4.2.4"
resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-4.2.4.tgz#382467a7e2923e6a85f015d081e1508052c191b9"
Expand Down

0 comments on commit 1b430fb

Please sign in to comment.