diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 15:44:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 15:44:42 +0000 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /app/assets/javascripts/tracking.js | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) | |
download | gitlab-ce-4555e1b21c365ed8303ffb7a3325d773c9b8bf31.tar.gz |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'app/assets/javascripts/tracking.js')
-rw-r--r-- | app/assets/javascripts/tracking.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/assets/javascripts/tracking.js b/app/assets/javascripts/tracking.js index cdfecceb78a..d2e69bc06cf 100644 --- a/app/assets/javascripts/tracking.js +++ b/app/assets/javascripts/tracking.js @@ -153,6 +153,21 @@ export default class Tracking { return loadEvents; } + static enableFormTracking(config, contexts = []) { + if (!this.enabled()) return; + + if (!config?.forms?.whitelist?.length && !config?.fields?.whitelist?.length) { + // eslint-disable-next-line @gitlab/require-i18n-strings + throw new Error('Unable to enable form event tracking without whitelist rules.'); + } + + contexts.unshift(STANDARD_CONTEXT); + const enabler = () => window.snowplow('enableFormTracking', config, contexts); + + if (document.readyState !== 'loading') enabler(); + else document.addEventListener('DOMContentLoaded', enabler); + } + static mixin(opts = {}) { return { computed: { |