Skip to content

Commit 6506c8d

Browse files
authored
Merge pull request #334 from InvolutionHell/feat/utm-tracking-v2
feat(growth): UTM 跟踪 doc 分享 + turbopack root 锁定
2 parents 8c0fc06 + 572c2ed commit 6506c8d

4 files changed

Lines changed: 26 additions & 5 deletions

File tree

README.en.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
</p>
44

55
<p align="center">
6-
<a href="https://involutionhell.com">
6+
<a href="https://involutionhell.com/?utm_source=github&utm_medium=readme&utm_campaign=logo">
77
<picture>
88
<!-- Dark mode logo -->
99
<source media="(prefers-color-scheme: dark)" srcset="./public/logo/logoInDark.svg">
@@ -21,7 +21,7 @@
2121
<img alt="Next.js" src="https://img.shields.io/badge/Next.js-000000?style=for-the-badge&logo=nextdotjs&logoColor=white" />
2222
<img alt="Vercel" src="https://img.shields.io/badge/Vercel-000000?style=for-the-badge&logo=vercel&logoColor=white" />
2323
<a href="https://github.com/InvolutionHell/involutionhell/blob/main/LICENSE">
24-
<a href="https://involutionhell.com">
24+
<a href="https://involutionhell.com/?utm_source=github&utm_medium=readme&utm_campaign=badge">
2525
<img src="https://img.shields.io/badge/Website-involutionhell.com-blue?style=for-the-badge" alt="Official Website">
2626
</a>
2727
</p>

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
</p>
44

55
<p align="center">
6-
<a href="https://involutionhell.com">
6+
<a href="https://involutionhell.com/?utm_source=github&utm_medium=readme&utm_campaign=logo">
77
<picture>
88
<!-- Dark mode logo -->
99
<source media="(prefers-color-scheme: dark)" srcset="./public/logo/logoInDark.svg">
@@ -21,7 +21,7 @@
2121
<img alt="Next.js" src="https://img.shields.io/badge/Next.js-000000?style=for-the-badge&logo=nextdotjs&logoColor=white" />
2222
<img alt="Vercel" src="https://img.shields.io/badge/Vercel-000000?style=for-the-badge&logo=vercel&logoColor=white" />
2323
<a href="https://github.com/InvolutionHell/involutionhell/blob/main/LICENSE">
24-
<a href="https://involutionhell.com">
24+
<a href="https://involutionhell.com/?utm_source=github&utm_medium=readme&utm_campaign=badge">
2525
<img src="https://img.shields.io/badge/Website-involutionhell.com-blue?style=for-the-badge" alt="Official Website">
2626
</a>
2727
</p>

app/components/DocShareButton.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ export function DocShareButton() {
2020
}, []);
2121

2222
const handleCopy = async () => {
23-
const url = window.location.href;
23+
// 用户点"复制链接"必然是要发到外面(DC/微信/X)
24+
// 给链接打上 UTM,回流时能在 GA Source 维度看到 doc_share,区别于 (direct)
25+
const target = new URL(window.location.href);
26+
target.searchParams.set("utm_source", "doc_share");
27+
target.searchParams.set("utm_medium", "user_share");
28+
const url = target.toString();
2429
try {
2530
await navigator.clipboard.writeText(url);
2631
setCopied(true);

next.config.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
// next.config.mjs
2+
import path from "node:path";
3+
import { fileURLToPath } from "node:url";
24
import { createMDX } from "fumadocs-mdx/next";
35
import createNextIntlPlugin from "next-intl/plugin";
46
import { withSentryConfig } from "@sentry/nextjs";
57

8+
// Next.js 16 detects multi-lockfile environments by searching upward for
9+
// pnpm-lock.yaml / package-lock.json / yarn.lock. 当父目录意外有 lockfile
10+
// 时(如开发服务器上 /home/ubuntu/package-lock.json),Next 会把 workspace
11+
// root 推到上层,turbopack 跟着到错的目录解析 node_modules,
12+
// 触发 "Can't resolve 'tailwindcss'" 之类报错。
13+
// 显式锁定到 frontend 自己目录,turbopack + outputFileTracing 双保险。
14+
const projectRoot = path.dirname(fileURLToPath(import.meta.url));
15+
616
/**
717
* IMPORTANT: remarkImage 配置已移至 source.config.ts 统一管理
818
*
@@ -22,6 +32,12 @@ const withNextIntl = createNextIntlPlugin("./i18n/request.ts");
2232
/** @type {import('next').NextConfig} */
2333
const config = {
2434
reactStrictMode: true,
35+
// 强制锁定 turbopack 和 SSR file tracing 的根目录到 frontend/ 自己,
36+
// 避免上层意外 lockfile 把 root 推错(详见文件顶部注释)。
37+
turbopack: {
38+
root: projectRoot,
39+
},
40+
outputFileTracingRoot: projectRoot,
2541
/**
2642
* docs 目录整理产生的 URL 变化 → 301 重定向。
2743
*

0 commit comments

Comments
 (0)