Skip to content
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

feat: Improve codebase Onboarding #3867

Merged
merged 1 commit into from
Oct 7, 2024

Conversation

JoseRFelix
Copy link
Collaborator

What is the purpose of the change:

This PR improves the onboarding process by addressing issues related to the initial build when environment variables have not been set up. Specifically, we replaced the hardcoded Osmosis API URL, which requires an API key, with a fallback to the free Coingecko API. While the Coingecko API has rate limits, it is sufficient for initial onboarding and short-term contributions to the code base.

Additionally, this PR updates the default feature flags to display a more up-to-date UI that aligns closely with the current production version. The README has also been updated to streamline the first installation and dev server setup. With these improvements, setting up the code base is now as simple as following the included instructions.

Linear Task

https://linear.app/osmosis/issue/FE-1146/improve-osmosis-fe-onboarding

Brief Changelog

  • Update README
  • Use free Coingecko API when the Osmosis API Key is not available
  • Update default Feature Flags to match current production UI

Copy link

vercel bot commented Oct 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
osmosis-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 4, 2024 4:58am
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
osmosis-frontend-datadog ⬜️ Ignored (Inspect) Oct 4, 2024 4:58am
osmosis-frontend-dev ⬜️ Ignored (Inspect) Oct 4, 2024 4:58am
osmosis-frontend-edgenet ⬜️ Ignored (Inspect) Oct 4, 2024 4:58am
osmosis-testnet ⬜️ Ignored (Inspect) Oct 4, 2024 4:58am

Copy link
Contributor

coderabbitai bot commented Oct 4, 2024

Walkthrough

The pull request includes modifications to the README.md file to improve clarity and update user instructions, particularly regarding the transition to a tRPC stack. Changes were made to the "Contributing" section to include a new build step, and the "Testnet" section was expanded with additional instructions. In the code, the packages/server/src/queries/coingecko/index.ts file was updated to conditionally assign API URLs based on the presence of an environment variable. Additionally, the packages/web/hooks/use-feature-flags.ts file saw updates to feature flag values and logic.

Changes

File Path Change Summary
README.md Updated instructions for transitioning to tRPC, added build step in "Contributing", expanded "Testnet" section, and noted release suspension.
packages/server/src/queries/coingecko/index.ts Modified PRICES_API_URL and DETAILS_API_URL to be conditional based on COINGECKO_API_KEY, introduced COINGECKO_API_URL.
packages/web/hooks/use-feature-flags.ts Updated feature flags in defaultFlags and adjusted logic for returning flags based on isDevModeWithoutClientID.

Possibly related PRs

Suggested reviewers

  • MaxMillington
  • DavideSegullo
  • PaddyMc

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

@JoseRFelix JoseRFelix requested a review from a team October 4, 2024 04:58
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: 0

🧹 Outside diff range and nitpick comments (8)
packages/server/src/queries/coingecko/index.ts (2)

9-11: LGTM: Conditional assignment of PRICES_API_URL

The conditional assignment of PRICES_API_URL effectively implements the fallback mechanism to the free Coingecko API when the Osmosis API key is not available. This change aligns well with the PR objective of improving the onboarding process.

For improved clarity, consider adding a brief comment explaining the purpose of this conditional assignment:

// Use Osmosis API if COINGECKO_API_KEY is available, otherwise fallback to free Coingecko API
export const PRICES_API_URL = process.env.COINGECKO_API_KEY
  ? "https://prices.osmosis.zone"
  : COINGECKO_API_URL;

12-14: LGTM: Conditional assignment of DETAILS_API_URL

The conditional assignment of DETAILS_API_URL follows the same pattern as PRICES_API_URL, providing a consistent fallback mechanism to the free Coingecko API when the Osmosis API key is not available. This change further supports the PR objective of improving the onboarding process.

For consistency and improved clarity, consider adding a brief comment here as well:

// Use Osmosis API if COINGECKO_API_KEY is available, otherwise fallback to free Coingecko API
export const DETAILS_API_URL = process.env.COINGECKO_API_KEY
  ? "https://coingecko.osmosis.zone"
  : COINGECKO_API_URL;
packages/web/hooks/use-feature-flags.ts (3)

48-55: LGTM! Consider updating documentation.

The changes to the default feature flags align with the PR objectives to reflect the current production UI. This update will improve the onboarding experience for new developers.

Consider updating the README or relevant documentation to reflect these new default feature flag values, ensuring new contributors are aware of the expected default behavior.


107-111: LGTM! Consider a minor refactor for readability.

The new logic for the oneClickTrading flag improves control over the feature's availability and aligns with the PR objectives. It correctly handles development mode without a client ID and ensures the feature is only enabled under specific conditions.

Consider refactoring the condition for better readability:

oneClickTrading: isDevModeWithoutClientID
  ? defaultFlags.oneClickTrading
  : !isMobile && launchdarklyFlags.swapToolSimulateFee && launchdarklyFlags.oneClickTrading,

This refactor maintains the same logic while making it slightly more concise and easier to read.


114-121: LGTM! Consider a minor optimization.

The new logic for the limitOrders flag successfully implements geoblocking functionality and improves the development experience. It aligns well with the PR objectives.

Consider this minor optimization to reduce nesting and improve readability:

limitOrders: isDevModeWithoutClientID
  ? defaultFlags.limitOrders
  : isInitialized &&
    launchdarklyFlags.limitOrders &&
    (LIMIT_ORDER_COUNTRY_CODES.length === 0 ||
     LIMIT_ORDER_COUNTRY_CODES.includes(levanaGeoblock?.countryCode ?? ""))

This refactor maintains the same logic while slightly reducing nesting and improving readability.

README.md (3)

54-60: Improved setup instructions for contributors.

The addition of the build step is crucial for ensuring all necessary artifacts are created before running the local server. This change significantly improves the onboarding process for new contributors.

Consider adding a brief explanation of why the build step is necessary. For example:

2. Run an initial build to create packages build artifacts (this step is crucial for setting up the monorepo structure):

```bash
yarn build

---

Line range hint `62-89`: **Comprehensive testnet development instructions added.**

The new testnet section provides valuable information for both public and local testnet development. The inclusion of environment variable examples and the note about updating IBC assets are particularly helpful for new contributors.



Consider adding a brief explanation of the difference between the public testnet and a local testnet, and when a developer might choose one over the other. This could help new contributors make informed decisions about their development environment.

---

Line range hint `91-93`: **Important release status update added.**

The new note in the "Releases" section provides critical information about the suspension of releases during the refactor. This warning is essential for preventing potential issues for users of the packages.



Consider adding an estimated timeline for the completion of the refactor, if possible. This could help users plan their development accordingly. For example:
```markdown
> Note: releases are suspended until the refactor is complete (estimated completion: Q4 2023). Please avoid importing packages from this repo until further notice. We will announce when releases resume on our official communication channels.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 29437aa and cf8c307.

📒 Files selected for processing (3)
  • README.md (1 hunks)
  • packages/server/src/queries/coingecko/index.ts (1 hunks)
  • packages/web/hooks/use-feature-flags.ts (2 hunks)
🔇 Additional comments (5)
packages/server/src/queries/coingecko/index.ts (2)

7-8: LGTM: Introduction of COINGECKO_API_URL constant

The addition of the COINGECKO_API_URL constant is a good approach. It centralizes the Coingecko API base URL, making it easier to maintain and update if needed in the future. This change aligns well with the PR objective of providing a fallback to the free Coingecko API when the Osmosis API key is not available.


7-14: Summary: Effective implementation of API fallback mechanism

The changes in this file successfully implement a fallback mechanism to the free Coingecko API when the Osmosis API key is not available. This aligns perfectly with the PR objective of improving the onboarding process for new contributors.

Key points:

  1. Introduction of COINGECKO_API_URL constant for centralized management of the Coingecko API base URL.
  2. Conditional assignments for both PRICES_API_URL and DETAILS_API_URL to use either the Osmosis API or fall back to the Coingecko API.

These changes should effectively resolve the issues encountered during the initial build when environment variables are not configured, making it easier for new contributors to get started with the project.

To further enhance the code:

  • Consider adding brief comments explaining the purpose of the conditional assignments for both PRICES_API_URL and DETAILS_API_URL.

Overall, these changes are well-implemented and should significantly improve the onboarding experience.

packages/web/hooks/use-feature-flags.ts (1)

Line range hint 1-134: Overall, the changes look good and align with the PR objectives.

The modifications to the useFeatureFlags hook successfully improve the onboarding process for new developers and add more granular control over feature availability. The changes to default flag values and the introduction of development mode checks enhance the initial setup experience.

Key improvements:

  1. Updated default feature flags to reflect the current production UI.
  2. Implemented checks for development mode without a client ID.
  3. Added geoblocking functionality for limit orders.

These changes will facilitate easier onboarding and contribute to a more streamlined development process.

README.md (2)

Line range hint 5-7: Excellent addition of context for the ongoing refactor.

The new note effectively communicates the current state of the codebase and sets appropriate expectations for contributors. This aligns well with the PR objective of improving the onboarding process.


Line range hint 1-100: Overall excellent improvements to documentation and onboarding process.

The changes made to the README.md file significantly enhance the onboarding process for new contributors and provide clearer instructions for various development scenarios. The additions and updates align well with the PR objectives, addressing the following key points:

  1. Improved clarity on the current state of the codebase and ongoing refactor.
  2. Enhanced setup instructions, including the crucial build step.
  3. Comprehensive guidance for testnet development, both public and local.
  4. Important information about the suspension of releases during the refactor.

These changes will greatly benefit new contributors and existing developers working on the Osmosis Frontend project.

Copy link
Collaborator

@MaxMillington MaxMillington left a comment

Choose a reason for hiding this comment

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

Any special env variables needed?

@MaxMillington MaxMillington merged commit 0387e17 into stage Oct 7, 2024
33 checks passed
@MaxMillington MaxMillington deleted the jose/fe-1146-improve-osmosis-fe-onboarding branch October 7, 2024 16:09
@coderabbitai coderabbitai bot mentioned this pull request Nov 4, 2024
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