feat: bind homepage visitor id after authentication#7319
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 008ec7937c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| 'bd_vid', | ||
| 'msclkid', | ||
| 'k', | ||
| 'source', |
There was a problem hiding this comment.
Avoid stripping the generic source query globally
Because useInitApp is mounted from projects/app/src/pages/_app.tsx, every page treats entries in this list as marketing-only parameters and getPathWithoutMarketingParams() removes them from the URL. Adding the generic source key breaks direct links such as /config/tool/marketplace?source=official or ?source=community: that page reads router.query.source to apply the marketplace source filter, but the global init strips it on mount and the filter is lost. Use a namespaced attribution query key or restrict this removal to the attribution entry flow.
Useful? React with 👍 / 👎.
Coverage Report
File CoverageNo changed files found. |
There was a problem hiding this comment.
Pull request overview
This PR wires homepage attribution (including visitor_id) into FastGPT’s existing marketing tracking, persists it on password login, and reports a CRM visitor identity binding when CRM env vars are configured.
Changes:
- Add
FastGPTSourceSchema/FastGPTTrackSemSchemaand client-side parsing/validation to storehome_sourcesafely infastgpt_sem. - Send
fastgpt_semthrough login flows and centralize “login success → clear marketing data” behavior. - Persist
home_sourceaslastsourceon password login and report CRM identity via a gated, failure-safe reporter; document new env vars and add deployment placeholders.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| projects/app/test/web/support/user/api.test.ts | Extends user API test fixture to include fastgpt_sem.home_source. |
| projects/app/test/web/support/marketing/utils.test.ts | Adds tests for source parsing, sem schema filtering, and login-success cleanup. |
| projects/app/test/api/support/user/account/loginByPassword.test.ts | Adds coverage for persisting home_source into fastgpt_sem.lastsource and adjusts Call generics. |
| projects/app/src/web/support/marketing/utils.ts | Adds schema-validated getFastGPTSem, parseFastGPTSource, and onFastGPTLoginSuccess. |
| projects/app/src/web/context/useInitApp.ts | Parses source query param into home_source, merges UTM fallbacks, and stores in fastgpt_sem. |
| projects/app/src/pages/login/provider.tsx | Uses onFastGPTLoginSuccess to clear marketing data post-login. |
| projects/app/src/pages/login/fastlogin.tsx | Sends fastgpt_sem with fast login and uses onFastGPTLoginSuccess. |
| projects/app/src/pages/api/support/user/account/loginByPassword.ts | Accepts fastgpt_sem, persists lastsource, and reports CRM visitor identity. |
| projects/app/src/pageComponents/login/RegisterForm.tsx | Uses onFastGPTLoginSuccess to clear marketing data post-registration login. |
| projects/app/src/pageComponents/login/LoginForm/WechatForm.tsx | Uses onFastGPTLoginSuccess to clear marketing data post-login. |
| projects/app/src/pageComponents/login/LoginForm/LoginForm.tsx | Sends fastgpt_sem on password login and uses onFastGPTLoginSuccess. |
| projects/app/.env.template | Documents new CRM_API_URL / CRM_API_KEY env vars. |
| packages/service/test/support/marketing/attribution.test.ts | Adds unit tests for gated CRM identity reporting and failure safety. |
| packages/service/support/marketing/attribution.ts | Implements reportCRMVisitorIdentity (gated by env vars, logs on failure). |
| packages/service/env.ts | Adds CRM_API_URL / CRM_API_KEY to service env schema. |
| packages/global/support/marketing/type.ts | Introduces FastGPTSourceSchema and separates tracking sem schema from persisted sem schema. |
| packages/global/openapi/support/user/account/login/api.ts | Extends login request schemas with TrackRegisterParamsSchema (incl. fastgpt_sem). |
| document/content/self-host/config/env.mdx | Documents CRM env vars (CN). |
| document/content/self-host/config/env.en.mdx | Documents CRM env vars (EN). |
| deploy/version/main/docker-compose.template.yml | Adds deployment placeholders for CRM env vars. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| await reportCRMVisitorIdentity({ | ||
| source: fastgpt_sem?.home_source, | ||
| userId: String(user._id), | ||
| username: user.username, | ||
| contact: user.contact | ||
| }); | ||
|
|
|
✅ Docs Preview Deployed! 🔗 👀 Click here to visit preview 🕒 Time: 2026-07-17 12:25:32 (UTC+8) |
|
✅ Admin Preview Image Ready! 🕒 Time: 2026-07-17 12:29:35 (UTC+8) |
|
✅ Build Successful - Preview fastgpt Image for this PR: 🕒 Time: 2026-07-16 23:16:10 (UTC+8) |
d752115 to
e354525
Compare
e354525 to
eb28cd0
Compare
Summary
visitor_idfrom the homepage and store it asfastgpt_sem.visitor_idfastgpt_source,fastgpt_sem.source,home_source,firstsource, andlastsourcecontactCRM_API_URLandCRM_API_KEYCompanion PRs
Validation
Notes
upstream/main@/assets/skill/runtimeUpgradeModalBg.jpg