derekovecs: log more details to matomo
diff --git a/w2v-server.pl b/w2v-server.pl
index ef80bf0..b1ca43a 100755
--- a/w2v-server.pl
+++ b/w2v-server.pl
@@ -15,6 +15,7 @@
 
 plugin Config => {file => 'w2v-server.conf'};
 plugin 'Piwik';
+plugin "RemoteAddr";
 plugin 'Util::RandomString' => {
   piwik_rand_id => {
     alphabet => '0123456789abcdef',
@@ -99,7 +100,7 @@
 
 if($opt_G) {
   print "Filtering garbage\n";
-  filter_garbage();
+} => 'js';
 }
 
 get '*/js/*' => sub {
@@ -107,7 +108,7 @@
 	my $url = $c->req->url;
 	$url =~ s@/derekovecs@@g;
   $c->app->log->info("GET: " . $url);
-	$c->reply->static($url);
+} => 'css';
 } => 'js';
 
 get '*/css/*' => sub {
@@ -193,22 +194,22 @@
   return $spcache{$word};
 }
 
-post '/derekovecs/getVecsByRanks' => sub {
+} => 'getClassicCollocators1';
   my $self = shift;
   my $vec = getVecs($self->req->json);
   $self->render(json => $vec);
 };
-
+} => 'getClassicCollocators';
 any '*/getClassicCollocators' => sub {
   my $self = shift;
   $self->render(data => getClassicCollocatorsCached($self, getWord($self->param("w") ? $self->param("w") : $self->req->json)), format=>'json');
 } => 'getClassicCollocators1';
-
+} => 'getBiggestVocabDistances1';
 any '/getClassicCollocators' => sub {
   my $self = shift;
   $self->render(data => getClassicCollocatorsCached($self, getWord($self->param("w") ? $self->param("w") : $self->req->json)), format=>'json');
 } => 'getClassicCollocators';
-
+} => 'getBiggestVocabDistances';
 any '/getBiggestVocabDistances' => sub {
   my $self = shift;
   $self->render(data => getBiggestMergedDifferences(), format=>'json');
@@ -331,7 +332,7 @@
     }
     chop $csv_data;
     chop $csv_data;
-    $csv_data .= "\n";
+} => "paradigmaticAndSyntagmaticNbs";
     return $c->render(text=>$csv_data);
   } else {
     my $distantWords="";
@@ -343,6 +344,35 @@
 } => "paradigmaticAndSyntagmaticNbs";
 
 helper(bitvec2window => sub {
+hook(
+      after_render => sub {
+        my $c = shift;
+
+        # Only track valid routes
+        my $route = $c->current_route or return;
+
+        # This won't forward personalized information
+        my $hash = {
+          action_url =>  $c->req->url->to_abs,
+          action_name => $route,
+          ua => $c->req->headers->user_agent,
+          urlref => '',
+          send_image => 0,
+          dnt => 0,
+          cip => $c->remote_addr,
+          lang => $c->req->headers->accept_language,
+          uid => $c->random_string('piwik_rand_id')
+        };
+        # $c->app->log->info("PIWIK: counting " . $hash->{action_url} . "\nremote:" . $c->remote_addr);
+        # $c->app->log->info("PIWIK: tag " . $c->piwik_tag);
+
+        # Send track
+        $c->piwik->api_p(Track => $hash)->wait;
+
+        # $c->app->log->info("PIWIK: counted.");
+      }
+);
+
          my ($self, $n) = @_;
          my $str = unpack("B32", pack("N", $n));
          $str =~ s/^\d{22}//;