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

[CHANGE][GWELLS-2186] Disabling Google Analytics #2216

Closed
Closed
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: 2 additions & 2 deletions app/backend/gwells/templates/gwells/base_spa.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<![endif]-->


{% if settings.ENABLE_GOOGLE_ANALYTICS %}
<!-- {% if settings.ENABLE_GOOGLE_ANALYTICS %}
<script>
(function(i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
Expand All @@ -68,7 +68,7 @@
ga('set', 'anonymizeIp', true);
ga('send', 'pageview');
</script>
{% endif %}
{% endif %} -->
</head>

<body class="gwells-body">
Expand Down
4 changes: 2 additions & 2 deletions app/frontend/src/aquifers/components/View.vue
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ export default {
this.waterWithdrawlVolume = sumBy(details.usage, 'total_qty')
}
},
// log a google analytics event when clicking on links to other sites
/* // log a google analytics event when clicking on links to other sites
handleOutboundLinkClicks (link) {
if (window.ga) {
window.ga('send', 'event', {
Expand All @@ -1003,7 +1003,7 @@ export default {
eventLabel: 'Aquifer Factsheet'
})
}
},
}, */
sanitizeResourceUrl (url) {
const sanitized = sanitizeUrl(url)
return encodeURI(sanitized)
Expand Down
16 changes: 8 additions & 8 deletions app/frontend/src/aquifers/store/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,14 @@ const aquiferSearchStore = {

// trigger the Google Analytics search event
// trigger the search event, sending along the search params as a string
if (window.ga) {
window.ga('send', {
hitType: 'event',
eventCategory: 'Button',
eventAction: 'AquiferSearch',
eventLabel: querystring.stringify(state.searchQuery)
})
}
// if (window.ga) {
// window.ga('send', {
// hitType: 'event',
// eventCategory: 'Button',
// eventAction: 'AquiferSearch',
// eventLabel: querystring.stringify(state.searchQuery)
// })
// }

if (state.pendingSearch) {
state.pendingSearch.cancel()
Expand Down
17 changes: 3 additions & 14 deletions app/frontend/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import * as Integrations from '@sentry/integrations'
import Vuex, { mapActions } from 'vuex'
import VueNoty from 'vuejs-noty'
import BootstrapVue from 'bootstrap-vue'
import VueAnalytics from 'vue-analytics'
import VueMatomo from 'vue-matomo'
import App from './App'
import router from './router.js'
Expand All @@ -37,9 +36,10 @@ import ApiService from '@/common/services/ApiService.js'

const PRODUCTION_GWELLS_URL = 'https://apps.nrs.gov.bc.ca/gwells'
const STAGING_GWELLS_URLS = ['testapps.nrs.gov.bc.ca', 'gwells-staging.apps.silver.devops.gov.bc.ca']
const isProduction = () => (window.location.href.substr(0, PRODUCTION_GWELLS_URL.length) === PRODUCTION_GWELLS_URL)
const BASE_PATH = '/gwells/'
const isProduction = () => (window.location.href.substring(0, PRODUCTION_GWELLS_URL.length) === PRODUCTION_GWELLS_URL)
const isStaging = () => (
window.location.pathname === '/gwells/' && STAGING_GWELLS_URLS.includes(window.location.hostname)
window.location.pathname.substring(0, BASE_PATH.length) === BASE_PATH && STAGING_GWELLS_URLS.includes(window.location.hostname)
)
if (isProduction()) {
Sentry.init({
Expand Down Expand Up @@ -69,16 +69,6 @@ Vue.component('form-input', FormInput)
// set baseURL and default headers
ApiService.init()

Vue.use(VueAnalytics, {
id: 'UA-106174915-1',
set: [
{ field: 'anonymizeIp', value: true }
],
disabled: ApiService.query('analytics', {}).then((response) => {
return response.data.enable_google_analytics !== true
})
})

if (isProduction()) {
Vue.use(VueMatomo, {
host: 'https://water-matomo.apps.silver.devops.gov.bc.ca/',
Expand Down Expand Up @@ -115,6 +105,5 @@ new Vue({
},
created () {
this.FETCH_CONFIG()
this.$ga.page()
}
})
22 changes: 11 additions & 11 deletions app/frontend/src/wells/components/SearchResultExports.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,18 @@ export default {
exportHandler(format) {
const exportUrl = this.getExportUrl(format);
ApiService.download(exportUrl);
this.sendAnalytics(format);
// this.sendAnalytics(format);
},
sendAnalytics (format) {
if (window.ga) {
window.ga('send', {
hitType: 'event',
eventCategory: 'Button',
eventAction: 'WellSearchResultsExtract',
eventLabel: format
})
}
}
// sendAnalytics (format) {
// if (window.ga) {
// window.ga('send', {
// hitType: 'event',
// eventCategory: 'Button',
// eventAction: 'WellSearchResultsExtract',
// eventLabel: format
// })
// }
// }
}
}
</script>
Expand Down
Loading