Skip to content

Commit 4c337eb

Browse files
committed
Smaller fixes
Signed-off-by: Heiko W. Rupp <[email protected]>
1 parent 2011420 commit 4c337eb

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/app/playground/chat/page.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ const ChatPage: React.FC = () => {
3636
variant="link"
3737
isInline
3838
onClick={(e) => {
39-
window.analytics.trackSingleItem('Chat Cleared', {});
4039
e.preventDefault();
4140
router.push('/playground/endpoints');
4241
}}

src/components/AppLayout.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type Route = {
4848
const AppLayout: React.FunctionComponent<IAppLayout> = ({ children, className }) => {
4949
const { data: session, status } = useSession();
5050
const [isExperimentalEnabled, setExperimental] = useState(false);
51+
const [analyticsInitialised, setAnalyticsInitialised] = useState(false);
5152

5253
const router = useRouter();
5354
const pathname = usePathname();
@@ -63,9 +64,9 @@ const AppLayout: React.FunctionComponent<IAppLayout> = ({ children, className })
6364
}, []);
6465

6566
React.useEffect(() => {
66-
console.log("Get analytics effect " + window.analytics);
6767
if (!window.analytics) {
6868
initAnalytics();
69+
setAnalyticsInitialised(true);
6970
}
7071
}, []);
7172

@@ -74,15 +75,16 @@ const AppLayout: React.FunctionComponent<IAppLayout> = ({ children, className })
7475
window.analytics.trackPageView(pathname);
7576
}
7677

77-
}, [pathname]);
78+
}, [pathname, analyticsInitialised]);
7879

7980
React.useEffect(() => {
80-
console.log(("Identify effect " + session?.user) )
8181
if (window.analytics) {
8282
// TODO we may potentially want to hash this. Also different code per target install?
83-
window.analytics.identify(session?.user?.name ? session.user.name : '-unknown-user-name ');
83+
// TODO pass other parameters as properties
84+
window.analytics.identify(session?.user?.name ? session.user.name : '-unknown-user-name ', {}
85+
);
8486
}
85-
},[session?.user?.name,session?.user]);
87+
},[analyticsInitialised, session?.user?.name,session?.user]);
8688

8789
React.useEffect(() => {
8890
if (status === 'loading') return; // Do nothing while loading

src/components/Chat/ChatBotComponent.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ const ChatBotComponent: React.FunctionComponent<ChatbotComponentProps> = ({
210210

211211
const handleCleanup = () => {
212212
setMessages([]);
213+
window.analytics.trackSingleItem('Chat Cleared', {});
213214
};
214215

215216
return (

0 commit comments

Comments
 (0)