fix: fix custom tracker script name not display in fe problem

This commit is contained in:
moonrailgun 2024-04-07 23:23:18 +08:00
parent d13e33e9a1
commit 5d8c18716a
3 changed files with 6 additions and 1 deletions

View File

@ -36,6 +36,7 @@ It's good to specialize in one thing, if we are experts in related abilities we
- [ ] waitlist
- [ ] survey
- [ ] lighthouse report
- [ ] hooks
## Preview

View File

@ -11,6 +11,7 @@ import {
} from '../ui/dialog';
import { useTranslation } from '@i18next-toolkit/react';
import { Typography } from 'antd';
import { useGlobalConfig } from '@/hooks/useConfig';
interface WebsiteCodeBtnProps {
websiteId: string;
@ -18,8 +19,9 @@ interface WebsiteCodeBtnProps {
export const WebsiteCodeBtn: React.FC<WebsiteCodeBtnProps> = React.memo(
(props) => {
const { t } = useTranslation();
const { customTrackerScriptName = 'tracker.js' } = useGlobalConfig();
const trackScript = `<script async defer src="${location.origin}/tracker.js" data-website-id="${props.websiteId}"></script>`;
const trackScript = `<script async defer src="${location.origin}/${customTrackerScriptName}" data-website-id="${props.websiteId}"></script>`;
return (
<Dialog>

View File

@ -22,6 +22,7 @@ export const globalRouter = router({
mapboxToken: z.string().optional(),
alphaMode: z.boolean(),
disableAnonymousTelemetry: z.boolean(),
customTrackerScriptName: z.string().optional(),
})
)
.query(async ({ input }) => {
@ -32,6 +33,7 @@ export const globalRouter = router({
mapboxToken: env.mapboxToken,
alphaMode: env.alphaMode,
disableAnonymousTelemetry: env.disableAnonymousTelemetry,
customTrackerScriptName: env.customTrackerScriptName,
};
}),
});