Skip to content

Commit

Permalink
Feat add tracert (#141)
Browse files Browse the repository at this point in the history
* feat: add ant tracert

* feat: add all pages tracert

* feat: opt tracert
  • Loading branch information
zhongyunWan authored Aug 22, 2024
1 parent a8c8726 commit 6e5dab7
Show file tree
Hide file tree
Showing 14 changed files with 109 additions and 32 deletions.
12 changes: 10 additions & 2 deletions .umirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default defineConfig({
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?e4bea71987c7daae77ee69586aad5bec";
var s = document.getElementsByTagName("script")[0];
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();`,
{
Expand All @@ -70,9 +70,17 @@ export default defineConfig({
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?9452f06d5325a3907efec5619d9f2392";
var s = document.getElementsByTagName("script")[0];
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();`,
{
src: 'https://ur.alipay.com/tracert_a4609.js',
async: true,
},
` window.TracertCmdCache=window.TracertCmdCache||[]
;var t=window.Tracert||{_isRenderInit:!0,call:function(){window.TracertCmdCache.push(arguments)}},f=["call","start","config","logPv","info","err","click","expo","pageName","pageState","time","timeEnd","parse","checkExpo","stringify","report","set","before"];for(let i=0;i<f.length;i++){(function(fn){t[fn]=function(){var a=[],l=arguments.length;for (var j=0;j<l;j++) {a.push(arguments[j])}a.unshift(fn);window.TracertCmdCache.push(a)}})(f[i])}window.Tracert=t;
window._to={autoLogPv:false};
window.Tracert.start({});`,
],
theme: {
'primary-color': 'rgba(22,80,255,1)',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"react-dom": "17.x",
"react-helmet": "^6.1.0",
"react-html-renderer": "^0.3.3",
"react-router-dom": "^6.26.1",
"react-use": "^17.4.0",
"umi": "^3.5.28"
},
Expand Down
19 changes: 7 additions & 12 deletions src/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import cx from 'classnames';
import { useEffect, useState } from 'react';
import { useMedia } from 'react-use';
import { history, useIntl, useLocation } from 'umi';
import { Link } from 'react-router-dom';

import { DEFAULT_LOCAL, searchParamsEn, searchParamsZh } from '@/constant';
import { getSearch, goLinkAt, historyPushLinkAt } from '@/util';
Expand Down Expand Up @@ -491,27 +492,21 @@ export const Header = ({ isStick }: { isStick?: boolean }) => {

const menuItems: MenuItem[] = [
{
label: (
<a href={goLinkAt('/')} rel="noopener noreferrer">
{intl.formatMessage({ id: 'header.home' })}
</a>
),
label: <Link to="/">{intl.formatMessage({ id: 'header.home' })}</Link>,
key: 'home',
},
{ ...(isWide ? pcProductMenu : mobileProductMenu) },
{
label: (
<a href={goLinkAt('/case')} rel="noopener noreferrer">
{intl.formatMessage({ id: 'header.case' })}
</a>
<Link to="/case">{intl.formatMessage({ id: 'header.case' })}</Link>
),
key: 'case',
},
{
label: (
<a href={goLinkAt('/ecosystem')} rel="noopener noreferrer">
<Link to="/ecosystem">
{intl.formatMessage({ id: 'header.ecosystem' })}
</a>
</Link>
),
key: 'ecosystem',
},
Expand All @@ -520,9 +515,9 @@ export const Header = ({ isStick }: { isStick?: boolean }) => {
{ ...(isWide ? pcCommunityMenu : mobileCommunityMenu) },
{
label: (
<a href={goLinkAt('/download')} rel="noopener noreferrer">
<Link to="/download">
{intl.formatMessage({ id: 'header.download' })}
</a>
</Link>
),
key: 'download',
},
Expand Down
10 changes: 9 additions & 1 deletion src/pages/blog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DEFAULT_LOCAL } from '@/constant';
import { getZHBlogs } from '@/data/blog';
import { getENBlogs } from '@/data/blog_en';
import { BlogItem } from '@/interface';
import { getSearch } from '@/util';
import { getSearch, tracertBPos } from '@/util';
import { Button, Layout, Pagination, Space, Spin, Tabs } from 'antd';
import cx from 'classnames';
import React, { useEffect, useState } from 'react';
Expand Down Expand Up @@ -57,6 +57,11 @@ export default function BlogPage() {
setListData(blogs.slice(0, PAGE_SIZE));
}, [blogs]);

/** Blog埋点 */
useEffect(() => {
tracertBPos('b106234');
}, []);

const onPaginationChange = (page: number) => {
const start = 0 + (page - 1) * PAGE_SIZE;
const end = start + PAGE_SIZE;
Expand All @@ -81,8 +86,10 @@ export default function BlogPage() {

const jumpToArticle = (article: BlogItem) => {
if (article.isLink) {
tracertBPos('b106257', { title: article.title });
window.open(article.content, '_blank');
} else {
tracertBPos('b106258', { title: article.title });
window.open(`/blog?id=${article.id}&lang=${lang}`);
}
};
Expand Down Expand Up @@ -111,6 +118,7 @@ export default function BlogPage() {
onClick={() => {
jumpToArticle(item);
}}
data-aspm={item.isLink ? 'c375857' : 'c375858'}
>
<Space size={isWide ? 24 : 22}>
<img src={item.img} alt={item.title} />
Expand Down
10 changes: 8 additions & 2 deletions src/pages/case.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect } from 'react';
import { Helmet } from 'react-helmet';
import { Carousel, Col, Row, Space } from 'antd';
import { useIntl, isBrowser, useLocation } from 'umi';
Expand All @@ -12,7 +12,7 @@ import { getExamples } from '@/data/examples';
import { getDemos } from '@/data/demos';
import { SubTitle } from '@/components/SubTitle';
import { DEFAULT_LOCAL } from '@/constant';
import { getSearch } from '@/util';
import { getSearch, tracertBPos } from '@/util';

export default function DemoPage() {
const intl = useIntl();
Expand All @@ -23,6 +23,12 @@ export default function DemoPage() {
const SWIPE_PADDING = isBrowser()
? (40 * document.body.clientWidth) / 750
: 40;

/** 案例埋点 */
useEffect(() => {
tracertBPos('b106231');
}, []);

const pcDemo = (
<div className="maxContainer">
<Row wrap={true} className={styles.demoWrapper}>
Expand Down
8 changes: 7 additions & 1 deletion src/pages/download.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import { Button, Col, message, Row, Select } from 'antd';
import { CopyToClipboard } from 'react-copy-to-clipboard';
import { useIntl } from 'umi';
Expand All @@ -8,13 +8,19 @@ import { ApplyForm } from '@/components/ApplyForm';
import { LayoutTemplate } from '@/components/LayoutTemplate';
import { assetsList, docsList, iconMap } from '@/data/download';
import { DownloadItem } from '@/interface';
import { tracertBPos } from '@/util';

export default function DownloadPage() {
const intl = useIntl();
const isWide = useMedia('(min-width: 767.99px)', true);

const [showApplyForm, setShowApplyForm] = useState(false);

/** 下载埋点 */
useEffect(() => {
tracertBPos('b106235');
}, []);

const DownloadGroupItem = ({ name, action, version }: DownloadItem) => {
const [key, setKey] = useState<any>(version?.list[0]?.value);
const [isHover, setIsHover] = useState(false);
Expand Down
10 changes: 8 additions & 2 deletions src/pages/ecosystem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { Anchor, Col, Row, Space } from 'antd';
import cx from 'classnames';
import { useMedia } from 'react-use';
import { useIntl, useLocation } from 'umi';
import React from 'react';
import React, { useEffect } from 'react';

import stylesZh from './ecosystem.less';
import stylesEn from './ecosystem_en.less';
import { getPartnerReason } from '@/data/get_partner_reason';
import { getPartner } from '@/data/get_partner';
import { LayoutTemplate } from '@/components/LayoutTemplate';
import { DEFAULT_LOCAL, logoList } from '@/constant';
import { getSearch } from '@/util';
import { getSearch, tracertBPos } from '@/util';

const { Link } = Anchor;

Expand All @@ -20,6 +20,12 @@ export default function EcosystemPage() {
const lang = getSearch(search)?.lang || DEFAULT_LOCAL;
const styles = lang === 'en' || lang === 'en-US' ? stylesEn : stylesZh;
const isWide = useMedia('(min-width: 767.99px)', true);

/** 生态埋点 */
useEffect(() => {
tracertBPos('b106232');
}, []);

const content = (
<div className={styles.containerWrapper}>
<div className={styles.cardWrapper} style={{ marginBottom: 40 }}>
Expand Down
10 changes: 8 additions & 2 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
Tooltip,
} from 'antd';
import cx from 'classnames';
import { useState } from 'react';
import { useEffect, useState } from 'react';
import { Helmet } from 'react-helmet';
import { useMedia } from 'react-use';
import { isBrowser, useIntl, useLocation } from 'umi';
Expand All @@ -34,7 +34,7 @@ import { SubTitle } from '@/components/SubTitle';
import { getCases } from '@/data/cases';
import { getTugraphFun } from '@/data/get_tugraph_functions';
import { getReasons } from '@/data/reasons';
import { getSearch } from '@/util';
import { getSearch, tracertBPos } from '@/util';
import stylesZh from './index.less';
import stylesEn from './index_en.less';

Expand All @@ -53,6 +53,12 @@ export default function IndexPage() {
const SWIPE_PADDING = isBrowser()
? (48 * document.body.clientWidth) / 750
: 24;

/** 首页埋点 */
useEffect(() => {
tracertBPos('b106229');
}, []);

const bannerButton = (
<div className={styles.bannerButtons}>
<Space>
Expand Down
10 changes: 8 additions & 2 deletions src/pages/overview.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button, Col, Row, Space } from 'antd';
import { useState } from 'react';
import { useState, useEffect } from 'react';
import { Helmet } from 'react-helmet';
import { useMedia } from 'react-use';
import { useIntl, useLocation } from 'umi';
Expand All @@ -11,7 +11,7 @@ import { getOverViewFeats } from '@/data/feats';
import { SubTitle } from '@/components/SubTitle';
import { LayoutTemplate } from '@/components/LayoutTemplate';
import { DEFAULT_LOCAL } from '@/constant';
import { getSearch } from '@/util';
import { getSearch, tracertBPos } from '@/util';

export default function OverviewPage() {
const intl = useIntl();
Expand All @@ -20,6 +20,12 @@ export default function OverviewPage() {
const styles = lang === 'en' || lang === 'en-US' ? stylesEn : stylesZh;
const isWide = useMedia('(min-width: 767.99px)', true);
const [showApplyForm, setShowApplyForm] = useState(false);

/** TuGraph 企业版概览 */
useEffect(() => {
tracertBPos('b106248');
}, []);

const content = (
<div className={styles.containerWrapper}>
<Helmet>
Expand Down
10 changes: 8 additions & 2 deletions src/pages/platform.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button, Col, Row } from 'antd';
import { useState } from 'react';
import { useState, useEffect } from 'react';
import { useMedia } from 'react-use';
import { useIntl, useLocation } from 'umi';

Expand All @@ -9,7 +9,7 @@ import { ApplyForm } from '@/components/ApplyForm';
import { proAdvantDataDb, proAdvantDataPlat } from '@/data/proAdvantData';
import { SubTitle } from '@/components/SubTitle';
import { LayoutTemplate } from '@/components/LayoutTemplate';
import { getSearch } from '@/util';
import { getSearch, tracertBPos } from '@/util';
import { DEFAULT_LOCAL } from '@/constant';

export default function PlatFormPage() {
Expand All @@ -25,6 +25,12 @@ export default function PlatFormPage() {
: proAdvantDataDb(intl);
const isWide = useMedia('(min-width: 767.99px)', true);
const [showApplyForm, setShowApplyForm] = useState(false);

/** TuGraph 一站式图平台、大规模分布式图数据库 */
useEffect(() => {
isPlatform ? tracertBPos('b106249') : tracertBPos('b106256');
}, []);

const content = (
<div className={styles.containerWrapper}>
<SubTitle
Expand Down
10 changes: 8 additions & 2 deletions src/pages/product.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect } from 'react';
import { Carousel, Col, Row, Space, Tag } from 'antd';
import { Helmet } from 'react-helmet';
import { useMedia } from 'react-use';
Expand All @@ -9,7 +9,7 @@ import JoLPlayer from '@/components/Player';
import { SubTitle } from '@/components/SubTitle';
import { LayoutTemplate } from '@/components/LayoutTemplate';
import { getFeats } from '@/data/feats';
import { getSearch } from '@/util';
import { getSearch, tracertBPos } from '@/util';
import { DEFAULT_LOCAL } from '@/constant';

export default function ProductPage() {
Expand All @@ -24,6 +24,12 @@ export default function ProductPage() {
const SWIPE_PADDING = isBrowser()
? (40 * document.body.clientWidth) / 750
: 40;

/** TuGraph DB Lite 单机版图数据库 */
useEffect(() => {
tracertBPos('b106230');
}, []);

const pcVideoList = (
<div className={styles.videoWrapper}>
{isBrowser() && (
Expand Down
9 changes: 7 additions & 2 deletions src/pages/product_analytics.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect } from 'react';

import { useIntl, useLocation } from 'umi';
import { Helmet } from 'react-helmet';
Expand All @@ -10,7 +10,7 @@ import stylesEn from './product_analytics_en.less';
import { LayoutTemplate } from '@/components/LayoutTemplate';
import { SubTitle } from '@/components/SubTitle';
import { getFeats } from '@/data/feats2';
import { getSearch } from '@/util';
import { getSearch, tracertBPos } from '@/util';
import { DEFAULT_LOCAL } from '@/constant';

const Root = () => {
Expand All @@ -20,6 +20,11 @@ const Root = () => {
const isWide = useMedia('(min-width: 767.99px)', true);
const styles = lang === 'en' || lang === 'en-US' ? stylesEn : stylesZh;

/** TuGraph DB Lite 单机版图数据库 */
useEffect(() => {
tracertBPos('b106246');
}, []);

const content = (
<div className={styles.containerWrapper}>
<Helmet>
Expand Down
10 changes: 8 additions & 2 deletions src/pages/product_learn.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect } from 'react';

import { useIntl, useLocation } from 'umi';
import { Helmet } from 'react-helmet';
Expand All @@ -10,7 +10,7 @@ import stylesEn from './product_learn_en.less';
import { LayoutTemplate } from '@/components/LayoutTemplate';
import { SubTitle } from '@/components/SubTitle';
import { getFeats } from '@/data/feats1';
import { getSearch } from '@/util';
import { getSearch, tracertBPos } from '@/util';
import { DEFAULT_LOCAL } from '@/constant';

const Root = () => {
Expand All @@ -19,6 +19,12 @@ const Root = () => {
const lang = getSearch(search)?.lang || DEFAULT_LOCAL;
const isWide = useMedia('(min-width: 767.99px)', true);
const styles = lang === 'en' || lang === 'en-US' ? stylesEn : stylesZh;

/** TuGraph Learn 图学习引擎 */
useEffect(() => {
tracertBPos('b106247');
}, []);

const content = (
<div className={styles.containerWrapper}>
<Helmet>
Expand Down
Loading

0 comments on commit 6e5dab7

Please sign in to comment.