Skip to content

fix(desktop): move desktop_opened event to app startup#878

Merged
saddlepaddle merged 1 commit into
mainfrom
move-posthog-ff
Jan 21, 2026
Merged

fix(desktop): move desktop_opened event to app startup#878
saddlepaddle merged 1 commit into
mainfrom
move-posthog-ff

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented Jan 21, 2026

Summary

  • Moved desktop_opened PostHog event from sign-in page to PostHogProvider initialization
  • Previously, logged-in users who skip sign-in never triggered this event
  • Now fires for all app launches regardless of auth state

Test plan

  • Open app while logged out → verify desktop_opened fires
  • Open app while logged in → verify desktop_opened fires (previously didn't)
  • Check PostHog dashboard for events

Summary by CodeRabbit

  • Refactor
    • Adjusted analytics event timing to be captured earlier during application initialization, replacing the previous collection point.

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

Previously, the desktop_opened event only fired when the sign-in page
loaded. This meant logged-in users who skip sign-in never triggered
the event.

Moved the event to PostHogProvider initialization so it fires for
all app launches regardless of auth state.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 21, 2026

📝 Walkthrough

Walkthrough

This PR relocates the "desktop_opened" PostHog analytics event capture from the sign-in page component to the PostHogProvider initialization. The event is now emitted when PostHog is initialized rather than when the user reaches the sign-in page.

Changes

Cohort / File(s) Summary
Analytics event relocation
apps/desktop/src/renderer/providers/PostHogProvider/PostHogProvider.tsx
Added posthog.capture("desktop_opened") call in useEffect after initPostHog() to emit event at provider initialization
Event tracking cleanup
apps/desktop/src/renderer/routes/sign-in/page.tsx
Removed useEffect hook that previously captured "desktop_opened" event on component mount

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~4 minutes

Possibly related PRs

Poem

🐰 A desktop awakens with a whispered chime,
PostHog tracks the opening, marking time,
From sign-in's corner to the provider's heart,
Events now flow from the very start!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: moving the desktop_opened event from the sign-in page to app startup (PostHogProvider initialization).
Description check ✅ Passed The description includes a summary of changes and test plan, but omits several template sections like Related Issues, Type of Change, Testing details, and Additional Notes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

@saddlepaddle saddlepaddle merged commit ca7c231 into main Jan 21, 2026
4 of 5 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch
  • ⚠️ Electric Fly.io app

Thank you for your contribution! 🎉

Copy link
Copy Markdown
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

🤖 Fix all issues with AI agents
In `@apps/desktop/src/renderer/providers/PostHogProvider/PostHogProvider.tsx`:
- Around line 13-16: Extract the hardcoded "desktop_opened" string to a
module-level constant (e.g., DESKTOP_OPENED_EVENT) and then wrap the
posthog.capture call in a try-catch so any exception is logged (use existing
logger) and does not prevent state progression; call setIsInitialized(true)
regardless (either in a finally block or after the try/catch) so isInitialized
isn't left false if capture throws—apply these changes around initPostHog(),
posthog.capture(...) and setIsInitialized(...) in PostHogProvider.
🧹 Nitpick comments (1)
apps/desktop/src/renderer/providers/PostHogProvider/PostHogProvider.tsx (1)

15-15: Extract event name to a module constant.

Hardcoded event names should be named constants at the module top for reuse and consistency.

♻️ Suggested change
+const POSTHOG_EVENT_DESKTOP_OPENED = "desktop_opened";
+
 export function PostHogProvider({ children }: PostHogProviderProps) {
   const [isInitialized, setIsInitialized] = useState(false);

   useEffect(() => {
     initPostHog();
-    posthog.capture("desktop_opened");
+    posthog.capture(POSTHOG_EVENT_DESKTOP_OPENED);
     setIsInitialized(true);
   }, []);

Comment on lines 13 to 16
useEffect(() => {
initPostHog();
posthog.capture("desktop_opened");
setIsInitialized(true);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Find PostHog-related files
fd -i 'posthog' apps/desktop/src/renderer --type f

Repository: superset-sh/superset

Length of output: 261


🏁 Script executed:

# Read the PostHogProvider file
cat -n apps/desktop/src/renderer/providers/PostHogProvider/PostHogProvider.tsx

Repository: superset-sh/superset

Length of output: 908


🏁 Script executed:

# Search for initPostHog implementation
rg -n 'initPostHog' apps/desktop/src/renderer -B 2 -A 10

Repository: superset-sh/superset

Length of output: 3323


🏁 Script executed:

cat -n apps/desktop/src/renderer/lib/posthog.ts

Repository: superset-sh/superset

Length of output: 1107


Add error handling and extract hardcoded event name to a constant.

initPostHog() is synchronous, so timing isn't the issue. However, posthog.capture() is not wrapped in error handling—if it throws, setIsInitialized is never called, leaving isInitialized false and blanking the UI indefinitely. Add a try-catch block with logging. Also extract the hardcoded event name "desktop_opened" to a named constant at the module top per guidelines.

🤖 Prompt for AI Agents
In `@apps/desktop/src/renderer/providers/PostHogProvider/PostHogProvider.tsx`
around lines 13 - 16, Extract the hardcoded "desktop_opened" string to a
module-level constant (e.g., DESKTOP_OPENED_EVENT) and then wrap the
posthog.capture call in a try-catch so any exception is logged (use existing
logger) and does not prevent state progression; call setIsInitialized(true)
regardless (either in a finally block or after the try/catch) so isInitialized
isn't left false if capture throws—apply these changes around initPostHog(),
posthog.capture(...) and setIsInitialized(...) in PostHogProvider.

@Kitenite Kitenite deleted the move-posthog-ff branch January 22, 2026 17:48
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.

1 participant