diff --git a/README.md b/README.md index fda6b039..626ef70c 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ It's good to specialize in one thing, if we are experts in related abilities we - [ ] utm track - [ ] waitlist - [ ] survey +- [ ] lighthouse report ## Preview diff --git a/src/client/components/PageHeader.tsx b/src/client/components/PageHeader.tsx index 52dbd89b..253eb3b9 100644 --- a/src/client/components/PageHeader.tsx +++ b/src/client/components/PageHeader.tsx @@ -18,7 +18,6 @@ export const PageHeader: React.FC<{ )} -
{props.title}
{props.action} ); diff --git a/src/client/components/telemetry/TelemetryList.tsx b/src/client/components/telemetry/TelemetryList.tsx index 138157c7..632d02d2 100644 --- a/src/client/components/telemetry/TelemetryList.tsx +++ b/src/client/components/telemetry/TelemetryList.tsx @@ -1,11 +1,12 @@ import { Trans, t } from '@i18next-toolkit/react'; -import { Button, Form, Input, Modal, Table } from 'antd'; +import { Button, Collapse, Form, Input, Modal, Table, Typography } from 'antd'; import React, { useMemo, useState } from 'react'; import { AppRouterOutput, trpc } from '../../api/trpc'; import { useCurrentWorkspaceId } from '../../store/user'; import { type ColumnsType } from 'antd/es/table/interface'; import { BarChartOutlined, + CodeOutlined, EditOutlined, PlusOutlined, } from '@ant-design/icons'; @@ -18,10 +19,11 @@ type TelemetryInfo = AppRouterOutput['telemetry']['all'][number]; export const TelemetryList: React.FC = React.memo(() => { const workspaceId = useCurrentWorkspaceId(); - const [isModalOpen, setIsModalOpen] = useState(false); + const [isEditModalOpen, setIsEditModalOpen] = useState(false); const [form] = Form.useForm<{ id?: string; name: string }>(); const upsertTelemetryMutation = trpc.telemetry.upsert.useMutation(); const utils = trpc.useUtils(); + const [modal, contextHolder] = Modal.useModal(); const handleAddTelemetry = useEvent(async () => { await form.validateFields(); @@ -35,13 +37,67 @@ export const TelemetryList: React.FC = React.memo(() => { utils.telemetry.all.refetch(); - setIsModalOpen(false); + setIsEditModalOpen(false); form.resetFields(); }); + const handleShowUsage = useEvent((info: TelemetryInfo) => { + const blankGif = `${window.location.origin}/telemetry/${workspaceId}/${info.id}.gif`; + const countBadgeUrl = `${window.location.origin}/telemetry/${workspaceId}/${info.id}/badge.svg`; + modal.info({ + maskClosable: true, + title: 'How to Use Telemetry', + content: ( +
+

Here is some way to use telemetry:

+

Insert to article:

+

+ if your article support raw html, you can direct insert it{' '} + + {blankGif} + +

+ +

+ Some website will not allow send `referer` field. so its + maybe can not track source. so you can mark it by + yourself. for example: +

+

+ + {blankGif}?url=https://xxxxxxxx + +

+
+ ), + }, + ]} + /> + +

Count your website visitor:

+

+ if your article support raw html, you can direct insert it{' '} + + {countBadgeUrl} + +

+

+ Like this: +

+ + ), + }); + }); + const handleEditTelemetry = useEvent(async (info: TelemetryInfo) => { - setIsModalOpen(true); + setIsEditModalOpen(true); form.setFieldsValue({ id: info.id, name: info.name, @@ -87,7 +143,7 @@ export const TelemetryList: React.FC = React.memo(() => { type="primary" icon={} size="large" - onClick={() => setIsModalOpen(true)} + onClick={() => setIsEditModalOpen(true)} > {t('Add Telemetry')} @@ -95,16 +151,19 @@ export const TelemetryList: React.FC = React.memo(() => { } /> - + handleAddTelemetry()} - onCancel={() => setIsModalOpen(false)} + onCancel={() => setIsEditModalOpen(false)} >
+ + {contextHolder} ); }); @@ -125,6 +186,7 @@ TelemetryList.displayName = 'TelemetryList'; const TelemetryListTable: React.FC<{ onEdit: (info: TelemetryInfo) => void; + onShowUsage: (info: TelemetryInfo) => void; }> = React.memo((props) => { const workspaceId = useCurrentWorkspaceId(); const { data = [], isLoading } = trpc.telemetry.all.useQuery({ @@ -155,6 +217,12 @@ const TelemetryListTable: React.FC<{ render: (_, record) => { return (
+