Skip to content

Commit 55063fc

Browse files
committed
chore: 给 page-detector 注入运行加耗时埋点
启用动态监控 debug 后页面 console 输出每次 page-detector 全量识别的同步运行耗时和命中项数,便于判断主线程卡顿是否来自该注入阶段。将版本号提升到 1.2.83。
1 parent 17d3164 commit 55063fc

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "stackprism",
33
"private": true,
4-
"version": "1.2.82",
4+
"version": "1.2.83",
55
"type": "module",
66
"description": "StackPrism 用于检测网页前端、后端、CDN、SaaS、广告营销、统计、登录、支付、网站程序和主题模板线索。",
77
"scripts": {

src/injected/page-detector.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1345,4 +1345,22 @@ ${html}`
13451345

13461346
const __spRules = (window as any).__SP_RULES__ ?? {}
13471347
;(window as any).__SP_RULES__ = undefined
1348-
export default detectPageTechnologies(__spRules)
1348+
const __spStart = performance.now()
1349+
const __spResult = detectPageTechnologies(__spRules)
1350+
try {
1351+
if (localStorage.getItem('__sp_observer_debug__') === '1') {
1352+
const __spDuration = performance.now() - __spStart
1353+
console.log(
1354+
'[StackPrism page-detector] 耗时',
1355+
__spDuration.toFixed(1) + 'ms',
1356+
'| 识别',
1357+
__spResult?.technologies?.length || 0,
1358+
'项 |',
1359+
'resources',
1360+
__spResult?.resources?.total || 0
1361+
)
1362+
}
1363+
} catch {
1364+
// ignore
1365+
}
1366+
export default __spResult

0 commit comments

Comments
 (0)