Skip to content

Chore/landing-page-analytics#381

Merged
IAmKio merged 3 commits intostagingfrom
chore/landing-page-analytics
Aug 6, 2025
Merged

Chore/landing-page-analytics#381
IAmKio merged 3 commits intostagingfrom
chore/landing-page-analytics

Conversation

@ashutoshamazix
Copy link
Collaborator

@ashutoshamazix ashutoshamazix commented Aug 1, 2025

Description

  • Added Plausible analytics to login page buttons

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Summary by CodeRabbit

  • New Features
    • Added analytics tracking for button clicks on the login page to monitor user interactions.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 1, 2025

Walkthrough

The Login page now integrates analytics tracking using the plausible-tracker library. Button click handlers are updated to log specific events when users interact with "Get Started" and "Connect Pillar Wallet" actions, utilizing environment variables for configuration. No exported entity signatures were changed.

Changes

Cohort / File(s) Change Summary
Login Page Analytics Integration
src/pages/Login.tsx
Added Plausible analytics tracker initialization and event logging to button click handlers.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant LoginPage
    participant PlausibleTracker

    User->>LoginPage: Clicks "Get Started" or "Connect Pillar Wallet"
    LoginPage->>PlausibleTracker: trackEvent("Login Page Get Started" or "Login Page Connect Pillar Wallet")
    LoginPage->>LoginPage: Execute original login or wallet connect logic
Loading

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Suggested reviewers

  • IAmKio

Poem

A bunny hopped onto the login scene,
With Plausible tracking, now events are seen.
Clicks on buttons, logged with delight,
Analytics sparkle, data in sight!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb496ad and 2313ef8.

📒 Files selected for processing (1)
  • src/pages/Login.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pages/Login.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: unit-tests
  • GitHub Check: lint
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/landing-page-analytics

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2db2248 and eb496ad.

📒 Files selected for processing (1)
  • src/pages/Login.tsx (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/pages/Login.tsx (1)
src/components/LandingPage/Button/index.jsx (1)
  • Button (38-61)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: unit-tests
  • GitHub Check: lint

Comment on lines +8 to 9
import Plausible from 'plausible-tracker';

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Guard against SSR / prerender breakage
plausible-tracker accesses window. Importing & initialising it at module top-level will crash during server-side rendering or static prerender where window is undefined. Wrap the initialisation in a browser check (or lazy-load in useEffect) so the page remains render-safe.

🤖 Prompt for AI Agents
In src/pages/Login.tsx around lines 8 to 9, importing plausible-tracker at the
top level causes crashes during server-side rendering because it accesses
window, which is undefined in that context. To fix this, remove the top-level
import and instead dynamically import and initialize plausible-tracker inside a
useEffect hook with a check to ensure it only runs in the browser environment.
This will prevent SSR/prerender breakage by deferring the code that accesses
window until after the component mounts on the client.

Comment on lines +19 to +22
// Plausible Domain Config
const { trackEvent } = Plausible({
domain: import.meta.env.VITE_PLAUSIBLE_DOMAIN,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add a safe fallback when env variable is missing
If VITE_PLAUSIBLE_DOMAIN is empty the tracker still initialises and will fire network requests to undefined, throwing in dev tools. Return a no-op implementation instead:

-// Plausible Domain Config
-const { trackEvent } = Plausible({
-  domain: import.meta.env.VITE_PLAUSIBLE_DOMAIN,
-});
+// Plausible Domain Config
+const domain = import.meta.env.VITE_PLAUSIBLE_DOMAIN;
+const plausible =
+  typeof window !== 'undefined' && domain
+    ? Plausible({ domain })
+    : { trackEvent: () => {} }; // graceful no-op
+
+const { trackEvent } = plausible;
📝 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.

Suggested change
// Plausible Domain Config
const { trackEvent } = Plausible({
domain: import.meta.env.VITE_PLAUSIBLE_DOMAIN,
});
// Plausible Domain Config
const domain = import.meta.env.VITE_PLAUSIBLE_DOMAIN;
const plausible =
typeof window !== 'undefined' && domain
? Plausible({ domain })
: { trackEvent: () => {} }; // graceful no-op
const { trackEvent } = plausible;
🤖 Prompt for AI Agents
In src/pages/Login.tsx around lines 19 to 22, the Plausible tracker is
initialized directly with the environment variable VITE_PLAUSIBLE_DOMAIN, which
can be undefined and cause network errors. Modify the code to check if
VITE_PLAUSIBLE_DOMAIN is set; if not, return a no-op implementation for
trackEvent that does nothing to prevent errors and unnecessary network requests.

Comment on lines 189 to 195
)}
<InsideWrapper>
<Button onClick={login} $fullWidth>{t`action.getStarted`}</Button>
<Button onClick={listenForWalletConnectUri} $last $fullWidth>
<Button onClick={() => {trackEvent('Login Page Get Started'); login();}} $fullWidth>{t`action.getStarted`}</Button>
<Button onClick={() => {trackEvent('Login Page Connect Pillar Wallet'); listenForWalletConnectUri();}} $last $fullWidth>
<img src={PillarWalletIcon} alt="pillar-wallet-icon" />
{t`action.connectPillarWallet`}
</Button>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Guarantee analytics event delivery before navigation
login() / listenForWalletConnectUri() often trigger a full page reload, cancelling the fetch sent by trackEvent. Use the tracker’s callback (or at least transport:"beacon") and avoid recreating handlers on every render:

-<Button onClick={() => {trackEvent('Login Page Get Started'); login();}} $fullWidth>{t`action.getStarted`}</Button>
-<Button onClick={() => {trackEvent('Login Page Connect Pillar Wallet'); listenForWalletConnectUri();}} $last $fullWidth>
+const handleGetStarted = () =>
+  trackEvent('Login Page Get Started', {
+    transport: 'beacon',
+    callback: login,
+  });
+
+const handleConnectPillar = () =>
+  trackEvent('Login Page Connect Pillar Wallet', {
+    transport: 'beacon',
+    callback: listenForWalletConnectUri,
+  });
+
+<Button onClick={handleGetStarted} $fullWidth>
+  {t`action.getStarted`}
+</Button>
+<Button onClick={handleConnectPillar} $last $fullWidth>
   <img src={PillarWalletIcon} alt="pillar-wallet-icon" />
   {t`action.connectPillarWallet`}
 </Button>

This both improves reliability of analytics and prevents unnecessary re-renders by using stable function references.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In src/pages/Login.tsx around lines 189 to 195, the current onClick handlers
call trackEvent followed immediately by functions that trigger page reloads,
causing the analytics fetch to be cancelled. To fix this, use the trackEvent
function's callback parameter to ensure the event is sent before navigation, or
use transport:"beacon" for reliable delivery. Also, define the onClick handlers
as stable functions outside the render to avoid recreating them on every render,
improving performance and analytics reliability.

@cloudflare-workers-and-pages
Copy link

Deploying x with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2313ef8
Status: ✅  Deploy successful!
Preview URL: https://b35ed99d.x-e62.pages.dev
Branch Preview URL: https://chore-landing-page-analytics.x-e62.pages.dev

View logs

@ashutoshamazix ashutoshamazix requested a review from IAmKio August 1, 2025 09:58
@IAmKio IAmKio merged commit f62acdd into staging Aug 6, 2025
6 checks passed
@IAmKio IAmKio deleted the chore/landing-page-analytics branch August 6, 2025 10:50
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