Skip to content

Comments

post hog #16

Merged
fortune710 merged 7 commits intofortune710:mainfrom
MaestroDev19:main
Jan 5, 2026
Merged

post hog #16
fortune710 merged 7 commits intofortune710:mainfrom
MaestroDev19:main

Conversation

@MaestroDev19
Copy link
Collaborator

@MaestroDev19 MaestroDev19 commented Jan 4, 2026

Summary by CodeRabbit

  • New Features

    • Added localization support for multi-language UI.
    • Integrated analytics to capture entry saves, friend-block actions, and invite acceptances for product insights.
  • Chores

    • Updated platform libraries and added packages to support localization and analytics.

✏️ Tip: You can customize this high-level summary in your review settings.

Default to empty string when userId is undefined to satisfy JsonType requirements for PostHog capture properties.
- Initialize PostHog client in [constants/posthog.ts](cci:7://file:///c:/Users/charl/keepsafe/frontend/constants/posthog.ts:0:0-0:0)
- Track `invite_accepted` event in `use-invite-acceptance` hook
- Track `friend_blocked` event in `use-friends` hook
- Track `entry_captured` event with metadata in `capture/details` screen
@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@vercel
Copy link

vercel bot commented Jan 4, 2026

@MaestroDev19 is attempting to deploy a commit to the fortune710's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 4, 2026

Warning

Rate limit exceeded

@MaestroDev19 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 18 minutes and 3 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between e2ab184 and 7b49357.

📒 Files selected for processing (2)
  • frontend/constants/posthog.ts
  • frontend/tsconfig.json

Walkthrough

Adds PostHog analytics with a safe no-op client; instruments entry saves, friend blocks, and invite acceptances; adds expo-localization and related dependency updates and plugins.

Changes

Cohort / File(s) Summary
PostHog client
frontend/constants/posthog.ts
New exported posthog constant: initializes a real PostHog client when EXPO_PUBLIC_POSTHOG_API_KEY and EXPO_PUBLIC_POSTHOG_HOST exist; otherwise provides a full no-op mock and logs a development-time warning.
Analytics instrumentation
frontend/app/capture/details.tsx, frontend/hooks/use-friends.ts, frontend/hooks/use-invite-acceptance.ts
Import posthog and call posthog.capture(...) after successful operations: entry save (entry_saved with type, is_private, is_everyone, friends_count), friend block (friend_blocked, omits friendship_id; includes preliminary status change), and invite acceptance (invite_accepted with inviter/invitee ids). Capture calls wrapped in try/catch with dev-only warnings.
Dependencies & app config
frontend/package.json, frontend/app.json
Added dependencies: posthog-react-native, expo-localization, expo-application; bumped expo-device and expo-file-system versions. Added expo-localization to expo.plugins in app.json.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant App as Mobile App
  participant API as Backend API
  participant PH as PostHog
  rect rgb(235,245,255)
    Note over User,App: User triggers action (save / accept / block)
    User->>App: action
  end
  rect rgb(245,255,235)
    App->>API: perform mutation (save/accept/block)
    API-->>App: mutation result (success / failure)
  end
  alt success
    rect rgb(255,250,235)
      App->>PH: posthog.capture(eventName, payload)
      PH-->>App: ack
    end
  else failure
    App-->>App: handle error (no analytics)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through lines with nimble paws,

Tucked tiny captures into quiet logs,
A locale pin, an event sent light,
Friends and invites now traced at night,
🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'post hog' is vague and generic, lacking specificity about what PostHog integration was added or how it was implemented across the codebase. Consider using a more descriptive title such as 'Add PostHog analytics integration' to clearly convey the main change and implementation scope.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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: 4

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0951575 and b7768e8.

⛔ Files ignored due to path filters (1)
  • frontend/bun.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • frontend/app.json
  • frontend/app/capture/details.tsx
  • frontend/constants/posthog.ts
  • frontend/hooks/use-friends.ts
  • frontend/hooks/use-invite-acceptance.ts
  • frontend/package.json
🧰 Additional context used
🧬 Code graph analysis (3)
frontend/hooks/use-friends.ts (1)
frontend/constants/posthog.ts (1)
  • posthog (3-5)
frontend/app/capture/details.tsx (1)
frontend/constants/posthog.ts (1)
  • posthog (3-5)
frontend/hooks/use-invite-acceptance.ts (1)
frontend/constants/posthog.ts (1)
  • posthog (3-5)
🔇 Additional comments (3)
frontend/app.json (1)

125-126: LGTM!

The expo-localization plugin addition is correctly configured and aligns with the dependency added in package.json.

frontend/package.json (1)

72-72: This dependency is compatible with the project.

The posthog-react-native package is a React Native SDK, not a React web library, and does not impose React (web) version requirements. It works within React Native/Expo environments regardless of the React version. Version 4.17.0 is current and shows no security vulnerabilities.

Likely an incorrect or invalid review comment.

frontend/hooks/use-invite-acceptance.ts (1)

5-5: LGTM!

The centralized PostHog client import follows good practice for maintaining a single configured instance across the application.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend/hooks/use-friends.ts (1)

160-171: Critical: Remove duplicate mutation call.

The function makes two separate database updates to the same friendship record:

  1. Line 160 sets status: BLOCKED (without blocked_by)
  2. Lines 167-171 set status: BLOCKED again with blocked_by: userId

This is inefficient and creates a race condition where the friendship temporarily exists in a BLOCKED state without the blocked_by field set.

🔎 Proposed fix: Single mutation with both fields
     try {
-      await updateFriendshipMutation.mutateAsync({ id: friendshipId, status: FRIENDSHIP_STATUS.BLOCKED });
-      try {
-        // Omitting friendship_id for privacy compliance
-        posthog.capture('friend_blocked', {});
-      } catch (error) {
-        if (__DEV__) console.warn('Analytics capture failed:', error);
-      }
       await updateFriendshipMutation.mutateAsync({ 
         id: friendshipId, 
         status: FRIENDSHIP_STATUS.BLOCKED,
         blocked_by: userId
       });
+      try {
+        // Omitting friendship_id for privacy compliance
+        posthog.capture('friend_blocked', {});
+      } catch (error) {
+        if (__DEV__) console.warn('Analytics capture failed:', error);
+      }
       return { success: true };
     } catch (error) {

This performs a single atomic update with both status and blocked_by, then captures analytics without disrupting the flow on failure.

🧹 Nitpick comments (1)
frontend/constants/posthog.ts (1)

12-26: LGTM! Consider enhancing mock method signatures for better type safety.

The implementation successfully addresses the previous concerns about environment variable validation and graceful degradation. The no-op fallback ensures the app won't crash when analytics aren't configured.

🔎 Optional refinement: Match PostHog method signatures in the mock

The current no-op methods use empty arrow functions () => {}, but PostHog methods accept parameters. Matching the signatures more precisely would improve type safety and prevent potential issues if calling code relies on parameter validation:

 export const posthog = apiKey && host 
   ? new PostHog(apiKey, { host })
   : {
       // Provide a no-op mock for when PostHog is not configured
-      capture: () => {},
-      identify: () => {},
-      reset: () => {},
-      screen: () => {},
-      group: () => {},
-      alias: () => {},
-      reloadFeatureFlags: () => {},
+      capture: (_event: string, _properties?: object) => {},
+      identify: (_distinctId: string, _properties?: object) => {},
+      reset: () => {},
+      screen: (_screenName: string, _properties?: object) => {},
+      group: (_groupType: string, _groupKey: string, _properties?: object) => {},
+      alias: (_alias: string) => {},
+      reloadFeatureFlags: () => {},
       isFeatureEnabled: () => false,
       getFeatureFlag: () => null,
       getFeatureFlagPayload: () => null,
     } as unknown as PostHog;

This change ensures the mock accepts the same parameters as the real PostHog client, improving code robustness.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dba94ad and 814b428.

📒 Files selected for processing (3)
  • frontend/constants/posthog.ts
  • frontend/hooks/use-friends.ts
  • frontend/hooks/use-invite-acceptance.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/hooks/use-invite-acceptance.ts
🧰 Additional context used
🧬 Code graph analysis (1)
frontend/hooks/use-friends.ts (2)
frontend/constants/supabase.ts (1)
  • FRIENDSHIP_STATUS (31-36)
frontend/constants/posthog.ts (1)
  • posthog (12-26)

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: 1

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 814b428 and e2ab184.

📒 Files selected for processing (2)
  • frontend/constants/posthog.ts
  • frontend/hooks/use-friends.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/hooks/use-friends.ts
🔇 Additional comments (1)
frontend/constants/posthog.ts (1)

1-10: LGTM! Environment variable validation prevents crashes.

The removal of non-null assertions and addition of validation logic effectively addresses the previous critical issue. The dev-mode warning provides helpful feedback when analytics is not configured.

@fortune710 fortune710 merged commit a1b1f66 into fortune710:main Jan 5, 2026
1 of 2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jan 9, 2026
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