aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--perllib/FixMyStreet/App/Controller/Location.pm20
-rw-r--r--perllib/FixMyStreet/Geocode/Bexley.pm2
-rw-r--r--perllib/FixMyStreet/Geocode/Bing.pm1
-rw-r--r--perllib/FixMyStreet/Geocode/Google.pm1
-rw-r--r--perllib/FixMyStreet/Geocode/OSM.pm1
-rw-r--r--perllib/FixMyStreet/Geocode/Zurich.pm1
7 files changed, 27 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4644e6a69..2ac73269b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -149,6 +149,7 @@
- Make front page cache time configurable.
- Better working of /fakemapit/ under https.
- Improve Open311 error output on failing GET requests.
+ - Optionally log failed geocoder searches.
- Backwards incompatible changes:
- If you wish the default for the showname checkbox to be checked,
add `sub default_show_name { 1 }` to your cobrand file.
diff --git a/perllib/FixMyStreet/App/Controller/Location.pm b/perllib/FixMyStreet/App/Controller/Location.pm
index 8d5b0b147..81c2c33fc 100644
--- a/perllib/FixMyStreet/App/Controller/Location.pm
+++ b/perllib/FixMyStreet/App/Controller/Location.pm
@@ -6,6 +6,7 @@ BEGIN {extends 'Catalyst::Controller'; }
use Encode;
use FixMyStreet::Geocode;
+use Try::Tiny;
use Utils;
=head1 NAME
@@ -107,6 +108,25 @@ sub determine_location_from_pc : Private {
# pass errors back to the template
$c->stash->{location_error_pc_lookup} = 1;
$c->stash->{location_error} = $error;
+
+ # Log failure in a log db
+ try {
+ my $dbfile = FixMyStreet->path_to('../data/analytics.sqlite');
+ my $db = DBI->connect("dbi:SQLite:dbname=$dbfile", undef, undef) or die "$DBI::errstr\n";
+ my $sth = $db->prepare("INSERT INTO location_searches_with_no_results
+ (datetime, cobrand, geocoder, url, user_input)
+ VALUES (?, ?, ?, ?, ?)") or die $db->errstr . "\n";
+ my $rv = $sth->execute(
+ POSIX::strftime("%Y-%m-%d %H:%M:%S", localtime(time())),
+ $c->cobrand->moniker,
+ $c->cobrand->get_geocoder(),
+ $c->stash->{geocoder_url},
+ $pc,
+ );
+ } catch {
+ $c->log->debug("Unable to log to analytics.sqlite: $_");
+ };
+
return;
}
diff --git a/perllib/FixMyStreet/Geocode/Bexley.pm b/perllib/FixMyStreet/Geocode/Bexley.pm
index a70a42cd1..8a1a886bb 100644
--- a/perllib/FixMyStreet/Geocode/Bexley.pm
+++ b/perllib/FixMyStreet/Geocode/Bexley.pm
@@ -23,6 +23,8 @@ sub string {
my $js = query_layer($s);
return $osm unless $js && @{$js->{features}};
+ $c->stash->{geocoder_url} = $s;
+
my ( $error, @valid_locations, $latitude, $longitude, $address );
foreach (sort { $a->{properties}{ADDRESS} cmp $b->{properties}{ADDRESS} } @{$js->{features}}) {
my @lines = @{$_->{geometry}{coordinates}};
diff --git a/perllib/FixMyStreet/Geocode/Bing.pm b/perllib/FixMyStreet/Geocode/Bing.pm
index ee5e15f8c..1d39d911f 100644
--- a/perllib/FixMyStreet/Geocode/Bing.pm
+++ b/perllib/FixMyStreet/Geocode/Bing.pm
@@ -38,6 +38,7 @@ sub string {
$url .= '&userLocation=' . $params->{centre} if $params->{centre};
$url .= '&c=' . $params->{bing_culture} if $params->{bing_culture};
+ $c->stash->{geocoder_url} = $url;
my $js = FixMyStreet::Geocode::cache('bing', $url, 'key=' . FixMyStreet->config('BING_MAPS_API_KEY'));
if (!$js) {
return { error => _('Sorry, we could not parse that location. Please try again.') };
diff --git a/perllib/FixMyStreet/Geocode/Google.pm b/perllib/FixMyStreet/Geocode/Google.pm
index 455d9cec0..ffbad96ba 100644
--- a/perllib/FixMyStreet/Geocode/Google.pm
+++ b/perllib/FixMyStreet/Geocode/Google.pm
@@ -49,6 +49,7 @@ sub string {
$url .= '&components=' . $components if $components;
+ $c->stash->{geocoder_url} = $url;
my $args = 'key=' . FixMyStreet->config('GOOGLE_MAPS_API_KEY');
my $js = FixMyStreet::Geocode::cache('google', $url, $args, qr/"status"\s*:\s*"(OVER_QUERY_LIMIT|REQUEST_DENIED|INVALID_REQUEST|UNKNOWN_ERROR)"/);
if (!$js) {
diff --git a/perllib/FixMyStreet/Geocode/OSM.pm b/perllib/FixMyStreet/Geocode/OSM.pm
index b979e2a10..20e653cf6 100644
--- a/perllib/FixMyStreet/Geocode/OSM.pm
+++ b/perllib/FixMyStreet/Geocode/OSM.pm
@@ -47,6 +47,7 @@ sub string {
if $params->{country};
$url .= join('&', map { "$_=$query_params{$_}" } sort keys %query_params);
+ $c->stash->{geocoder_url} = $url;
my $js = FixMyStreet::Geocode::cache('osm', $url);
if (!$js) {
return { error => _('Sorry, we could not find that location.') };
diff --git a/perllib/FixMyStreet/Geocode/Zurich.pm b/perllib/FixMyStreet/Geocode/Zurich.pm
index 0b85ab7b2..b0c0b528e 100644
--- a/perllib/FixMyStreet/Geocode/Zurich.pm
+++ b/perllib/FixMyStreet/Geocode/Zurich.pm
@@ -97,6 +97,7 @@ sub string {
my $cache_dir = path(FixMyStreet->config('GEO_CACHE'), 'zurich')->absolute(FixMyStreet->path_to());
my $cache_file = $cache_dir->child(md5_hex($s));
my $result;
+ $c->stash->{geocoder_url} = $s;
if (-s $cache_file && -M $cache_file <= 7 && !FixMyStreet->config('STAGING_SITE')) {
$result = retrieve($cache_file);
} else {