Feat/posthog analytics#2
Open
aman-wednesdaysol wants to merge 3 commits into
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PostHog Analytics Integration
Description
This PR introduces backend analytics tracking using PostHog across authentication and music library flows.
A centralized analytics layer was added to provide consistent, non-blocking event tracking while keeping business logic isolated from analytics concerns. Tracking is implemented using fire-and-forget helpers to avoid impacting request latency.
Key Features
Implementation Details
New Files
lib/analytics/client.jsshutdownAnalytics()for graceful process terminationlib/analytics/events.jslib/analytics/tracker.jsModified Files
Infrastructure
webpack/server.config.js— Added@analyticsaliasjest.config.json— Added analytics module mappingjest.setup.js— Mocked analytics during tests.env.local— Added:POSTHOG_API_KEYPOSTHOG_HOSTServer Lifecycle
server.js— AddedSIGINThandler invokingshutdownAnalytics()to flush queued events before shutdownTracked Routes
lib/routes/login/routes.js→trackLoginlib/routes/signup/routes.js→trackSignuplib/routes/logout/routes.js→trackLogoutlib/routes/music/resources/routes.js→trackSongSearchedlib/routes/music/library/routes.jstrackLibraryViewedtrackSongLikedtrackSongUnlikedTests
lib/routes/signup/tests/routes.test.jsuserpropertyResults
Steps to Reproduce / Test
Perform the following actions:
Verify events appear in PostHog dashboard.
Run tests:
yarn testChecklist
yarn testpasses