Commit fd80c46c authored by Mikko Ahlroth's avatar Mikko Ahlroth

Hopefully fix getting referrer from wrong place

Referrer must be sent with JS as obviously when sending the request the
referrer is the sending page, not the original referrer.
parent 47c05c24
......@@ -17,7 +17,7 @@ defmodule Tilastokeskus.Reception.Routes.PageView do
addr = get_addr(req)
ua = parse_ua(req)
{referrer, referrer_noq, referrer_domain} = parse_referrer(req)
{referrer, referrer_noq, referrer_domain} = parse_referrer(body)
screen_w = Map.get(body, "screen_width")
screen_h = Map.get(body, "screen_height")
......@@ -145,8 +145,8 @@ defmodule Tilastokeskus.Reception.Routes.PageView do
|> UAInspector.parse()
end
defp parse_referrer(req) do
referrer = Raxx.get_header(req, "referer", nil)
defp parse_referrer(body) do
referrer = Map.get(body, "referrer")
case referrer do
nil ->
......
......@@ -122,6 +122,10 @@ SOFTWARE.
data.tz_offset = (new Date()).getTimezoneOffset();
data.url = window.location.href;
if ('referrer' in document && document.referrer != null) {
data.referrer = document.referrer;
}
var data_parts = [];
function add_part(source, key, parts) {
......@@ -132,6 +136,7 @@ SOFTWARE.
add_part(data, 'screen_height', data_parts);
add_part(data, 'tz_offset', data_parts);
add_part(data, 'url', data_parts);
add_part(data, 'referrer', data_parts);
var data_str = data_parts.join('&');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment