Updated handling of env vars.

This commit is contained in:
Mike Cao
2024-05-11 21:52:40 -07:00
parent abd0913e9b
commit 30c1933718
8 changed files with 192 additions and 155 deletions

View File

@@ -3,7 +3,7 @@ import { useMessages, useConfig } from 'components/hooks';
const SCRIPT_NAME = 'script.js';
export function TrackingCode({ websiteId, hostUrl }: { websiteId: string; hostUrl?: string }) {
export function TrackingCode({ websiteId }: { websiteId: string }) {
const { formatMessage, messages } = useMessages();
const config = useConfig();
@@ -12,8 +12,8 @@ export function TrackingCode({ websiteId, hostUrl }: { websiteId: string; hostUr
const url = trackerScriptName?.startsWith('http')
? trackerScriptName
: `${hostUrl || process.env.hostUrl || window?.location.origin}${
process.env.basePath
: `${process.env.trackerScriptHost || window?.location.origin || ''}${
process.env.basePath || ''
}/${trackerScriptName}`;
const code = `<script defer src="${url}" data-website-id="${websiteId}"></script>`;