diff options
Diffstat (limited to 'app/assets/javascripts/entrypoints/tracker.js')
-rw-r--r-- | app/assets/javascripts/entrypoints/tracker.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/app/assets/javascripts/entrypoints/tracker.js b/app/assets/javascripts/entrypoints/tracker.js new file mode 100644 index 00000000000..91d19d249b3 --- /dev/null +++ b/app/assets/javascripts/entrypoints/tracker.js @@ -0,0 +1,50 @@ +import { + newTracker, + enableActivityTracking, + trackPageView, + setDocumentTitle, + trackStructEvent, + setCustomUrl, + setReferrerUrl, +} from '@snowplow/browser-tracker'; +import { + enableLinkClickTracking, + LinkClickTrackingPlugin, +} from '@snowplow/browser-plugin-link-click-tracking'; +import { enableFormTracking, FormTrackingPlugin } from '@snowplow/browser-plugin-form-tracking'; +import { TimezonePlugin } from '@snowplow/browser-plugin-timezone'; +import { GaCookiesPlugin } from '@snowplow/browser-plugin-ga-cookies'; +import { PerformanceTimingPlugin } from '@snowplow/browser-plugin-performance-timing'; +import { ClientHintsPlugin } from '@snowplow/browser-plugin-client-hints'; + +const SNOWPLOW_ACTIONS = { + newTracker, + enableActivityTracking, + trackPageView, + setDocumentTitle, + trackStructEvent, + enableLinkClickTracking, + enableFormTracking, + setCustomUrl, + setReferrerUrl, +}; + +window.snowplow = (action, ...config) => { + if (SNOWPLOW_ACTIONS[action]) { + SNOWPLOW_ACTIONS[action](...config); + } else { + // eslint-disable-next-line no-console, @gitlab/require-i18n-strings + console.warn('Unsupported snowplow action:', action); + } +}; + +window.snowplowPlugins = [ + LinkClickTrackingPlugin(), + FormTrackingPlugin(), + TimezonePlugin(), + GaCookiesPlugin(), + PerformanceTimingPlugin(), + ClientHintsPlugin(), +]; + +export default {}; |