Skip to content

feat(analytics): Add 51LA Analytics Component Support#249

Merged
CuteLeaf merged 2 commits intoCuteLeaf:masterfrom
jacksen168sub:feat/51la-analytics
Mar 15, 2026
Merged

feat(analytics): Add 51LA Analytics Component Support#249
CuteLeaf merged 2 commits intoCuteLeaf:masterfrom
jacksen168sub:feat/51la-analytics

Conversation

@jacksen168sub
Copy link
Contributor

Type of change

  • Bug fix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other (please describe):

Checklist

  • I have read the CONTRIBUTING document.
  • I have checked to ensure that this Pull Request is not for personal changes.
  • I have performed a self-review of my own code.
  • My changes generate no new warnings.

Related Issue

Changes

新增 51la 网站统计支持,与现有的 Google Analytics 和 Microsoft Clarity 保持一致的代码风格。

修改文件:

文件 改动
src/types/config.ts 添加 51la 配置类型定义
src/config/siteConfig.ts 添加 51la 配置项
src/components/analytics/La51Analytics.astro 新建 51la 统计组件
src/layouts/Layout.astro 集成 51la 组件

配置选项:

analytics: {
  la51AnalyticsId: "YOUR_ID",
  la51Config: {
    sdkUrl: "",       // 自定义 SDK 地址,防止 DNS 污染
    ck: "",           // 多统计 ID 数据分离标识
    autoTrack: true,  // 事件分析功能
    hashMode: false,  // SPA 路由支持(MPA 站点无需开启)
    screenRecord: true, // 录屏功能
  },
},

How To Test

  1. src/config/siteConfig.ts 中填写 la51AnalyticsId
  2. 运行 pnpm build 构建项目
  3. 部署后访问网站,检查 51la 后台是否正常接收数据

Screenshots (if applicable)

Additional Notes

  • 使用异步加载方式,不阻塞页面渲染
  • 使用 is:inline + data-swup-ignore-script 属性,与 Swup 页面切换兼容
  • 支持自定义 SDK 地址,防止 DNS 污染导致加载恶意 JS

feat(analytics): 添加51LA统计组件支持

New 51LA Analytics Component:
- Created a new `src/components/analytics/La51Analytics.astro` component file
- Added `la51AnalyticsId` and `la51Config` configuration options to the site configuration (`siteConfig`)
- Integrated the `La51Analytics` component into the main `Layout.astro` layout
- Added corresponding type declarations for the new options in the `SiteConfig` type definition

Enhanced Configuration Options:
- The feature supports various configurable options including:
  - Custom SDK URL
  - Data separation identifiers
  - Automatic page tracking
  - Hash-based router mode
  - Screen recording functionality

新增51LA分析组件:
- 新增了 `src/components/analytics/La51Analytics.astro` 组件文件
- 在站点配置 (`siteConfig`) 中添加了 `la51AnalyticsId` 和 `la51Config` 配置项
- 将 `La51Analytics` 组件集成到主布局文件 `Layout.astro` 中
- 在 `SiteConfig` 类型定义中为新增选项添加了相应的类型声明

增强的配置选项:
- 此功能支持多种可配置选项,包括:
  - 自定义 SDK URL
  - 数据分离标识符
  - 自动页面跟踪
  - 基于Hash的路由模式
  - 屏幕录制功能
@netlify
Copy link

netlify bot commented Mar 12, 2026

Deploy Preview for demo-firefly ready!

Name Link
🔨 Latest commit 4c29e60
🔍 Latest deploy log https://app.netlify.com/projects/demo-firefly/deploys/69b64e3ade66670008dc8bc9
😎 Deploy Preview https://deploy-preview-249--demo-firefly.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@CuteLeaf CuteLeaf merged commit 2d21e64 into CuteLeaf:master Mar 15, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants