Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export function PostHogProvider({ children }: PostHogProviderProps) {

useEffect(() => {
initPostHog();
posthog.capture("desktop_opened");
setIsInitialized(true);
Comment on lines 13 to 16
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.

}, []);

Expand Down
5 changes: 0 additions & 5 deletions apps/desktop/src/renderer/routes/sign-in/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { type AuthProvider, COMPANY } from "@superset/shared/constants";
import { Button } from "@superset/ui/button";
import { Spinner } from "@superset/ui/spinner";
import { createFileRoute, Navigate } from "@tanstack/react-router";
import { useEffect } from "react";
import { FaGithub } from "react-icons/fa";
import { FcGoogle } from "react-icons/fc";
import { authClient } from "renderer/lib/auth-client";
Expand All @@ -18,10 +17,6 @@ function SignInPage() {
const { data: session, isPending } = authClient.useSession();
const signInMutation = electronTrpc.auth.signIn.useMutation();

useEffect(() => {
posthog.capture("desktop_opened");
}, []);

// Show loading while session is being fetched
if (isPending) {
return (
Expand Down
Loading