Fix uuid passing

This commit is contained in:
Bartosz Hernas 2020-09-15 14:10:01 +02:00
parent 7a71bb1c68
commit 241905c5fe

View File

@ -83,12 +83,9 @@ function log(isDebug, messageFn) {
const scheduledCalls = window.umami.calls; const scheduledCalls = window.umami.calls;
window.umami = {}; window.umami = {};
window.umami.collect = (type, params, id) => { window.umami.collect = (type, params, uuid) => {
if (!id) {
id = website;
}
const payload = { const payload = {
website: id, website: uuid,
hostname, hostname,
screen, screen,
language, language,
@ -106,15 +103,15 @@ function log(isDebug, messageFn) {
payload, payload,
}); });
}; };
window.umami.pageView = (url = currentUrl, referrer = currentRef) => window.umami.collect('pageview', { window.umami.pageView = (url = currentUrl, referrer = currentRef, uuid = website) => window.umami.collect('pageview', {
url, url,
referrer, referrer,
}); }, uuid);
window.umami.event = (event_type, event_value, url = currentUrl) => window.umami.collect('event', { window.umami.event = (event_type, event_value, url = currentUrl, uuid = website) => window.umami.collect('event', {
url, url,
event_type, event_type,
event_value, event_value,
}); }, uuid);
window.umami.registerAutoEvents = () => { window.umami.registerAutoEvents = () => {
history.pushState = hook(history, 'pushState', handlePush); history.pushState = hook(history, 'pushState', handlePush);
history.replaceState = hook(history, 'replaceState', handlePush); history.replaceState = hook(history, 'replaceState', handlePush);
@ -122,8 +119,6 @@ function log(isDebug, messageFn) {
}; };
log(isDebug, () => 'Umami, calling scheduled invocations'); log(isDebug, () => 'Umami, calling scheduled invocations');
log(isDebug, () => scheduledCalls);
scheduledCalls.forEach(([fnName, ...params]) => { scheduledCalls.forEach(([fnName, ...params]) => {
log(isDebug, () => `Umami, calling ${fnName} fn with params: ${JSON.stringify(params)}`); log(isDebug, () => `Umami, calling ${fnName} fn with params: ${JSON.stringify(params)}`);
window.umami[fnName].apply(window.umami, params); window.umami[fnName].apply(window.umami, params);