When we track a page view that has no arguments, the default behaviour
is for the trackers to work out the path by themselves from the
window.location. In order for us to strip PII though we need to build an
argument ourselves so we have something to strip PII from, and we then
inject that into the arguments we send to the trackers. Prior to this
change we were sending a full url, but the GA docs say that this argument
should be a path, not a full url.
In order to test this (stubbing window.location apears to be painful) we
make the defaultPathForTrackPageview function take a location object,
and we pass window.location into it at the call-sites. The tests can
now pass an object in and we can test the function properly. These tests
are a bit brittle because the location object we use only has the
properties we use.
Page view analytics sent without this (e.g. using 7.3.0 and 7.4.0) are
broken without this change.
For: https://trello.com/c/vISRi8lY/58-investigate-preventing-pii-being-sent-to-ga
When we track a page view that has no arguments, the default behaviour is for the trackers to work out the path by themselves from the window.location. In order for us to strip PII though we need to build an argument ourselves so we have something to strip PII from, and we then inject that into the arguments we send to the trackers. Prior to this change we were sending a full url, but the GA docs say that this argument should be a path, not a full url.
In order to test this (stubbing window.location apears to be painful) we make the
defaultPathForTrackPageview
function take a location object, and we passwindow.location
into it at the call-sites. The tests can now pass an object in and we can test the function properly. These tests are a bit brittle because the location object we use only has the properties we use.Page view analytics sent without this (e.g. using 7.3.0 and 7.4.0) are broken without this change.