diff options
Diffstat (limited to 'app/assets/javascripts/tracking')
-rw-r--r-- | app/assets/javascripts/tracking/dispatch_snowplow_event.js | 7 | ||||
-rw-r--r-- | app/assets/javascripts/tracking/tracking.js | 6 |
2 files changed, 11 insertions, 2 deletions
diff --git a/app/assets/javascripts/tracking/dispatch_snowplow_event.js b/app/assets/javascripts/tracking/dispatch_snowplow_event.js index bc9d7384ea4..7e596f5f36f 100644 --- a/app/assets/javascripts/tracking/dispatch_snowplow_event.js +++ b/app/assets/javascripts/tracking/dispatch_snowplow_event.js @@ -10,7 +10,8 @@ export function dispatchSnowplowEvent( throw new Error('Tracking: no category provided for tracking.'); } - const { label, property, value, extra = {} } = data; + const { label, property, extra = {} } = data; + let { value } = data; const standardContext = getStandardContext({ extra }); const contexts = [standardContext]; @@ -19,5 +20,9 @@ export function dispatchSnowplowEvent( contexts.push(data.context); } + if (value !== undefined) { + value = Number(value); + } + return window.snowplow('trackStructEvent', category, action, label, property, value, contexts); } diff --git a/app/assets/javascripts/tracking/tracking.js b/app/assets/javascripts/tracking/tracking.js index c26abc261ed..173eef0646b 100644 --- a/app/assets/javascripts/tracking/tracking.js +++ b/app/assets/javascripts/tracking/tracking.js @@ -10,6 +10,8 @@ import { addReferrersCacheEntry, } from './utils'; +const ALLOWED_URL_HASHES = ['#diff', '#note']; + export default class Tracking { static queuedEvents = []; static initialized = false; @@ -183,7 +185,9 @@ export default class Tracking { originalUrl: window.location.href, }); - window.snowplow('setCustomUrl', pageLinks.url); + const appendHash = ALLOWED_URL_HASHES.some((prefix) => window.location.hash.startsWith(prefix)); + const customUrl = `${pageUrl}${appendHash ? window.location.hash : ''}`; + window.snowplow('setCustomUrl', customUrl); if (document.referrer) { const node = referrers.find((links) => links.originalUrl === document.referrer); |