From 2fbe751db2c2cb3db8dc607b99106f4e1cb9dea5 Mon Sep 17 00:00:00 2001
From: schneefux <schneefux+commit@schneefux.xyz>
Date: Fri, 13 Jul 2018 12:46:20 +0200
Subject: GA: Persist opt out

---
 src/IntroBox.vue | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

(limited to 'src/IntroBox.vue')

diff --git a/src/IntroBox.vue b/src/IntroBox.vue
index d146f2f..e0a1abb 100644
--- a/src/IntroBox.vue
+++ b/src/IntroBox.vue
@@ -13,7 +13,7 @@
         The data can be imprecise and can be contrary to your personal experience.
       </p>
       <p>
-        This site shares visitor data with Google Analytics and Google AdSense which store cookies. If you do not want that, you can <a @click="this.$ga.disable()">opt out of Google Analytics</a> and <a href="http://www.youronlinechoices.com/">opt out of targeted advertisements</a>.
+      This site shares visitor data with Google Analytics and Google AdSense which store cookies. If you do not want that, you can <a @click="optOutAnalytics()">opt out of Google Analytics</a><span v-if="gaOptedOut"> (Google Analytics is disabled for you)</span> and <a href="http://www.youronlinechoices.com/">opt out of targeted advertisements</a>.
       </p>
     </div>
   </div>
@@ -28,12 +28,27 @@ export default Vue.component('intro-box', {
   data: function() {
     return {
       hideIntro: !!localStorage.getItem('hideIntro'),
+      gaOptedOut: !!localStorage.getItem('gaOptOut'),
     };
   },
+  methods: {
+    optOutAnalytics: function() {
+      this.$ga.disable();
+      this.gaOptedOut = true;
+    },
+  },
+  created: function() {
+    if (this.gaOptedOut) {
+      this.$ga.disable();
+    }
+  },
   watch: {
     hideIntro: function(value) {
       localStorage.setItem('hideIntro', value);
     },
+    gaOptedOut: function(value) {
+      localStorage.setItem('gaOptOut', value);
+    },
     selectedMode: function(value) {
       this.hideIntro = !!localStorage.getItem('hideIntro');
     },
-- 
cgit v1.3.1

