-
Notifications
You must be signed in to change notification settings - Fork 265
feat(docs): Adding growthbook for feature flag support #1307
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
Conversation
✅ Deploy Preview for docs-optimism ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Warning Rate limit exceeded@jvmi7 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 13 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis pull request introduces several changes, including the addition of a new Possibly related PRs
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
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: 3
🧹 Nitpick comments (1)
components/AskAIButton.tsx (1)
11-15
: Move inline styles to a CSS module.Inline styles make the component harder to maintain and override. Consider moving them to a CSS module.
Create a new file
AskAIButton.module.css
:.button { background-color: #FF0420; color: white; display: flex; align-items: center; gap: 4px; }Then update the component:
+import styles from './AskAIButton.module.css'; return ( - <button id='custom-ask-ai-button' className='nx-flex nx-gap-2 nx-items-center nx-py-1.5 nx-px-3 nx-rounded-lg nx-text-sm nx-font-semibold' style={{ backgroundColor: '#FF0420', color: 'white', display: 'flex', alignItems: 'center', gap: '4px' }}> + <button id='custom-ask-ai-button' className={`nx-flex nx-gap-2 nx-items-center nx-py-1.5 nx-px-3 nx-rounded-lg nx-text-sm nx-font-semibold ${styles.button}`}> <span>Ask AI</span> <RiSparkling2Fill size={14} /> </button>
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (6)
components/AskAIButton.tsx
(1 hunks)lib/growthbook.ts
(1 hunks)package.json
(1 hunks)pages/_app.tsx
(1 hunks)providers/GrowthbookProvider.tsx
(1 hunks)theme.config.tsx
(4 hunks)
✅ Files skipped from review due to trivial changes (1)
- providers/GrowthbookProvider.tsx
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Redirect rules - docs-optimism
- GitHub Check: Header rules - docs-optimism
- GitHub Check: Pages changed - docs-optimism
- GitHub Check: pr-workflow
🔇 Additional comments (4)
pages/_app.tsx (1)
32-45
: LGTM!The GrowthBook provider is correctly integrated into the app's component hierarchy.
theme.config.tsx (1)
35-35
: LGTM!The AskAIButton is correctly integrated into the navbar.
package.json (2)
25-25
: LGTM! Dependency correctly added.The GrowthBook React library is:
- Properly placed in the dependencies section
- Follows the existing version format using caret
- Maintains alphabetical ordering
25-25
: Verify GrowthBook package version and security.The dependency addition looks good, but let's verify the version and security status.
✅ Verification successful
✅ GrowthBook package version and compatibility verified
The package is using the latest version (1.3.1) and is fully compatible with the project's React version through its peer dependencies support.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check latest version and security advisories for @growthbook/growthbook-react # Check NPM for latest version echo "Latest version from NPM:" npm view @growthbook/growthbook-react version # Check for security advisories echo -e "\nSecurity advisories from NPM:" npm audit @growthbook/growthbook-react # Check React compatibility echo -e "\nPeer dependencies:" npm view @growthbook/growthbook-react peerDependenciesLength of output: 736
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: 0
🧹 Nitpick comments (3)
lib/growthbook.ts (3)
4-6
: Consider using TypeScript for environment variables.While the validation is good, consider using TypeScript to ensure type safety for environment variables.
declare global { namespace NodeJS { interface ProcessEnv { NEXT_PUBLIC_GROWTHBOOK_API_HOST: string; NEXT_PUBLIC_GROWTHBOOK_CLIENT_KEY: string; } } }
8-11
: Consider additional GrowthBook configuration options.The basic configuration is good, but consider adding optional configurations like
enableDevMode
for development environments andtrackingCallback
for analytics integration.export const growthbook = new GrowthBook({ apiHost: process.env.NEXT_PUBLIC_GROWTHBOOK_API_HOST, - clientKey: process.env.NEXT_PUBLIC_GROWTHBOOK_CLIENT_KEY + clientKey: process.env.NEXT_PUBLIC_GROWTHBOOK_CLIENT_KEY, + enableDevMode: process.env.NODE_ENV === 'development', + trackingCallback: (experiment, result) => { + // Add analytics tracking here + console.log('Experiment viewed:', experiment.key, result); + } });
13-17
: Enhance error handling with retry logic.Consider adding retry logic for initialization failures, as they might be due to temporary network issues.
+const MAX_RETRIES = 3; +const RETRY_DELAY = 1000; + +async function initializeWithRetry(retries = 0) { try { growthbook.init(); } catch (error) { - console.error('Error initializing GrowthBook', error); + console.error(`Error initializing GrowthBook (attempt ${retries + 1}/${MAX_RETRIES}):`, error); + if (retries < MAX_RETRIES - 1) { + setTimeout(() => initializeWithRetry(retries + 1), RETRY_DELAY); + } } +} + +initializeWithRetry();
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
lib/growthbook.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: pr-workflow
Adding growthbook for feature flag support