umami/components/pages/settings/websites/TrackingCode.js

20 lines
605 B
JavaScript
Raw Normal View History

2023-01-10 08:59:26 +01:00
import { TextArea } from 'react-basics';
import { TRACKER_SCRIPT_URL } from 'lib/constants';
2023-03-22 22:05:55 +01:00
import useMessages from 'hooks/useMessages';
2023-01-10 08:59:26 +01:00
export default function TrackingCode({ websiteId }) {
2023-03-22 22:05:55 +01:00
const { formatMessage, messages } = useMessages();
2023-01-10 09:13:32 +01:00
const url = TRACKER_SCRIPT_URL.startsWith('http')
? TRACKER_SCRIPT_URL
: `${location.origin}${TRACKER_SCRIPT_URL}`;
const code = `<script async src="${url}" data-website-id="${websiteId}"></script>`;
2023-01-10 08:59:26 +01:00
return (
<>
2023-01-25 16:42:46 +01:00
<p>{formatMessage(messages.trackingCode)}</p>
2023-01-10 08:59:26 +01:00
<TextArea rows={4} value={code} readOnly allowCopy />
</>
);
}