fix(privacy): wire up modal

This commit is contained in:
Kalista Payne
2025-08-28 17:41:38 -05:00
parent a32fadbcbd
commit 7a65bc2d8d
3 changed files with 34 additions and 6 deletions

View File

@@ -98,6 +98,9 @@ export default {
) { ) {
this.hidden = true; this.hidden = true;
} }
this.$root.$on('privacy-complete', () => {
this.close();
});
}, },
methods: { methods: {
close () { close () {

View File

@@ -21,7 +21,9 @@
<label class="mb-0"> <label class="mb-0">
{{ $t('performanceAnalytics') }} {{ $t('performanceAnalytics') }}
</label> </label>
<toggle-switch /> <toggle-switch
v-model="privacyConsent"
/>
</div> </div>
<small> <small>
{{ $t('usedForSupport') }} {{ $t('usedForSupport') }}
@@ -44,13 +46,22 @@
</small> </small>
</div> </div>
<div class="d-flex flex-column text-center"> <div class="d-flex flex-column text-center">
<button class="btn btn-primary mb-2"> <button
class="btn btn-primary mb-2"
@click="consent(true)"
>
{{ $t('acceptAllCookies') }} {{ $t('acceptAllCookies') }}
</button> </button>
<button class="btn btn-secondary mb-2"> <button
class="btn btn-primary mb-2"
@click="consent(false)"
>
{{ $t('denyNonEssentialCookies') }} {{ $t('denyNonEssentialCookies') }}
</button> </button>
<button class="btn btn-secondary mb-3"> <button
class="btn btn-secondary mb-3"
@click="consent(privacyConsent)"
>
{{ $t('savePreferences') }} {{ $t('savePreferences') }}
</button> </button>
<a <a
@@ -92,7 +103,17 @@ export default {
closeX, closeX,
ToggleSwitch, ToggleSwitch,
}, },
data () {
return {
privacyConsent: true,
};
},
methods: { methods: {
consent (decision) {
localStorage.setItem('analyticsConsent', decision);
this.$root.$emit('privacy-complete');
this.close();
},
close () { close () {
this.$root.$emit('bv::hide::modal', 'privacy-preferences'); this.$root.$emit('bv::hide::modal', 'privacy-preferences');
}, },

View File

@@ -80,7 +80,9 @@ export function track (properties, options = {}) {
// Track events on the server by default // Track events on the server by default
if (trackOnClient === true) { if (trackOnClient === true) {
amplitude.getInstance().logEvent(properties.eventAction, properties); amplitude.getInstance().logEvent(properties.eventAction, properties);
window.gtag('event', properties.eventAction, properties); if (window.gtag) {
window.gtag('event', properties.eventAction, properties);
}
} else { } else {
const store = getStore(); const store = getStore();
store.dispatch('analytics:trackEvent', properties); store.dispatch('analytics:trackEvent', properties);
@@ -94,7 +96,9 @@ export function updateUser (properties = {}) {
// Use nextTick to avoid blocking the UI // Use nextTick to avoid blocking the UI
Vue.nextTick(() => { Vue.nextTick(() => {
_gatherUserStats(properties); _gatherUserStats(properties);
window.gtag('set', 'user_properties', properties); if (window.gtag) {
window.gtag('set', 'user_properties', properties);
}
forEach(properties, (value, key) => { forEach(properties, (value, key) => {
const identify = new amplitude.Identify().set(key, value); const identify = new amplitude.Identify().set(key, value);
amplitude.getInstance().identify(identify); amplitude.getInstance().identify(identify);