Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pac
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tools
pac
Commits
89ba8c29
Commit
89ba8c29
authored
Oct 14, 2026
by
luoqi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(web): add Baidu analytics to PAC and FridayAI
parent
6a4e0d99
Pipeline
#3791
failed in 0 seconds
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
82 additions
and
0 deletions
+82
-0
apps/ai-web/src/app/layout.tsx
+2
-0
apps/ai-web/src/components/baidu-analytics.tsx
+39
-0
apps/pac-web/src/app/layout.tsx
+2
-0
apps/pac-web/src/components/baidu-analytics.tsx
+39
-0
No files found.
apps/ai-web/src/app/layout.tsx
View file @
89ba8c29
import
{
BaiduAnalytics
}
from
'@/components/baidu-analytics'
;
import
type
{
Metadata
,
Viewport
}
from
'next'
;
import
type
{
Metadata
,
Viewport
}
from
'next'
;
import
type
{
ReactNode
}
from
'react'
;
import
type
{
ReactNode
}
from
'react'
;
import
'./globals.css'
;
import
'./globals.css'
;
...
@@ -23,6 +24,7 @@ export default function RootLayout({ children }: { children: ReactNode }) {
...
@@ -23,6 +24,7 @@ export default function RootLayout({ children }: { children: ReactNode }) {
<
AuthSessionBoundary
>
{
children
}
</
AuthSessionBoundary
>
<
AuthSessionBoundary
>
{
children
}
</
AuthSessionBoundary
>
{
/* ⚠️ 挂在根布局 —— 提示条要能从任何一页弹出来,⛔ 不能每页各挂一个(会叠出多份) */
}
{
/* ⚠️ 挂在根布局 —— 提示条要能从任何一页弹出来,⛔ 不能每页各挂一个(会叠出多份) */
}
<
Toaster
/>
<
Toaster
/>
<
BaiduAnalytics
/>
</
body
>
</
body
>
</
html
>
</
html
>
);
);
...
...
apps/ai-web/src/components/baidu-analytics.tsx
0 → 100644
View file @
89ba8c29
"use client"
;
import
{
useEffect
}
from
'react'
;
import
{
usePathname
}
from
'next/navigation'
;
const
SITE_ID
=
'731849b080736f1c473e1118c4d729ad'
;
const
PRODUCTION_HOST
=
'fai.friday.tech'
;
type
AnalyticsWindow
=
Window
&
{
_hmt
?:
unknown
[][];
__pacBaiduLastPage
?:
string
;
};
/** 仅统计生产页面访问;查询参数和动态业务记录编号不进入手动 PV。 */
export
function
BaiduAnalytics
()
{
const
pathname
=
usePathname
();
useEffect
(()
=>
{
if
(
!
pathname
||
window
.
location
.
hostname
!==
PRODUCTION_HOST
)
return
;
const
analytics
=
window
as
AnalyticsWindow
;
const
queue
=
(
analytics
.
_hmt
??
=
[]);
// SPA 自行上报首屏与路由切换,避免自动首屏统计重复。
if
(
!
document
.
getElementById
(
'baidu-analytics'
))
{
queue
.
push
([
'_setAutoPageview'
,
false
]);
const
script
=
document
.
createElement
(
'script'
);
script
.
id
=
'baidu-analytics'
;
script
.
async
=
true
;
script
.
src
=
`https://hm.baidu.com/hm.js?
${
SITE_ID
}
`
;
script
.
referrerPolicy
=
'no-referrer'
;
document
.
head
.
appendChild
(
script
);
}
const
page
=
pathname
.
replace
(
/^
(\/
plans
)\/[^/]
+$/
,
'$1/:id'
)
.
replace
(
/^
(\/
admin
\/
ai-invocations
)\/[^/]
+$/
,
'$1/:id'
)
.
replace
(
/^
(\/
host
\/
appointments
)\/[^/]
+$/
,
'$1/:id'
);
if
(
analytics
.
__pacBaiduLastPage
===
page
)
return
;
analytics
.
__pacBaiduLastPage
=
page
;
queue
.
push
([
'_trackPageview'
,
page
]);
},
[
pathname
]);
return
null
;
}
apps/pac-web/src/app/layout.tsx
View file @
89ba8c29
import
{
BaiduAnalytics
}
from
'@/components/baidu-analytics'
;
import
type
{
Metadata
}
from
'next'
;
import
type
{
Metadata
}
from
'next'
;
import
{
Toaster
}
from
'@/components/ui/toaster'
;
import
{
Toaster
}
from
'@/components/ui/toaster'
;
import
'./globals.css'
;
import
'./globals.css'
;
...
@@ -13,6 +14,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
...
@@ -13,6 +14,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
<
body
className=
"min-h-screen bg-background text-foreground antialiased"
>
<
body
className=
"min-h-screen bg-background text-foreground antialiased"
>
{
children
}
{
children
}
<
Toaster
/>
<
Toaster
/>
<
BaiduAnalytics
/>
</
body
>
</
body
>
</
html
>
</
html
>
);
);
...
...
apps/pac-web/src/components/baidu-analytics.tsx
0 → 100644
View file @
89ba8c29
"use client"
;
import
{
useEffect
}
from
'react'
;
import
{
usePathname
}
from
'next/navigation'
;
const
SITE_ID
=
'731849b080736f1c473e1118c4d729ad'
;
const
PRODUCTION_HOST
=
'pac.friday.tech'
;
type
AnalyticsWindow
=
Window
&
{
_hmt
?:
unknown
[][];
__pacBaiduLastPage
?:
string
;
};
/** 仅统计生产页面访问;查询参数和动态业务记录编号不进入手动 PV。 */
export
function
BaiduAnalytics
()
{
const
pathname
=
usePathname
();
useEffect
(()
=>
{
if
(
!
pathname
||
window
.
location
.
hostname
!==
PRODUCTION_HOST
)
return
;
const
analytics
=
window
as
AnalyticsWindow
;
const
queue
=
(
analytics
.
_hmt
??
=
[]);
// SPA 自行上报首屏与路由切换,避免自动首屏统计重复。
if
(
!
document
.
getElementById
(
'baidu-analytics'
))
{
queue
.
push
([
'_setAutoPageview'
,
false
]);
const
script
=
document
.
createElement
(
'script'
);
script
.
id
=
'baidu-analytics'
;
script
.
async
=
true
;
script
.
src
=
`https://hm.baidu.com/hm.js?
${
SITE_ID
}
`
;
script
.
referrerPolicy
=
'no-referrer'
;
document
.
head
.
appendChild
(
script
);
}
const
page
=
pathname
.
replace
(
/^
(\/
plans
)\/[^/]
+$/
,
'$1/:id'
)
.
replace
(
/^
(\/
admin
\/
ai-invocations
)\/[^/]
+$/
,
'$1/:id'
)
.
replace
(
/^
(\/
host
\/
appointments
)\/[^/]
+$/
,
'$1/:id'
);
if
(
analytics
.
__pacBaiduLastPage
===
page
)
return
;
analytics
.
__pacBaiduLastPage
=
page
;
queue
.
push
([
'_trackPageview'
,
page
]);
},
[
pathname
]);
return
null
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment