From d28fe1a1b4c330c4894fd9219aa99d95a083fbc0 Mon Sep 17 00:00:00 2001 From: "R. Miles McCain" Date: Thu, 16 Apr 2020 09:42:43 -0400 Subject: [PATCH] Improve resiliency --- shynet/analytics/tasks.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/shynet/analytics/tasks.py b/shynet/analytics/tasks.py index 886c802..eb81d76 100644 --- a/shynet/analytics/tasks.py +++ b/shynet/analytics/tasks.py @@ -51,6 +51,10 @@ def ingress_request( ip_data = _geoip2_lookup(ip) log.debug(f"Found geoip2 data") + # Validate payload + if payload.get("loadTime", 1) <= 0: + payload["loadTime"] = None + # Create or update session session = ( Session.objects.filter( @@ -59,8 +63,10 @@ def ingress_request( ip=ip, user_agent=user_agent, ) - .filter(Q(identifier=identifier) | Q(identifier="")) .first() + # We used to check for identifiers, but that can cause issues when people + # re-open the page in a new tab, for example. It's better to match sessions + # solely based on IP and user agent. ) if session is None: log.debug("Cannot link to existing session; creating a new one...")