Skip to content
Snippets Groups Projects
Unverified Commit ae70d158 authored by Alexander Polyankin's avatar Alexander Polyankin Committed by GitHub
Browse files

Sanitize tracking urls (#19907)

parent de54fdd1
No related branches found
No related tags found
No related merge requests found
......@@ -22,11 +22,11 @@ export const trackPageView = url => {
}
if (Settings.googleAnalyticsEnabled()) {
trackGoogleAnalyticsPageView(url);
trackGoogleAnalyticsPageView(getSanitizedUrl(url));
}
if (Settings.snowplowEnabled()) {
trackSnowplowPageView(url);
trackSnowplowPageView(getSanitizedUrl(url));
}
};
......@@ -115,10 +115,8 @@ const createSnowplowPlugin = store => {
};
const trackSnowplowPageView = url => {
const maskedUrl = new URL(url, Settings.snowplowUrl());
Snowplow.setReferrerUrl("#");
Snowplow.setCustomUrl(maskedUrl.href);
Snowplow.setCustomUrl(url);
Snowplow.trackPageView();
};
......@@ -143,3 +141,10 @@ const handleStructEventClick = event => {
}
}
};
const getSanitizedUrl = url => {
const urlWithoutSlug = url.replace(/(\/\d+)-[^\/]+$/, (match, path) => path);
const urlWithoutHost = new URL(urlWithoutSlug, Settings.snowplowUrl());
return urlWithoutHost.href;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment