mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 09:45:04 +01:00
Allow alternate host url in tracker.
This commit is contained in:
parent
aec012fb79
commit
cebd3fd924
@ -1,11 +1,11 @@
|
||||
export function removeTrailingSlash(url) {
|
||||
return url.length > 1 && url.endsWith('/') ? url.slice(0, -1) : url;
|
||||
return url && url.length > 1 && url.endsWith('/') ? url.slice(0, -1) : url;
|
||||
}
|
||||
|
||||
export function getDomainName(str) {
|
||||
try {
|
||||
return new URL(str).hostname;
|
||||
} catch {
|
||||
} catch (e) {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "umami",
|
||||
"version": "0.19.0",
|
||||
"version": "0.20.0",
|
||||
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
|
||||
"author": "Mike Cao <mike@mikecao.com>",
|
||||
"license": "MIT",
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'promise-polyfill/src/polyfill';
|
||||
import 'unfetch/polyfill';
|
||||
import { post, hook, doNotTrack } from '../lib/web';
|
||||
import { removeTrailingSlash } from '../lib/url';
|
||||
|
||||
(window => {
|
||||
const {
|
||||
@ -17,7 +18,10 @@ import { post, hook, doNotTrack } from '../lib/web';
|
||||
if (!script || (__DNT__ && doNotTrack())) return;
|
||||
|
||||
const website = script.getAttribute('data-website-id');
|
||||
const hostUrl = new URL(script.src).href.split('/').slice(0, -1).join('/');
|
||||
const hostUrl = script.getAttribute('data-host-url');
|
||||
const root = hostUrl
|
||||
? removeTrailingSlash(hostUrl)
|
||||
: new URL(script.src).href.split('/').slice(0, -1).join('/');
|
||||
const screen = `${width}x${height}`;
|
||||
const listeners = [];
|
||||
|
||||
@ -42,7 +46,7 @@ import { post, hook, doNotTrack } from '../lib/web';
|
||||
});
|
||||
}
|
||||
|
||||
return post(`${hostUrl}/api/collect`, {
|
||||
return post(`${root}/api/collect`, {
|
||||
type,
|
||||
payload,
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user