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 - [ ] waitlist
- [ ] survey - [ ] survey
- [ ] lighthouse report - [ ] lighthouse report
- [ ] hooks
## Preview ## Preview

View File

@ -11,6 +11,7 @@ import {
} from '../ui/dialog'; } from '../ui/dialog';
import { useTranslation } from '@i18next-toolkit/react'; import { useTranslation } from '@i18next-toolkit/react';
import { Typography } from 'antd'; import { Typography } from 'antd';
import { useGlobalConfig } from '@/hooks/useConfig';
interface WebsiteCodeBtnProps { interface WebsiteCodeBtnProps {
websiteId: string; websiteId: string;
@ -18,8 +19,9 @@ interface WebsiteCodeBtnProps {
export const WebsiteCodeBtn: React.FC<WebsiteCodeBtnProps> = React.memo( export const WebsiteCodeBtn: React.FC<WebsiteCodeBtnProps> = React.memo(
(props) => { (props) => {
const { t } = useTranslation(); 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 ( return (
<Dialog> <Dialog>

View File

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