How to use the watchtower.serializer.getGeoData function in watchtower

To help you get started, we’ve selected a few watchtower examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github synw / django-watchtower / watchtower / middleware.py View on Github external
data["content_length"] = doc_size
        ua = {
            "is_mobile": request.user_agent.is_mobile,
            "is_pc": request.user_agent.is_pc,
            "is_tablet": request.user_agent.is_tablet,
            "is_bot": request.user_agent.is_bot,
            "is_touch": request.user_agent.is_touch_capable,
            "browser": request.user_agent.browser.family,
            "browser_version": request.user_agent.browser.version_string,
            "os": request.user_agent.os.family,
            "os_version": request.user_agent.os.version_string,
            "device": request.user_agent.device.family,
        }
        data["ua"] = ua
        name = CONF.SITE_SLUG + "_hit" + str(HITNUM)
        data["geo"] = serializer.getGeoData(data['ip'])
        if CONF.COLLECTOR is True:
            hit = serializer.pack(data)
            R.set(name, hit)
        else:
            thread = Thread(target=dispatch, args=([data],))
            thread.start()
        HITNUM += 1
        return response