Skip to content

Commit 8215d9e

Browse files
feat: Tracking events for drawer (#137)
1 parent ebb213f commit 8215d9e

File tree

11 files changed

+471
-102
lines changed

11 files changed

+471
-102
lines changed

src/bundles/AiDrawer/AiDrawer.stories.tsx

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@ import * as React from "react"
33
import type { Meta, StoryObj } from "@storybook/react"
44
import { http, HttpResponse } from "msw"
55
import { handlers } from "../../components/AiChat/test-utils/api"
6-
import { AiDrawer, AiDrawerInitMessage } from "./AiDrawer"
6+
import { AiDrawer, AiDrawerSettings } from "./AiDrawer"
77
import { MathJaxContext } from "better-react-mathjax"
88
import Button from "@mui/material/Button"
99

10-
type InitPayload = AiDrawerInitMessage["payload"]
11-
1210
const TEST_API_STREAMING = "http://localhost:4567/streaming"
1311
const CONTENT_FILE_URL =
1412
"http://localhost:4567/api/v1/contentfiles/?edx_module_id=1"
1513

16-
const INITIAL_MESSAGES: InitPayload["chat"]["initialMessages"] = [
14+
const INITIAL_MESSAGES: AiDrawerSettings["chat"]["initialMessages"] = [
1715
{
1816
content: "Hi! What are you interested in learning about?",
1917
role: "assistant",
@@ -29,18 +27,18 @@ const STARTERS = [
2927
const meta: Meta<typeof AiDrawer> = {
3028
title: "smoot-design/AI/AiDrawer",
3129
component: AiDrawer,
32-
render: ({ payload }) => {
30+
render: ({ settings }) => {
3331
const [open, setOpen] = React.useState(false)
3432
return (
3533
<>
3634
<Button variant="outlined" onClick={() => setOpen(true)}>
3735
Open Drawer
3836
</Button>
3937
<p>Message data:</p>
40-
<pre>{JSON.stringify({ payload }, null, 2)}</pre>
38+
<pre>{JSON.stringify({ settings }, null, 2)}</pre>
4139
<MathJaxContext>
4240
<AiDrawer
43-
payload={payload}
41+
settings={settings}
4442
open={open}
4543
onClose={() => setOpen(false)}
4644
/>
@@ -49,7 +47,7 @@ const meta: Meta<typeof AiDrawer> = {
4947
)
5048
},
5149
argTypes: {
52-
payload: {
50+
settings: {
5351
// JSON controls break form submission via keyboard. See
5452
// https://github.com/storybookjs/storybook/issues/31881
5553
control: false,
@@ -63,9 +61,8 @@ type Story = StoryObj<typeof AiDrawer>
6361

6462
export const ProblemStory: Story = {
6563
args: {
66-
payload: {
64+
settings: {
6765
blockType: "problem",
68-
target: "problem-frame",
6966
title: "AskTIM for help with Problem: Derivatives 1.1",
7067
chat: {
7168
apiUrl: TEST_API_STREAMING,
@@ -78,9 +75,9 @@ export const ProblemStory: Story = {
7875

7976
export const ProblemDefaultInitialMessagesStory: Story = {
8077
args: {
81-
payload: {
78+
settings: {
8279
blockType: "problem",
83-
target: "problem-frame-default-initial-messages",
80+
8481
title: "AskTIM for help with Problem: Derivatives 1.1",
8582
chat: {
8683
apiUrl: TEST_API_STREAMING,
@@ -92,9 +89,8 @@ export const ProblemDefaultInitialMessagesStory: Story = {
9289

9390
export const EntryScreenStory: Story = {
9491
args: {
95-
payload: {
92+
settings: {
9693
blockType: "problem",
97-
target: "entry-screen-frame",
9894
chat: {
9995
apiUrl: TEST_API_STREAMING,
10096
initialMessages: INITIAL_MESSAGES,
@@ -111,9 +107,8 @@ export const EntryScreenStory: Story = {
111107
*/
112108
export const VideoStory: Story = {
113109
args: {
114-
payload: {
110+
settings: {
115111
blockType: "video",
116-
target: "video-frame",
117112
chat: {
118113
apiUrl: TEST_API_STREAMING,
119114
conversationStarters: STARTERS,
@@ -141,9 +136,8 @@ export const VideoStory: Story = {
141136
*/
142137
export const FlashcardConversationStartersStory: Story = {
143138
args: {
144-
payload: {
139+
settings: {
145140
blockType: "video",
146-
target: "starters-frame",
147141
chat: {
148142
apiUrl: TEST_API_STREAMING,
149143
},

0 commit comments

Comments
 (0)