mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
fix(frontend): launch darkly initialisation (#10408)
## Changes 🏗️ Only initialise Launch Darkly if we have a user and the config is set. ### Checklist 📋 ### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: - [x] Once merged login into app and see if Launch Darkly initialises ### For configuration changes: No
This commit is contained in:
@@ -3,32 +3,16 @@ import { ReactNode } from "react";
|
||||
import { useSupabase } from "@/lib/supabase/hooks/useSupabase";
|
||||
import { BehaveAs, getBehaveAs } from "@/lib/utils";
|
||||
|
||||
const clientId = process.env.NEXT_PUBLIC_LAUNCHDARKLY_CLIENT_ID;
|
||||
const envEnabled = process.env.NEXT_PUBLIC_LAUNCHDARKLY_ENABLED === "true";
|
||||
|
||||
export function LaunchDarklyProvider({ children }: { children: ReactNode }) {
|
||||
const clientId = process.env.NEXT_PUBLIC_LAUNCHDARKLY_CLIENT_ID;
|
||||
|
||||
const { user } = useSupabase();
|
||||
const isCloud = getBehaveAs() === BehaveAs.CLOUD;
|
||||
|
||||
const enabled =
|
||||
isCloud && process.env.NEXT_PUBLIC_LAUNCHDARKLY_ENABLED === "true";
|
||||
|
||||
const { user, isUserLoading } = useSupabase();
|
||||
const enabled = isCloud && envEnabled && clientId && user;
|
||||
|
||||
if (!enabled) return <>{children}</>;
|
||||
|
||||
if (!clientId) {
|
||||
throw new Error("NEXT_PUBLIC_LAUNCHDARKLY_CLIENT_ID is not defined");
|
||||
}
|
||||
|
||||
// Show loading state while user is being determined
|
||||
if (isUserLoading) {
|
||||
return (
|
||||
<div className="flex min-h-screen items-center justify-center">
|
||||
<div className="h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Create user context for LaunchDarkly
|
||||
const userContext = user
|
||||
? {
|
||||
kind: "user",
|
||||
|
||||
Reference in New Issue
Block a user