debian-mirror-gitlab/app/assets/javascripts/entrypoints/tracker.js
2023-07-09 08:55:56 +05:30

50 lines
1.3 KiB
JavaScript

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 {};