[FEAT] : PostHog Integration for user analytics#118
Conversation
|
@AshutoshDash1999 is attempting to deploy a commit to the niharika-mente's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Review limit reached
More reviews will be available in 2 minutes and 16 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses rolling per-developer review limits. Reviews become available again as older review attempts age out of the rolling limit window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughPostHog initialization is moved from ChangesPostHog Analytics Instrumentation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
290af12 to
b9677e0
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
lib/posthog/helpers.ts (1)
10-15: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winType
captureEventto the shared event union.Line 11 accepts any
string, which bypasses your typed event map and allows silent event-name typos. Use thePOSTHOG_EVENTSvalue union for compile-time safety.Suggested refactor
import posthog from "posthog-js"; +import { POSTHOG_EVENTS } from "./events"; + +type PostHogEventName = + (typeof POSTHOG_EVENTS)[keyof typeof POSTHOG_EVENTS]; @@ export function captureEvent( - event: string, + event: PostHogEventName, properties?: Record<string, unknown> ) { posthog.capture(event, properties); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lib/posthog/helpers.ts` around lines 10 - 15, The captureEvent function currently accepts any string for the event parameter, which allows silent typos and bypasses type safety. Replace the event parameter type from a generic string to use the POSTHOG_EVENTS value union instead. This will enforce compile-time safety by ensuring only valid event names from your typed event map can be passed to the captureEvent function.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@components/BookEvent.tsx`:
- Around line 31-34: The captureEvent call for POSTHOG_EVENTS.BOOKING_FAILED is
sending raw email as part of the payload, which violates the PII protection rule
established earlier in the code (line 30). Remove the email parameter from the
captureEvent function call on line 34 where BOOKING_FAILED is captured, keeping
only the eventId and slug parameters which are safe to log.
In `@components/SearchFilters.tsx`:
- Around line 32-34: The captureEvent call with POSTHOG_EVENTS.EVENT_SEARCHED is
sending the raw search query string which may contain PII. Instead of passing
the raw search query directly to the analytics event, create a redacted or
derived version of the search data before sending it. This could involve
sanitizing the query string, hashing it, or sending only safe metadata about the
search (such as search length or category) instead of the full text. Update the
properties object passed to captureEvent to exclude or transform the raw query
parameter.
In `@instrumentation-client.ts`:
- Around line 3-5: In the posthog.init() call, replace the environment variable
NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN with NEXT_PUBLIC_POSTHOG_KEY to match the
documented configuration contract. Additionally, add a guard condition to check
that both NEXT_PUBLIC_POSTHOG_KEY and NEXT_PUBLIC_POSTHOG_HOST are defined
before calling posthog.init(), ensuring that the initialization only proceeds
when both required environment variables are present to prevent undefined values
from being passed to the init method.
---
Nitpick comments:
In `@lib/posthog/helpers.ts`:
- Around line 10-15: The captureEvent function currently accepts any string for
the event parameter, which allows silent typos and bypasses type safety. Replace
the event parameter type from a generic string to use the POSTHOG_EVENTS value
union instead. This will enforce compile-time safety by ensuring only valid
event names from your typed event map can be passed to the captureEvent
function.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e1ea13f0-e6c4-4720-b6c0-15233a28cb8f
📒 Files selected for processing (10)
app/error.tsxapp/providers.tsxcomponents/BookEvent.tsxcomponents/CreateNewEvent.tsxcomponents/EventCard.tsxcomponents/SearchFilters.tsxinstrumentation-client.tslib/posthog.jslib/posthog/events.tslib/posthog/helpers.ts
💤 Files with no reviewable changes (1)
- lib/posthog.js
Description
Next Step
NEXT_PUBLIC_POSTHOG_KEYandNEXT_PUBLIC_POSTHOG_HOSTFixes #116
Type of Change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.
Checklist:
Summary by CodeRabbit