mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-01 12:29:35 +01:00
Pass analyticsUrl prop.
This commit is contained in:
parent
7f1f3b685a
commit
a3a24e76c9
@ -16,7 +16,7 @@ import useMessages from 'components/hooks/useMessages';
|
||||
|
||||
const generateId = () => getRandomChars(16);
|
||||
|
||||
export function ShareUrl({ websiteId, data, onSave }) {
|
||||
export function ShareUrl({ websiteId, data, analyticsUrl, onSave }) {
|
||||
const { formatMessage, labels, messages } = useMessages();
|
||||
const { name, shareId } = data;
|
||||
const [id, setId] = useState(shareId);
|
||||
@ -27,10 +27,7 @@ export function ShareUrl({ websiteId, data, onSave }) {
|
||||
);
|
||||
const ref = useRef(null);
|
||||
const url = useMemo(
|
||||
() =>
|
||||
`${process.env.analyticsUrl || location.origin}${basePath}/share/${id}/${encodeURIComponent(
|
||||
name,
|
||||
)}`,
|
||||
() => `${analyticsUrl || location.origin}${basePath}/share/${id}/${encodeURIComponent(name)}`,
|
||||
[id, name, basePath],
|
||||
);
|
||||
|
||||
|
@ -3,7 +3,7 @@ import useMessages from 'components/hooks/useMessages';
|
||||
import useConfig from 'components/hooks/useConfig';
|
||||
import { useRouter } from 'next/router';
|
||||
|
||||
export function TrackingCode({ websiteId, baseUrl }) {
|
||||
export function TrackingCode({ websiteId, analyticsUrl }) {
|
||||
const { formatMessage, messages } = useMessages();
|
||||
const { basePath } = useRouter();
|
||||
const config = useConfig();
|
||||
@ -13,7 +13,7 @@ export function TrackingCode({ websiteId, baseUrl }) {
|
||||
|
||||
const url = trackerScriptName?.startsWith('http')
|
||||
? trackerScriptName
|
||||
: `${baseUrl || location.origin}${basePath}/${trackerScriptName}`;
|
||||
: `${analyticsUrl || location.origin}${basePath}/${trackerScriptName}`;
|
||||
|
||||
const code = `<script async src="${url}" data-website-id="${websiteId}"></script>`;
|
||||
|
||||
|
@ -69,7 +69,14 @@ export function WebsiteSettings({ websiteId, openExternal = false, analyticsUrl
|
||||
<WebsiteEditForm websiteId={websiteId} data={values} onSave={handleSave} />
|
||||
)}
|
||||
{tab === 'tracking' && <TrackingCode websiteId={websiteId} analyticsUrl={analyticsUrl} />}
|
||||
{tab === 'share' && <ShareUrl websiteId={websiteId} data={values} onSave={handleSave} />}
|
||||
{tab === 'share' && (
|
||||
<ShareUrl
|
||||
websiteId={websiteId}
|
||||
data={values}
|
||||
analyticsUrl={analyticsUrl}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
)}
|
||||
{tab === 'data' && <WebsiteData websiteId={websiteId} onSave={handleReset} />}
|
||||
</Page>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user