-
Notifications
You must be signed in to change notification settings - Fork 8
Algolia and GA #203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Algolia and GA #203
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughAdds Google Analytics Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@docs/.vitepress/config.mts`:
- Around line 48-53: Gate Google Analytics initialization behind explicit user
consent: modify the two script entries that inject gtag (the ['script', ...]
entries and the inline gtag setup invoking gtag('config')) to first set consent
defaults to denied (use gtag('consent', 'default', {ad_storage:'denied',
analytics_storage:'denied'})) and remove or delay the gtag('config') call;
implement a consent callback (or expose a function like enableGtagConsent())
that upon user opt-in calls gtag('consent','update', {ad_storage:'granted',
analytics_storage:'granted'}) and then calls gtag('config', 'G-JF828SKW90') so
analytics are only configured after consent.
🧹 Nitpick comments (1)
docs/.vitepress/config.mts (1)
631-637: Algolia search-only keys are designed to be publicly committed; consider env injection for easier rotation.This appears to be a search-only API key (correct for a public docs search provider). Algolia and DocSearch explicitly state that search-only keys are safe to share publicly, including in git. However, using an environment variable (
process.env.ALGOLIA_SEARCH_KEY) would simplify future rotation without requiring a git commit. This is optional rather than urgent.♻️ Env-injected key (optional)
options: { appId: 'AXICJJC8RP', - apiKey: '23df4157dee1d9a8d435cadd6cae3f26', + apiKey: process.env.ALGOLIA_SEARCH_KEY ?? '23df4157dee1d9a8d435cadd6cae3f26', indexName: 'plane_developer_docs', searchParameters: { facetFilters: [] }, insights: true,
| // Google Analytics | ||
| ['script', { async: '', src: 'https://www.googletagmanager.com/gtag/js?id=G-JF828SKW90' }], | ||
| ['script', {}, `window.dataLayer = window.dataLayer || []; | ||
| function gtag(){dataLayer.push(arguments);} | ||
| gtag('js', new Date()); | ||
| gtag('config', 'G-JF828SKW90');`], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
# First, read the config.mts file to see the exact implementation
cat -n docs/.vitepress/config.mts | head -100Repository: makeplane/developer-docs
Length of output: 4399
🏁 Script executed:
# Search for consent-related code in the codebase
rg -i "consent|gtag|analytics" --type ts --type js --type mts --type vue -A 3 -B 1Repository: makeplane/developer-docs
Length of output: 95
🏁 Script executed:
# Check if there's a consent banner or cookie consent implementation
fd -e vue -e ts -e js . | xargs grep -l -i "consent\|cookie" 2>/dev/null | head -20Repository: makeplane/developer-docs
Length of output: 50
🏁 Script executed:
# Look for environment variables or configuration related to GA/analytics
rg "VITE_|GOOGLE|ANALYTICS|gtag" docs/ --type mts --type tsRepository: makeplane/developer-docs
Length of output: 95
🏁 Script executed:
# Search for consent-related code in Vue and TS files (broader search)
find docs -type f \( -name "*.vue" -o -name "*.ts" -o -name "*.js" \) | xargs grep -l -i "consent\|gtag\|analytics" 2>/dev/nullRepository: makeplane/developer-docs
Length of output: 52
🏁 Script executed:
# Check if there's a layout or theme file that might wrap the GA initialization
find docs/.vitepress -type f \( -name "*.vue" -o -name "*.ts" -o -name "*.js" \) | head -20Repository: makeplane/developer-docs
Length of output: 331
🏁 Script executed:
# Search entire codebase for gtag references
grep -r "gtag\|consent" docs --include="*.vue" --include="*.ts" --include="*.js" 2>/dev/nullRepository: makeplane/developer-docs
Length of output: 50
🏁 Script executed:
# Look for environment-based GA initialization or feature flags
grep -r "ANALYTICS\|GA_" . --include="*.vue" --include="*.ts" --include="*.js" --include="*.env*" --include="*.mts" 2>/dev/nullRepository: makeplane/developer-docs
Length of output: 50
🏁 Script executed:
# Read the theme index to see how GA might be handled
cat -n docs/.vitepress/theme/index.tsRepository: makeplane/developer-docs
Length of output: 4915
🏁 Script executed:
# Check for Layout components
find docs/.vitepress/theme -name "*Layout*" -o -name "Layout.*"Repository: makeplane/developer-docs
Length of output: 50
🏁 Script executed:
# Look for app setup or useRouter hooks that might modify GA
grep -r "useRouter\|onMounted\|mounted" docs/.vitepress/theme --include="*.vue" --include="*.ts" -A 3Repository: makeplane/developer-docs
Length of output: 585
🏁 Script executed:
# Final check for any cookie consent library (Cookiebot, CookieConsent, etc.)
grep -r "cookie\|consent\|onetrust\|cookiebot\|iubenda" docs --include="*.html" --include="*.vue" --include="*.ts" --include="*.js" --include="*.mts" 2>/dev/null || echo "No cookie consent found"Repository: makeplane/developer-docs
Length of output: 91
🏁 Script executed:
# Check if gtag is referenced anywhere else or if consent mode is set elsewhere
grep -r "window.dataLayer\|gtag.*'consent'\|gtag('config'" . --include="*.vue" --include="*.ts" --include="*.js" --include="*.mts" 2>/dev/null || echo "No additional gtag references"Repository: makeplane/developer-docs
Length of output: 229
Gate GA initialization behind user consent before calling gtag('config').
Google Analytics is loaded and configured for all visitors without consent checks. No cookie consent banner or consent mode is implemented. For GDPR and CCPA compliance, configure consent mode to default to "denied" and only call gtag('config') after users opt in, or implement a consent banner to gate the second script tag.
🤖 Prompt for AI Agents
In `@docs/.vitepress/config.mts` around lines 48 - 53, Gate Google Analytics
initialization behind explicit user consent: modify the two script entries that
inject gtag (the ['script', ...] entries and the inline gtag setup invoking
gtag('config')) to first set consent defaults to denied (use gtag('consent',
'default', {ad_storage:'denied', analytics_storage:'denied'})) and remove or
delay the gtag('config') call; implement a consent callback (or expose a
function like enableGtagConsent()) that upon user opt-in calls
gtag('consent','update', {ad_storage:'granted', analytics_storage:'granted'})
and then calls gtag('config', 'G-JF828SKW90') so analytics are only configured
after consent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@docs/.vitepress/config.mts`:
- Line 31: The config sets lang: 'root', which is not a valid BCP 47 tag and
will produce improper <html lang="">; update the exported VitePress config
object (the lang property) to a valid BCP 47 tag such as 'en' or 'en-US' (e.g.,
replace 'root' with 'en' or 'en-US') so screen readers and SEO receive a correct
language attribute.
docs/.vitepress/config.mts
Outdated
| ], | ||
| }, | ||
| }, | ||
| lang: 'root', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalid lang value: 'root' is not a valid BCP 47 language tag.
The lang attribute is used for the <html lang=""> attribute which affects screen readers and SEO. Use a valid language code like 'en' or 'en-US' instead.
🛠️ Proposed fix
- lang: 'root',
+ lang: 'en',📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| lang: 'root', | |
| lang: 'en', |
🤖 Prompt for AI Agents
In `@docs/.vitepress/config.mts` at line 31, The config sets lang: 'root', which
is not a valid BCP 47 tag and will produce improper <html lang="">; update the
exported VitePress config object (the lang property) to a valid BCP 47 tag such
as 'en' or 'en-US' (e.g., replace 'root' with 'en' or 'en-US') so screen readers
and SEO receive a correct language attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@docs/.vitepress/config.mts`:
- Around line 628-635: The Algolia credentials are hardcoded in the
search.options object (appId and apiKey) — replace the literal values for appId
and apiKey with environment variables (e.g., read from process.env or Vite's
import.meta.env) so search.options.appId and search.options.apiKey pull from
ALGOLIA_APP_ID and ALGOLIA_SEARCH_KEY at build time; keep indexName and insights
as-is, update docs/deployment settings to declare those env vars
(ALGOLIA_APP_ID, ALGOLIA_SEARCH_KEY) and ensure CI/Vercel build config injects
them for production builds.
| search: { | ||
| provider: 'local' | ||
| provider: 'algolia', | ||
| options: { | ||
| appId: 'AXICJJC8RP', | ||
| apiKey: '23df4157dee1d9a8d435cadd6cae3f26', | ||
| indexName: 'plane_developer_docs', | ||
| insights: true, | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
# First, let's check the actual content of the config file at the specified lines
if [ -f "docs/.vitepress/config.mts" ]; then
wc -l docs/.vitepress/config.mts
sed -n '620,645p' docs/.vitepress/config.mts
fiRepository: makeplane/developer-docs
Length of output: 866
🏁 Script executed:
# Check for any environment variable configuration or .env files
find . -type f \( -name ".env*" -o -name "*.example" \) | head -20Repository: makeplane/developer-docs
Length of output: 50
🏁 Script executed:
# Search for Algolia configuration elsewhere in the codebase
rg -i "algolia" --type ts --type js --type mts -A 5 -B 5 | head -100Repository: makeplane/developer-docs
Length of output: 95
🏁 Script executed:
# Check if there's documentation about environment setup
find . -type f \( -name "README*" -o -name "SETUP*" -o -name "ENV*" -o -name "CONFIG*" \) | grep -E "(^|/)(README|SETUP|ENV|CONFIG)" | head -20Repository: makeplane/developer-docs
Length of output: 79
🏁 Script executed:
# Read the README to check for environment setup instructions
cat README.md | head -100Repository: makeplane/developer-docs
Length of output: 2285
🏁 Script executed:
# Search for any documentation files mentioning Algolia or API keys
find . -type f -name "*.md" -exec grep -l -i "algolia\|api.?key\|env" {} \; | head -20Repository: makeplane/developer-docs
Length of output: 1925
🏁 Script executed:
# Check the git history for this file to see if keys were recently added or if there's been discussion
git log --oneline -20 -- docs/.vitepress/config.mtsRepository: makeplane/developer-docs
Length of output: 103
🏁 Script executed:
# Check package.json for build process and any env setup
cat package.json | grep -A 10 -B 5 "algolia\|env\|script"Repository: makeplane/developer-docs
Length of output: 401
🏁 Script executed:
# Search for any build or deployment configuration
find . -type f -name "*.json" -o -name "*.yml" -o -name "*.yaml" -o -name "*.config.*" | grep -v node_modules | head -20Repository: makeplane/developer-docs
Length of output: 166
🏁 Script executed:
# Check if there's a .gitignore to understand what's typically ignored
cat .gitignore 2>/dev/null | grep -i "env\|algolia\|key\|secret" || echo "No matching patterns in .gitignore"Repository: makeplane/developer-docs
Length of output: 102
🏁 Script executed:
# Check vercel.json deployment configuration
cat vercel.jsonRepository: makeplane/developer-docs
Length of output: 91
🏁 Script executed:
# Check if there's any build environment setup or CI/CD config
find . -type f \( -name ".github" -o -name ".*yml" -o -name ".*yaml" \) | head -20
ls -la .github/ 2>/dev/null || echo "No .github directory"Repository: makeplane/developer-docs
Length of output: 88
Move Algolia credentials to environment variables; avoid committing API keys to version control.
Lines 631-632 expose an Algolia API key and app ID in the repository. Even if this is a search-only key intended for public use, hardcoding credentials violates security best practices and prevents easy credential rotation without code changes. Use environment variables at build time instead:
Suggested change
- appId: 'AXICJJC8RP',
- apiKey: '23df4157dee1d9a8d435cadd6cae3f26',
+ appId: process.env.ALGOLIA_APP_ID ?? '',
+ apiKey: process.env.ALGOLIA_SEARCH_KEY ?? '',Document the required environment variables (ALGOLIA_APP_ID, ALGOLIA_SEARCH_KEY) in your deployment configuration (e.g., Vercel dashboard or build environment).
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| search: { | |
| provider: 'local' | |
| provider: 'algolia', | |
| options: { | |
| appId: 'AXICJJC8RP', | |
| apiKey: '23df4157dee1d9a8d435cadd6cae3f26', | |
| indexName: 'plane_developer_docs', | |
| insights: true, | |
| } | |
| search: { | |
| provider: 'algolia', | |
| options: { | |
| appId: process.env.ALGOLIA_APP_ID ?? '', | |
| apiKey: process.env.ALGOLIA_SEARCH_KEY ?? '', | |
| indexName: 'plane_developer_docs', | |
| insights: true, | |
| } |
🧰 Tools
🪛 Gitleaks (8.30.0)
[high] 632-632: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
🤖 Prompt for AI Agents
In `@docs/.vitepress/config.mts` around lines 628 - 635, The Algolia credentials
are hardcoded in the search.options object (appId and apiKey) — replace the
literal values for appId and apiKey with environment variables (e.g., read from
process.env or Vite's import.meta.env) so search.options.appId and
search.options.apiKey pull from ALGOLIA_APP_ID and ALGOLIA_SEARCH_KEY at build
time; keep indexName and insights as-is, update docs/deployment settings to
declare those env vars (ALGOLIA_APP_ID, ALGOLIA_SEARCH_KEY) and ensure CI/Vercel
build config injects them for production builds.
Description
Type of Change
Screenshots and Media (if applicable)
Test Scenarios
References
Summary by CodeRabbit
New Features
Documentation