Changed route ids to be more explicit.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { TextArea } from 'react-basics';
|
||||
import { useMessages, useConfig } from 'components/hooks';
|
||||
|
||||
const SCRIPT_NAME = 'script.js';
|
||||
|
||||
export function TrackingCode({ websiteId, hostUrl }: { websiteId: string; hostUrl?: string }) {
|
||||
const { formatMessage, messages } = useMessages();
|
||||
const config = useConfig();
|
||||
|
||||
const trackerScriptName =
|
||||
config?.trackerScriptName?.split(',')?.map((n: string) => n.trim())?.[0] || SCRIPT_NAME;
|
||||
|
||||
const url = trackerScriptName?.startsWith('http')
|
||||
? trackerScriptName
|
||||
: `${hostUrl || process.env.hostUrl || window?.location.origin}${
|
||||
process.env.basePath
|
||||
}/${trackerScriptName}`;
|
||||
|
||||
const code = `<script defer src="${url}" data-website-id="${websiteId}"></script>`;
|
||||
|
||||
return (
|
||||
<>
|
||||
<p>{formatMessage(messages.trackingCode)}</p>
|
||||
<TextArea rows={4} value={code} readOnly allowCopy />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default TrackingCode;
|
||||
Reference in New Issue
Block a user