Skip to content
Snippets Groups Projects

Add .gitlab-ci.yml

Files
11
+ 20
20
@@ -5,7 +5,7 @@
/* global mt */
(Drupal => {
((Drupal) => {
/**
* This array contains all pageviews that have been sent to Mautic.
* This is used to prevent duplicate pageviews in one request.
@@ -36,40 +36,40 @@
const params =
settings.advancedMauticIntegration.trackDefaultParameters;
Object.assign(params, extraParams);
if (typeof mt === "function") {
mt("send", "pageview", params);
if (typeof mt === 'function') {
mt('send', 'pageview', params);
}
Drupal.mt_pageviews.push(url);
}
};
const isInternal = url => {
const isInternal = (url) => {
const isInternalRegex = new RegExp(
`^(https?)://${window.location.host}`,
"i"
'i',
);
return isInternalRegex.test(url);
};
const isDownload = url => {
const isDownload = (url) => {
const isDownloadRegex = new RegExp(
`\\.(${settings.advancedMauticIntegration.trackDownloadExtensions})([?#].*)?$`,
"i"
'i',
);
return isDownloadRegex.test(url);
};
const isMailto = url => {
const isMailto = (url) => {
const isInternalRegex = /^mailto:/i;
return isInternalRegex.test(url);
};
const isTel = url => {
const isTel = (url) => {
const isInternalRegex = /^tel:/i;
return isInternalRegex.test(url);
};
const isProperExternal = url => {
const isProperExternal = (url) => {
const isProperExternalRegex = /^\w+:\/\//i;
return isProperExternalRegex.test(url);
};
@@ -80,8 +80,8 @@
}
// Bind events to <a> tags.
once("bind-mautic-tracking", "a", context).forEach(el => {
const trackLink = event => {
once('bind-mautic-tracking', 'a', context).forEach((el) => {
const trackLink = (event) => {
const url = event.target.href;
if (isInternal(url)) {
@@ -90,7 +90,7 @@
Drupal.mt_send({
page_url: url,
page_title: `Download ${url}`,
referrer: window.location.href
referrer: window.location.href,
});
}
}
@@ -99,7 +99,7 @@
Drupal.mt_send({
page_url: url,
page_title: `Mail to: ${url.substr(7)}`,
referrer: window.location.href
referrer: window.location.href,
});
}
} else if (isTel(url)) {
@@ -107,7 +107,7 @@
Drupal.mt_send({
page_url: url,
page_title: `Phone: ${url.substr(5)}`,
referrer: window.location.href
referrer: window.location.href,
});
}
} else if (
@@ -117,15 +117,15 @@
Drupal.mt_send({
page_url: url,
page_title: `External link: ${url}`,
referrer: window.location.href
referrer: window.location.href,
});
}
};
el.addEventListener("mousedown", trackLink);
el.addEventListener("keyup", trackLink);
el.addEventListener("touchstart", trackLink);
el.addEventListener('mousedown', trackLink);
el.addEventListener('keyup', trackLink);
el.addEventListener('touchstart', trackLink);
});
}
},
};
})(Drupal);
Loading