[tor-commits] [metrics-web/master] Add webstats-tb-platform graph.

karsten at torproject.org karsten at torproject.org
Fri Feb 3 15:04:04 UTC 2017


commit fd5f640af28b4854b3e3cc999a51a37dc0267a53
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Thu Feb 2 20:31:01 2017 +0100

    Add webstats-tb-platform graph.
---
 website/etc/categories.json |  1 +
 website/etc/metrics.json    | 14 ++++++++++++++
 website/etc/web.xml         |  4 ++++
 website/rserve/graphs.R     | 29 +++++++++++++++++++++++++++++
 4 files changed, 48 insertions(+)

diff --git a/website/etc/categories.json b/website/etc/categories.json
index 134ef44..de10ceb 100644
--- a/website/etc/categories.json
+++ b/website/etc/categories.json
@@ -81,6 +81,7 @@
     "description": "The following application statistics are based on the analysis of requests to <code>torproject.org</code> web servers.",
     "metrics": [
       "webstats-tb",
+      "webstats-tb-platform",
       "webstats-tb-locale",
       "webstats-tm"
     ]
diff --git a/website/etc/metrics.json b/website/etc/metrics.json
index 41e2c6f..2af4bf6 100644
--- a/website/etc/metrics.json
+++ b/website/etc/metrics.json
@@ -418,6 +418,20 @@
     ]
   },
   {
+    "id": "webstats-tb-platform",
+    "title": "Tor Browser downloads by platform",
+    "type": "Graph",
+    "description": "<p>This graph shows absolute numbers of requests to Tor's web servers by request type.  It is based on data from <a href=\"https://webstats.torproject.org/\" target=\"_blank\"><code>webstats.torproject.org</code></a> which collects logs from <code>torproject.org</code> web servers and provides them as a stripped-down version of Apache's \"combined\" log format without IP addresses, log times, HTTP parameters, referers, and user agent strings.  All shown requests are requests made by the user to download a Tor Browser executable from the Tor website, broken down by platform of the requested executable.</p>",
+    "function": "plot_webstats_tb_platform",
+    "parameters": [
+      "start",
+      "end"
+    ],
+    "data": [
+      "webstats"
+    ]
+  },
+  {
     "id": "webstats-tb-locale",
     "title": "Tor Browser downloads by locale",
     "type": "Graph",
diff --git a/website/etc/web.xml b/website/etc/web.xml
index 9e42aa5..bd7f4f1 100644
--- a/website/etc/web.xml
+++ b/website/etc/web.xml
@@ -47,6 +47,7 @@
     <url-pattern>/hidserv-rend-relayed-cells.html</url-pattern>
     <url-pattern>/hidserv-frac-reporting.html</url-pattern>
     <url-pattern>/webstats-tb.html</url-pattern>
+    <url-pattern>/webstats-tb-platform.html</url-pattern>
     <url-pattern>/webstats-tb-locale.html</url-pattern>
     <url-pattern>/webstats-tm.html</url-pattern>
   </servlet-mapping>
@@ -183,6 +184,9 @@
     <url-pattern>/webstats-tb.png</url-pattern>
     <url-pattern>/webstats-tb.pdf</url-pattern>
     <url-pattern>/webstats-tb.svg</url-pattern>
+    <url-pattern>/webstats-tb-platform.png</url-pattern>
+    <url-pattern>/webstats-tb-platform.pdf</url-pattern>
+    <url-pattern>/webstats-tb-platform.svg</url-pattern>
     <url-pattern>/webstats-tb-locale.png</url-pattern>
     <url-pattern>/webstats-tb-locale.pdf</url-pattern>
     <url-pattern>/webstats-tb-locale.svg</url-pattern>
diff --git a/website/rserve/graphs.R b/website/rserve/graphs.R
index 1b232f4..4c2f45e 100644
--- a/website/rserve/graphs.R
+++ b/website/rserve/graphs.R
@@ -1126,6 +1126,35 @@ plot_webstats_tb <- function(start, end, path) {
   ggsave(filename = path, width = 8, height = 5, dpi = 72)
 }
 
+plot_webstats_tb_platform <- function(start, end, path) {
+  end <- min(end, as.character(Sys.Date() - 2))
+  d <- read.csv(paste("/srv/metrics.torproject.org/metrics/shared/stats/",
+                "webstats.csv", sep = ""), stringsAsFactors = FALSE)
+  d <- d[d$log_date >= start & d$log_date <= end & d$request_type == 'tbid', ]
+  d <- aggregate(list(count = d$count), by = list(log_date = as.Date(d$log_date),
+    platform = d$platform), FUN = sum)
+  date_breaks <- date_breaks(as.numeric(max(d$log_date) - min(d$log_date)))
+  formatter <- function(x, ...) {
+    format(x, ..., scientific = FALSE, big.mark = ' ') }
+  ggplot(d, aes(x = log_date, y = count, colour = platform)) +
+    geom_point() +
+    geom_line() +
+    expand_limits(y = 0) +
+    scale_x_date(name = paste("\nThe Tor Project - ",
+        "https://metrics.torproject.org/", sep = ""),
+        labels = date_format(date_breaks$format),
+        breaks = date_breaks$major,
+        minor_breaks = date_breaks$minor) +
+    scale_y_continuous(name = 'Requests per day\n', labels = formatter) +
+    scale_colour_hue(name = "Platform",
+        breaks = c("w", "m", "l", "o", ""),
+        labels = c("Windows", "Mac", "Linux", "Other", "Unknown")) +
+    theme(strip.text.y = element_text(angle = 0, hjust = 0, size = rel(1.5)),
+          strip.background = element_rect(fill = NA)) +
+    ggtitle("Tor Browser downloads by platform\n")
+  ggsave(filename = path, width = 8, height = 5, dpi = 72)
+}
+
 plot_webstats_tb_locale <- function(start, end, path) {
   end <- min(end, as.character(Sys.Date() - 2))
   d <- read.csv(paste("/srv/metrics.torproject.org/metrics/shared/stats/",





More information about the tor-commits mailing list