summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xsynapse/app/homeserver.py10
-rw-r--r--synapse/config/server.py3
-rw-r--r--synapse/storage/__init__.py4
3 files changed, 10 insertions, 7 deletions
diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py
index f3ac3d19f0..ffaa0ae94a 100755
--- a/synapse/app/homeserver.py
+++ b/synapse/app/homeserver.py
@@ -500,11 +500,11 @@ def run(hs):
             "generate_user_daily_visits",
             hs.get_datastore().generate_user_daily_visits,
         )
-
-    # Rather than update on per session basis, batch up the requests.
-    # If you increase the loop period, the accuracy of user_daily_visits
-    # table will decrease
-    clock.looping_call(generate_user_daily_visit_stats, 5 * 60 * 1000)
+    if hs.config.store_user_daily_visits:
+        # Rather than update on per session basis, batch up the requests.
+        # If you increase the loop period, the accuracy of user_daily_visits
+        # table will decrease
+        clock.looping_call(generate_user_daily_visit_stats, 5 * 60 * 1000)
 
     # monthly active user limiting functionality
     def reap_monthly_active_users():
diff --git a/synapse/config/server.py b/synapse/config/server.py
index 120c2b81fc..809f75cae4 100644
--- a/synapse/config/server.py
+++ b/synapse/config/server.py
@@ -97,6 +97,9 @@ class ServerConfig(Config):
         self.hs_disabled_message = config.get("hs_disabled_message", "")
         self.hs_disabled_limit_type = config.get("hs_disabled_limit_type", "")
 
+        # User stats
+        self.store_user_daily_visits = config.get("store_user_daily_visits", False)
+
         # Admin uri to direct users at should their instance become blocked
         # due to resource constraints
         self.admin_contact = config.get("admin_contact", None)
diff --git a/synapse/storage/__init__.py b/synapse/storage/__init__.py
index 24329879e5..ce9f9d0094 100644
--- a/synapse/storage/__init__.py
+++ b/synapse/storage/__init__.py
@@ -372,8 +372,8 @@ class DataStore(RoomMemberStore, RoomStore,
             now = self.clock.time_msec()
 
             sql = """
-                INSERT INTO user_daily_visits (user_id, device_id, timestamp)
-                    SELECT u.user_id, u.device_id, ?
+                INSERT INTO user_daily_visits (user_id, device_id, timestamp, user_agent)
+                    SELECT u.user_id, u.device_id, ?, u.user_agent
                     FROM user_ips AS u
                     LEFT JOIN (
                       SELECT user_id, device_id, timestamp FROM user_daily_visits