2023-01-10 08:59:26 +01:00
|
|
|
import { TextArea } from 'react-basics';
|
|
|
|
import { TRACKER_SCRIPT_URL } from 'lib/constants';
|
2023-01-25 16:42:46 +01:00
|
|
|
import { messages } from 'components/messages';
|
|
|
|
import { useIntl } from 'react-intl';
|
2023-01-10 08:59:26 +01:00
|
|
|
|
|
|
|
export default function TrackingCode({ websiteId }) {
|
2023-01-25 16:42:46 +01:00
|
|
|
const { formatMessage } = useIntl();
|
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 />
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|