Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Updates to Preview Branch (feat/add-secondary-ga-stream) ↗︎
Tasks are run on every commit but only new migration files are pushed.
View logs for this Workflow Run ↗︎. |
WalkthroughA new Google Analytics ID constant is added and an additional GoogleAnalytics component is injected into the RootLayout in Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/app/layout.tsx`:
- Line 212: The GoogleAnalytics call with GA_NEAR_COM_ID is being rendered
unconditionally; restrict it the same way NearComPromo is gated so only
production and approved templates (e.g., near-intents) load it to avoid
double-streaming and whitelabel leaks. Update the Layout (around where
GoogleAnalytics and per-template GA are used) to check isProduction (or
process/env flag) AND that the current template identifier (the prop/state used
to decide templates—e.g., templateName/templateSlug/selectedTemplate) is in an
allowlist before rendering <GoogleAnalytics gaId={GA_NEAR_COM_ID} />; leave the
existing per-template GA rendering (the GA for lines 209–211) unchanged. Ensure
the allowlist matches the templates that should report to near.com (likely only
"near-intents") and add a short comment explaining why the gate exists.
| <GoogleAnalytics | ||
| gaId={tmpl === "omniswap" ? GA_OMNI_SWAP_ID : GA_NEAR_INTENTS_ID} | ||
| /> | ||
| <GoogleAnalytics gaId={GA_NEAR_COM_ID} /> |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== GA wiring in root layout =="
rg -nP --type=tsx 'GA_[A-Z_]+_ID|GoogleAnalytics' src/app/layout.tsx
echo
echo "== Template branches currently defined in layout metadata/root =="
rg -nP --type=tsx 'templ\s*===\s*"[^"]+"|tmpl\s*===\s*"[^"]+"' src/app/layout.tsx
echo
echo "== Other GA/gtag instrumentation across repo =="
rg -nP --type=ts --type=tsx 'GoogleAnalytics|gtag\s*\(|page_view|send_page_view'Repository: defuse-protocol/defuse-frontend
Length of output: 150
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Check if file exists
ls -la src/app/layout.tsx
echo
echo "== File size and content around line 212 =="
wc -l src/app/layout.tsx
echo
echo "== Reading content from line 200-220 =="
sed -n '200,220p' src/app/layout.tsx
echo
echo "== GA wiring in root layout (no type filter) =="
rg -n 'GA_[A-Z_]+_ID|GoogleAnalytics' src/app/layout.tsx
echo
echo "== Template variable references =="
rg -n 'tmpl|template' src/app/layout.tsx | head -20
echo
echo "== Other GA/gtag instrumentation across repo =="
rg -n 'GoogleAnalytics|gtag\s*\(|page_view|send_page_view' . --type ts 2>/dev/null | head -30Repository: defuse-protocol/defuse-frontend
Length of output: 1722
🏁 Script executed:
#!/bin/bash
# Check for any documentation or comments about APP_ENV, template strategy, or GA management
echo "== Checking APP_ENV definition and usage context =="
rg -n 'APP_ENV\s*=' src/app/layout.tsx
echo
echo "== Context around line 156 (tmpl initialization) =="
sed -n '150,165p' src/app/layout.tsx
echo
echo "== Search for whitelabel or template documentation =="
rg -n 'whitelabel|WHITELABEL' . --type ts 2>/dev/null || echo "No whitelabel refs found"Repository: defuse-protocol/defuse-frontend
Length of output: 8572
Gate GA_NEAR_COM_ID to intended templates only to prevent double-streaming and whitelabel boundary violations.
At Line 212, GA_NEAR_COM_ID renders unconditionally, meaning every template (omniswap, solswap, turboswap, dogecoinswap, trumpswap, rabitswap, near-intents) sends telemetry to this stream. This creates double-streaming—each template already has a dedicated GA stream routed at lines 209–211—and violates whitelabel boundaries for branded templates that should not report to near.com telemetry.
The codebase already gates template-specific content (e.g., NearComPromo only renders for near-intents), so apply the same pattern here. Restrict GA_NEAR_COM_ID to production + intended templates (likely near-intents only, or a defined allowlist):
Proposed guard
+ const shouldLoadNearComGa =
+ APP_ENV === "production" &&
+ tmpl === "near-intents"
+
return (
<html lang="en" suppressHydrationWarning className={`tmpl-${tmpl}`}>
@@
- <GoogleAnalytics gaId={GA_NEAR_COM_ID} />
+ {shouldLoadNearComGa && <GoogleAnalytics gaId={GA_NEAR_COM_ID} />}
{HELPSCOUT_BEACON_ID && <Helpscout />}
</html>
)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/app/layout.tsx` at line 212, The GoogleAnalytics call with GA_NEAR_COM_ID
is being rendered unconditionally; restrict it the same way NearComPromo is
gated so only production and approved templates (e.g., near-intents) load it to
avoid double-streaming and whitelabel leaks. Update the Layout (around where
GoogleAnalytics and per-template GA are used) to check isProduction (or
process/env flag) AND that the current template identifier (the prop/state used
to decide templates—e.g., templateName/templateSlug/selectedTemplate) is in an
allowlist before rendering <GoogleAnalytics gaId={GA_NEAR_COM_ID} />; leave the
existing per-template GA rendering (the GA for lines 209–211) unchanged. Ensure
the allowlist matches the templates that should report to near.com (likely only
"near-intents") and add a short comment explaining why the gate exists.
There was a problem hiding this comment.
This is intentional, the PR title is literally "complementary GA code backup."
There was a problem hiding this comment.
@devsparrow5, understood—thank you for clarifying. Since the backup GA stream is intentional, I'll defer to your design decision here. Just to confirm you're aware: this will send telemetry from all templates (omniswap, turboswap, dogecoinswap, etc.) to GA_NEAR_COM_ID in addition to their dedicated streams, which may affect analytics segmentation and whitelabel data isolation, but if that's acceptable for the backup strategy, no further changes are needed.
No description provided.