Skip to content

Commit ae19f80

Browse files
more fixes
1 parent dca105c commit ae19f80

File tree

7 files changed

+30
-20
lines changed

7 files changed

+30
-20
lines changed

apps/dashboard/src/app/(app)/team/[team_slug]/(team)/layout.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { AppFooter } from "@/components/blocks/app-footer";
44
import { TabPathLinks } from "@/components/ui/tabs";
55
import { AnnouncementBanner } from "components/notices/AnnouncementBanner";
66
import { redirect } from "next/navigation";
7+
import { siwaExamplePrompts } from "../../../(dashboard)/support/page";
78
import { getClientThirdwebClient } from "../../../../../@/constants/thirdweb-client.client";
89
import { CustomChatButton } from "../../../../nebula-app/(app)/components/CustomChat/CustomChatButton";
9-
import { examplePrompts } from "../../../../nebula-app/(app)/data/examplePrompts";
1010
import { getValidAccount } from "../../../account/settings/getAccount";
1111
import {
1212
getAuthToken,
@@ -95,17 +95,13 @@ export default async function TeamLayout(props: {
9595
<main className="flex grow flex-col">{props.children}</main>
9696
<div className="fixed right-6 bottom-6 z-50">
9797
<CustomChatButton
98+
clientId={undefined}
9899
isLoggedIn={true}
99100
networks="all"
100101
isFloating={true}
101102
pageType="support"
102103
label="Ask AI Assistant"
103-
customApiParams={{
104-
messagePrefix: `You are helping a user in the team "${team.name}". `,
105-
chainIds: [],
106-
wallet: undefined,
107-
}}
108-
examplePrompts={examplePrompts}
104+
examplePrompts={siwaExamplePrompts}
109105
teamId={team.id}
110106
authToken={authToken}
111107
/>

apps/dashboard/src/app/nebula-app/(app)/components/ChatPageContent.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ export function ChatPageContent(props: {
339339

340340
{messages.length > 0 && (
341341
<Chats
342+
teamId={undefined}
342343
messages={messages}
343344
isChatStreaming={isChatStreaming}
344345
authToken={props.authToken}

apps/dashboard/src/app/nebula-app/(app)/components/Chats.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ function Variant(props: {
227227
}) {
228228
return (
229229
<Chats
230+
teamId={undefined}
230231
enableAutoScroll={false}
231232
setEnableAutoScroll={() => {}}
232233
client={storybookThirdwebClient}

apps/dashboard/src/app/nebula-app/(app)/components/Chats.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { AlertCircleIcon, ThumbsDownIcon, ThumbsUpIcon } from "lucide-react";
55
import { useEffect, useRef, useState } from "react";
66
import type { ThirdwebClient } from "thirdweb";
77
import { Button } from "../../../../@/components/ui/button";
8+
import { useTrack } from "../../../../hooks/analytics/useTrack";
89
import type { NebulaSwapData } from "../api/chat";
910
import type { NebulaUserMessage, NebulaUserMessageContent } from "../api/types";
1011
import { NebulaIcon } from "../icons/NebulaIcon";
@@ -254,7 +255,6 @@ function RenderMessage(props: {
254255
</ScrollShadow>
255256
<FeedbackButtons
256257
sessionId={props.sessionId}
257-
messageText={message.type === "assistant" ? message.text : ""}
258258
authToken={props.authToken}
259259
teamId={props.teamId}
260260
/>
@@ -465,22 +465,28 @@ function StyledMarkdownRenderer(props: {
465465

466466
function FeedbackButtons({
467467
sessionId,
468-
messageText,
469468
authToken,
470469
teamId,
471470
}: {
472471
sessionId: string | undefined;
473-
messageText: string;
474472
authToken: string;
475473
teamId: string | undefined;
476474
}) {
477-
const [, setFeedback] = useState<"good" | "bad" | null>(null);
475+
const [, setFeedback] = useState<1 | -1 | null>(null);
478476
const [loading, setLoading] = useState(false);
479477
const [thankYou, setThankYou] = useState(false);
478+
const trackEvent = useTrack();
480479

481-
async function sendFeedback(rating: "good" | "bad") {
480+
async function sendFeedback(rating: 1 | -1) {
482481
setLoading(true);
483482
try {
483+
trackEvent({
484+
category: "siwa",
485+
action: "submit-feedback",
486+
rating: rating === 1 ? "good" : "bad",
487+
sessionId,
488+
teamId,
489+
});
484490
const apiUrl = process.env.NEXT_PUBLIC_SIWA_URL;
485491
await fetch(`${apiUrl}/v1/chat/feedback`, {
486492
method: "POST",
@@ -491,8 +497,7 @@ function FeedbackButtons({
491497
},
492498
body: JSON.stringify({
493499
conversationId: sessionId,
494-
message: messageText,
495-
rating,
500+
feedbackRating: rating,
496501
}),
497502
});
498503
setFeedback(rating);
@@ -517,7 +522,7 @@ function FeedbackButtons({
517522
<Button
518523
className="rounded-full border p-2 hover:bg-muted-foreground/10"
519524
variant="ghost"
520-
onClick={() => sendFeedback("bad")}
525+
onClick={() => sendFeedback(-1)}
521526
disabled={loading}
522527
aria-label="Thumbs down"
523528
>
@@ -526,7 +531,7 @@ function FeedbackButtons({
526531
<Button
527532
className="rounded-full border p-2 hover:bg-muted-foreground/10"
528533
variant="ghost"
529-
onClick={() => sendFeedback("good")}
534+
onClick={() => sendFeedback(1)}
530535
disabled={loading}
531536
aria-label="Thumbs up"
532537
>

apps/dashboard/src/app/nebula-app/(app)/components/CustomChat/CustomChatButton.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { MessageCircleIcon, XIcon } from "lucide-react";
66
import { useCallback, useRef, useState } from "react";
77
import { createThirdwebClient } from "thirdweb";
88
import { NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID } from "../../../../../@/constants/public-envs";
9+
import { useTrack } from "../../../../../hooks/analytics/useTrack";
910
import CustomChatContent from "./CustomChatContent";
1011

1112
// Create a thirdweb client for the chat functionality
@@ -29,12 +30,17 @@ export function CustomChatButton(props: {
2930
const [hasBeenOpened, setHasBeenOpened] = useState(false);
3031
const closeModal = useCallback(() => setIsOpen(false), []);
3132
const ref = useRef<HTMLDivElement>(null);
33+
const trackEvent = useTrack();
3234

3335
return (
3436
<>
3537
{/* Inline Button (not floating) */}
3638
<Button
3739
onClick={() => {
40+
trackEvent({
41+
category: "siwa",
42+
action: "open-chat",
43+
});
3844
setIsOpen(true);
3945
setHasBeenOpened(true);
4046
}}

apps/dashboard/src/app/nebula-app/(app)/components/CustomChat/CustomChatContent.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,8 @@ function CustomChatContentLoggedIn(props: {
7070
const textMessage = userMessage.content.find((x) => x.type === "text");
7171

7272
trackEvent({
73-
category: "floating_siwa",
74-
action: "send",
75-
label: "message",
73+
category: "siwa",
74+
action: "send-message",
7675
message: textMessage?.text,
7776
sessionId: sessionId,
7877
});
@@ -159,6 +158,7 @@ function CustomChatContentLoggedIn(props: {
159158
/>
160159
) : (
161160
<Chats
161+
teamId={props.teamId}
162162
messages={messages}
163163
isChatStreaming={isChatStreaming}
164164
authToken={props.authToken}
@@ -172,7 +172,7 @@ function CustomChatContentLoggedIn(props: {
172172
/>
173173
)}
174174
<ChatBar
175-
placeholder={"Ask AI"}
175+
placeholder={"Ask AI Assistant"}
176176
onLoginClick={undefined}
177177
client={props.client}
178178
isConnectingWallet={connectionStatus === "connecting"}

apps/dashboard/src/app/nebula-app/(app)/components/FloatingChat/FloatingChatContent.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ function FloatingChatContentLoggedIn(props: {
202202
/>
203203
) : (
204204
<Chats
205+
teamId={undefined}
205206
messages={messages}
206207
isChatStreaming={isChatStreaming}
207208
authToken={props.authToken}

0 commit comments

Comments
 (0)