-
Notifications
You must be signed in to change notification settings - Fork 8
[LC-1534]: Modular Product Analytics #948
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
base: main
Are you sure you want to change the base?
Conversation
|
✅ Deploy Preview for learncarddocs canceled.
|
✅ Deploy Preview for staging-learncardapp ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
👋 Hey there! It looks like you modified code, but didn't update the documentation in If this PR introduces new features, changes APIs, or modifies behavior that users or developers need to know about, please consider updating the docs. 🏄 Windsurf TipYou can ask Windsurf to help:
Windsurf will review your changes and suggest appropriate documentation updates based on what was modified. 📚 Documentation Guide
This is an automated reminder. If no docs are needed, feel free to ignore this message. |
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.
✨ PR Review
The PR introduces a well-structured analytics abstraction layer with provider-agnostic tracking. However, there are critical issues with event loss during initialization, type safety violations in the Firebase provider, and performance problems from unstable dependencies causing infinite effect re-runs.
3 issues detected:
🚀 Performance - Non-memoized function dependencies cause infinite effect re-execution 🛠️
Details: The useEffect has dependencies on
getDIDandidentifyfunctions. ThegetDIDfunction from useWallet() is not memoized and creates a new reference on every render, causing this effect to re-run constantly. This leads to redundant identify() calls and unnecessary performance overhead.
File:apps/learn-card-app/src/analytics/useSetAnalyticsUserId.ts (44-44)
🛠️ A suggested code correction is included in the review comments.🐞 Bug - Unsafe type cast forces null through string-typed API that may not accept it 🛠️
Details: The reset() function uses a dangerous type cast
null as unknown as stringto bypass TypeScript's type checking when calling setUserId. This could cause runtime failures if Firebase Analytics doesn't properly handle null values, and indicates the API is being used incorrectly.
File:apps/learn-card-app/src/analytics/providers/firebase.ts (54-54)
🛠️ A suggested code correction is included in the review comments.🐞 Bug - Analytics events fired before async provider initialization are lost in production
Details: The provider initializes as NoopProvider and asynchronously loads the real provider. Between mount and provider initialization completing, any analytics calls (track, identify, etc.) are sent to NoopProvider which only logs in dev mode, causing production events to be lost. Critical startup events like user identification or first page views may never be tracked.
File:apps/learn-card-app/src/analytics/context.tsx
Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Review using Guidelines Learn how
| if (currentUser) { | ||
| setUserId(); | ||
| } | ||
| }, [currentUser, currentLCNUser, getDID, identify, options.debug]); |
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.
🚀 Performance - Infinite Effect Loop: Remove getDID and identify from the dependency array, or ensure useWallet() memoizes the getDID function with useCallback. The effect should primarily depend on currentUser changes, and the functions can be safely used without being dependencies since they're stable across the hook's lifecycle.
| }, [currentUser, currentLCNUser, getDID, identify, options.debug]); | |
| }, [currentUser, currentLCNUser, options.debug]); |
Is this review accurate? Use 👍 or 👎 to rate it
If you want to tell us more, use /gs feedback e.g. /gs feedback this review doesn't make sense, I disagree, and it keeps repeating over and over
|
|
||
| async reset(): Promise<void> { | ||
| try { | ||
| await FirebaseAnalytics.setUserId({ userId: null as unknown as string }); |
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.
🐞 Bug - Type Safety Violation: Use an empty string '' instead of null, or check the Firebase Analytics documentation for the proper way to clear/reset the user ID. If null is genuinely required, add error handling and documentation explaining why this unsafe cast is necessary.
| await FirebaseAnalytics.setUserId({ userId: null as unknown as string }); | |
| await FirebaseAnalytics.setUserId({ userId: '' }); |
Is this review accurate? Use 👍 or 👎 to rate it
If you want to tell us more, use /gs feedback e.g. /gs feedback this review doesn't make sense, I disagree, and it keeps repeating over and over
Overview
🎟 Relevant Jira Issues
📚 What is the context and goal of this PR?
🥴 TL; RL:
💡 Feature Breakdown (screenshots & videos encouraged!)
🛠 Important tradeoffs made:
🔍 Types of Changes
💳 Does This Create Any New Technical Debt? ( If yes, please describe and add JIRA TODOs )
Testing
🔬 How Can Someone QA This?
📱 🖥 Which devices would you like help testing on?
🧪 Code Coverage
Documentation
📝 Documentation Checklist
User-Facing Docs (
docs/→ docs.learncard.com)docs/tutorials/)docs/how-to-guides/)docs/sdks/)docs/core-concepts/)docs/apps/)Internal/AI Docs
Visual Documentation
💭 Documentation Notes
✅ PR Checklist
🚀 Ready to squash-and-merge?:
✨ PR Description
Purpose: Add provider-agnostic analytics abstraction layer to support multiple analytics backends (PostHog, Firebase) for tracking user interactions and product events across the Learn Card application.
Main changes:
Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Description using Guidelines Learn how