1- import React , { useState } from "react" ;
1+ import React , { useState , useEffect } from "react" ;
22import { Excalidraw , MainMenu , Footer } from "@atyrode/excalidraw" ;
33import type { ExcalidrawImperativeAPI , AppState } from "@atyrode/excalidraw/types" ;
44import type { ExcalidrawEmbeddableElement , NonDeleted } from "@atyrode/excalidraw/element/types" ;
@@ -7,6 +7,7 @@ import type { ExcalidrawEmbeddableElement, NonDeleted } from "@atyrode/excalidra
77import { useAuthStatus } from "./hooks/useAuthStatus" ;
88import { usePadTabs } from "./hooks/usePadTabs" ;
99import { useCallbackRefState } from "./hooks/useCallbackRefState" ;
10+ import { useAppConfig } from "./hooks/useAppConfig" ;
1011
1112// Components
1213import DiscordButton from './ui/DiscordButton' ;
@@ -22,6 +23,7 @@ import Tabs from "./ui/Tabs";
2223import { INITIAL_APP_DATA , HIDDEN_UI_ELEMENTS } from "./constants" ;
2324
2425export default function App ( ) {
26+ const { config, configError } = useAppConfig ( ) ;
2527 const { isAuthenticated, isLoading : isLoadingAuth , user } = useAuthStatus ( ) ;
2628
2729 const {
@@ -49,16 +51,16 @@ export default function App() {
4951 lockEmbeddables ( excalidrawAPI ?. getAppState ( ) ) ;
5052 } ;
5153
52- // useEffect(() => {
53- // if (appConfig ?.posthogKey && appConfig ?.posthogHost) {
54- // initializePostHog({
55- // posthogKey: appConfig .posthogKey,
56- // posthogHost: appConfig .posthogHost,
57- // });
58- // } else if (configError) {
59- // console.error('[pad.ws] Failed to load app config:', configError);
60- // }
61- // }, [appConfig , configError]);
54+ useEffect ( ( ) => {
55+ if ( config ?. posthogKey && config ?. posthogHost ) {
56+ initializePostHog ( {
57+ posthogKey : config . posthogKey ,
58+ posthogHost : config . posthogHost ,
59+ } ) ;
60+ } else if ( configError ) {
61+ console . error ( '[pad.ws] Failed to load app config:' , configError ) ;
62+ }
63+ } , [ config , configError ] ) ;
6264
6365 return (
6466 < >
0 commit comments