How to use the watchtower.conf.SITE_SLUG 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 / db / redis / __init__.py View on Github external
def getHits(r):
    prefix = SITE_SLUG + "_hit*"
    hits = []
    for key in r.scan_iter(prefix):
        val = r.get(key)
        r.delete(key)
        hit = decodeHitRow(val)
        hits.append(hit)
    return hits
github synw / django-watchtower / watchtower / serializer.py View on Github external
def pack(data):
    global G
    sep = "#!#"
    h = (
        SITE_SLUG,
        data["path"],
        data["method"],
        data["ip"],
        data["user_agent"],
        str(data["is_authenticated"]).lower(),
        str(data["is_staff"]).lower(),
        str(data["is_superuser"]).lower(),
        data["user"],
        data["referer"],
        data["view"],
        data["module"],
        str(data["status_code"]),
        data["reason_phrase"],
        str(data["request_time"]),
        str(data["doc_size"]),
        str(data["num_queries"]),
github synw / django-watchtower / watchtower / middleware.py View on Github external
data["num_queries"] = num_queries
        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
github synw / django-watchtower / watchtower / db / influx / __init__.py View on Github external
def process_hits(hits):
    points = []
    for hit in hits:
        data = {
            "measurement": "hits",
            "tags": {
                "service": "django",
                "domain": SITE_SLUG,
                "user": hit["user"],
                "path": hit["path"],
                "referer": hit["referer"],
                "user_agent": hit["user_agent"],
                "method": hit["method"],
                "authenticated": hit["is_authenticated"],
                "staff": hit["is_staff"],
                "superuser": hit["is_superuser"],
                "status_code": hit["status_code"],
                "view": hit["view"],
                "module": hit["module"],
                "ip": hit["ip"],
                "os": hit["ua"]["os"],
                "os_version": hit["ua"]["os_version"],
                "is_pc": hit["ua"]["is_pc"],
                "is_bot": hit["ua"]["is_bot"],