Conversation
Update colors
Update colors
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
hyperterminal | 9e59576 | Mar 26 2026, 01:54 PM |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request integrates a comprehensive 'Hypermiles' points system into the application, designed to enhance user engagement and growth. It introduces a new modal for displaying user points and managing referrals, accessible directly from the main navigation. The system includes logic for capturing referral codes from URLs and automatically registering users, streamlining the onboarding process for referred users. Configuration for the new points API and Turnstile has also been updated, alongside necessary localization string additions. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new 'Hypermiles' points system, including a dedicated PointsModal for displaying user points, rank, and referral information, along with signup functionality. A 'Points' button has been added to the top navigation, which replaces the Faucet button on mainnet. The changes also include new referral capture and auto-registration hooks, updates to the global modal store, and environment variable configurations. Review comments suggest improvements for error logging in catch blocks and proper dependency management for useEffect hooks using useCallback in the new points modal and referral hooks.
| .catch(() => { | ||
| setError("Unable to connect to points service"); | ||
| setView("error"); | ||
| }); |
There was a problem hiding this comment.
For better observability and easier debugging, it's a good practice to log caught errors to the console. This applies here and in the catch block of the handleSignup function (line 182).
.catch((error) => {
console.error("Failed to fetch points:", error);
setError("Unable to connect to points service");
setView("error");
});
| // biome-ignore lint/correctness/useExhaustiveDependencies: fetchPoints is intentionally excluded to avoid re-creating on every render | ||
| useEffect(() => { | ||
| if (!open || !address) return; | ||
| fetchPoints(); | ||
| }, [open, address]); |
There was a problem hiding this comment.
This useEffect is ignoring the exhaustive-deps lint rule. To fix this properly, you should wrap the fetchPoints function in a useCallback hook. This will give fetchPoints a stable identity and allow you to include it in the dependency array, satisfying the lint rule and making the data flow more explicit.
Example for fetchPoints:
const fetchPoints = useCallback(() => {
// ... function body
}, [address]);Then you can add fetchPoints to this useEffect's dependency array.
| } catch (err) { | ||
| setError(err instanceof Error ? err.message : "Signup failed"); |
There was a problem hiding this comment.
It's a good practice to log caught errors for easier debugging. The actual error object err is available here but is not being logged to the console.
| } catch (err) { | |
| setError(err instanceof Error ? err.message : "Signup failed"); | |
| } catch (err) { | |
| console.error("Signup failed:", err); | |
| setError(err instanceof Error ? err.message : "Signup failed"); |
src/hooks/use-referral.ts
Outdated
| .catch(() => { | ||
| registeredRef.current = false; | ||
| }); |
There was a problem hiding this comment.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements a new referral system. It introduces useReferralCapture to extract referral codes from the URL and store them, and useAutoRegisterReferral to automatically register users with these codes upon wallet connection. The points modal has been updated to use stored referral codes, improve error logging, and display a full referral link. A suggestion was made to refactor the useAutoRegisterReferral hook's useEffect logic to use async/await for improved readability and more explicit error handling, as the current promise chain might inadvertently swallow errors.
| useEffect(() => { | ||
| if (!isConnected || !address || registeredRef.current) return; | ||
|
|
||
| registeredRef.current = true; | ||
|
|
||
| fetch(`${API_URL}/user_points?user_address=${address}`) | ||
| .then((res) => { | ||
| if (res.ok) { | ||
| clearStoredReferral(); | ||
| return; | ||
| } | ||
| if (res.status === 404) { | ||
| const referral = getStoredReferral(); | ||
| const body: Record<string, string> = { walletAddress: address }; | ||
| if (referral) { | ||
| body.referralCode = referral; | ||
| } | ||
| if (user?.id) { | ||
| body.privyUserId = user.id; | ||
| } | ||
| return fetch(`${API_URL}/users`, { | ||
| method: "POST", | ||
| headers: { "Content-Type": "application/json" }, | ||
| body: JSON.stringify(body), | ||
| }).then(() => { | ||
| clearStoredReferral(); | ||
| }); | ||
| } | ||
| }) | ||
| .catch(() => { | ||
| registeredRef.current = false; | ||
| }); | ||
| }, [isConnected, address, user?.id]); |
There was a problem hiding this comment.
The logic inside this useEffect can be simplified and made more readable by using async/await. This also provides an opportunity to handle errors more explicitly by logging them in a catch block. The current implementation swallows errors, which can make debugging difficult.
useEffect(() => {
const autoRegister = async () => {
if (!isConnected || !address || registeredRef.current) return;
registeredRef.current = true;
try {
const res = await fetch(`${API_URL}/user_points?user_address=${address}`);
if (res.ok) {
clearStoredReferral();
return;
}
if (res.status === 404) {
const referral = getStoredReferral();
const body: Record<string, string> = { walletAddress: address };
if (referral) {
body.referralCode = referral;
}
if (user?.id) {
body.privyUserId = user.id;
}
await fetch(`${API_URL}/users`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
clearStoredReferral();
}
} catch (error) {
console.error("Auto-registration failed:", error);
registeredRef.current = false;
}
};
autoRegister();
}, [isConnected, address, user?.id]);
No description provided.