This commit is contained in:
Francis Cao 2024-03-18 10:37:16 -07:00
commit 50c2bb2af7
2 changed files with 5 additions and 5 deletions

View File

@ -10,7 +10,8 @@ export default {
},
plugins: [
replace({
'/api/send': process.env.COLLECT_API_ENDPOINT || '/api/send',
'__COLLECT_API_HOST__': process.env.COLLECT_API_HOST || '',
'__COLLECT_API_ENDPOINT__': process.env.COLLECT_API_ENDPOINT || '/api/send',
delimiters: ['', ''],
preventAssignment: true,
}),

View File

@ -22,10 +22,9 @@
const stripSearch = attr(_data + 'strip-search') === _true;
const domain = attr(_data + 'domains') || '';
const domains = domain.split(',').map(n => n.trim());
const root = hostUrl
? hostUrl.replace(/\/$/, '')
: currentScript.src.split('/').slice(0, -1).join('/');
const endpoint = `${root}/api/send`;
const host =
hostUrl || '__COLLECT_API_HOST__' || currentScript.src.split('/').slice(0, -1).join('/');
const endpoint = `${host.replace(/\/$/, '')}__COLLECT_API_ENDPOINT__`;
const screen = `${width}x${height}`;
const eventRegex = /data-umami-event-([\w-_]+)/;
const eventNameAttribute = _data + 'umami-event';