Skip to content

Commit 61ce032

Browse files
track all current events
1 parent cbe4cf7 commit 61ce032

File tree

7 files changed

+39
-3
lines changed

7 files changed

+39
-3
lines changed

src/components/content/chat/chatbubbles/BobAnswerBubble.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Bobhead from "../../../../assets/illustrations/Bob-hode-svg.svg"
55
import { Message, NewMessage } from "../../../../types/Message.ts"
66
import BobSuggests from "../suggestions/BobSuggests.tsx"
77
import BobAnswerCitations from "./BobAnswerCitations.tsx"
8+
import amplitude from "../../../../utils/amplitude.ts"
89

910
interface BobAnswerBubbleProps {
1011
message: Message
@@ -30,6 +31,14 @@ export const BobAnswerBubble = ({
3031
}
3132
}, [isReadMoreOpen])
3233

34+
const readMoreOpenOnChange = (value: boolean) => {
35+
value
36+
? amplitude.kildeAccordionÅpnet()
37+
: amplitude.kildeAccordionSkjult()
38+
39+
setIsReadMoreOpen(value)
40+
}
41+
3342
return (
3443
<VStack gap='1' align='stretch' className='pb-12'>
3544
<HStack gap='1' align='start' wrap={false} width='full'>
@@ -70,7 +79,7 @@ export const BobAnswerBubble = ({
7079
<ReadMore
7180
header='Sitater fra kunnskapsbasen'
7281
defaultOpen={true}
73-
onOpenChange={setIsReadMoreOpen}
82+
onOpenChange={readMoreOpenOnChange}
7483
className='readmore-styling fade-in-citations'
7584
>
7685
<div className='flex flex-col gap-2 pt-4'>

src/components/content/chat/feedback/GiveUsFeedback.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { BodyLong, Button, Heading, Modal } from "@navikt/ds-react"
33
import { useRef } from "react"
44
import Markdown from "react-markdown"
55
import { Message } from "../../../../types/Message.ts"
6+
import amplitude from "../../../../utils/amplitude.ts"
67

78
interface GiveUsFeedbackProps {
89
message: Message
@@ -19,6 +20,7 @@ export const GiveUsFeedback = ({ message }: GiveUsFeedbackProps) => {
1920
}
2021

2122
function handleButtonClick() {
23+
amplitude.feilMeldt(message.id)
2224
window.open(
2325
`https://forms.office.com/Pages/ResponsePage.aspx?id=NGU2YsMeYkmIaZtVNSedCyBQAauBOz1OlySa0dtLBP9UNUZJQkJYVzhKWTZXS0g0V0RBM0JSN1pNMC4u&rc0fd63ffeb9146e1bec0b90cc73ca985=${encodedText(message.content)}%0A%0AMeldingsID: ${encodedText(message.id)}`,
2426
"_blank",

src/components/content/chat/suggestions/BobSuggests.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Button, CopyButton, Dropdown, Label } from "@navikt/ds-react"
33
import { Message, NewMessage } from "../../../../types/Message.ts"
44
import { GiveUsFeedback } from "../feedback/GiveUsFeedback.tsx"
55
import "./BobSuggests.css"
6+
import amplitude from "../../../../utils/amplitude.ts"
67

78
interface BobSuggestsProps {
89
message: Message
@@ -12,6 +13,7 @@ interface BobSuggestsProps {
1213

1314
const BobSuggests = ({ message, onSend, isLastMessage }: BobSuggestsProps) => {
1415
function handleTranslate() {
16+
amplitude.svarEndret("oversett")
1517
const translate: NewMessage = {
1618
content: isLastMessage
1719
? "Oversett svaret til engelsk"
@@ -21,6 +23,7 @@ const BobSuggests = ({ message, onSend, isLastMessage }: BobSuggestsProps) => {
2123
}
2224

2325
function handleBulletList() {
26+
amplitude.svarEndret("punktliste")
2427
const bulletList: NewMessage = {
2528
content: isLastMessage
2629
? "Gjør om svaret til punktliste"
@@ -30,6 +33,7 @@ const BobSuggests = ({ message, onSend, isLastMessage }: BobSuggestsProps) => {
3033
}
3134

3235
function handleSimplify() {
36+
amplitude.svarEndret("forenkle")
3337
const simplifyMessage: NewMessage = {
3438
content: isLastMessage
3539
? "Forenkle svaret"
@@ -45,6 +49,7 @@ const BobSuggests = ({ message, onSend, isLastMessage }: BobSuggestsProps) => {
4549
size='small'
4650
text='Kopier'
4751
activeText='Kopiert'
52+
onClick={() => amplitude.svarKopiert(message.id)}
4853
/>
4954
<GiveUsFeedback message={message} />
5055

src/components/header/tipsfrombob/TipsFromBob.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,23 @@ import { Button } from "@navikt/ds-react"
33
import { useRef } from "react"
44
import "./TipsFromBob.css"
55
import { ButtonClickModal, FirstTimeLoginModal } from "./TipsModals.tsx"
6+
import amplitude from "../../../utils/amplitude.ts"
67

78
const TipsFromBob = () => {
89
const firstTimeLoginModal = useRef<HTMLDialogElement>(null)
910
const buttonClickModal = useRef<HTMLDialogElement>(null)
1011

12+
const showModal = () => {
13+
amplitude.infoÅpnet()
14+
buttonClickModal.current?.showModal()
15+
}
16+
1117
return (
1218
<div className='flex self-center'>
1319
<Button
1420
variant='tertiary'
1521
size='small'
16-
onClick={() => buttonClickModal.current?.showModal()}
22+
onClick={() => showModal()}
1723
icon={<InformationSquareIcon />}
1824
iconPosition='right'
1925
className='max-phone:hidden'
@@ -23,7 +29,7 @@ const TipsFromBob = () => {
2329
<Button
2430
variant='tertiary'
2531
size='medium'
26-
onClick={() => buttonClickModal.current?.showModal()}
32+
onClick={() => showModal()}
2733
icon={<InformationSquareIcon />}
2834
iconPosition='right'
2935
className='phone:hidden'

src/components/inputfield/InputField.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useEffect, useState } from "react"
55

66
import { NewMessage } from "../../types/Message.ts"
77
import "./InputField.css"
8+
import amplitude from "../../utils/amplitude.ts"
89

910
interface InputFieldProps {
1011
onSend: (message: NewMessage) => void
@@ -31,6 +32,7 @@ function InputField({ onSend, disabled }: InputFieldProps) {
3132
}
3233

3334
function handlePasteInfoAlert() {
35+
amplitude.tekstInnholdLimtInn()
3436
setIsSensitiveInfoAlert(true)
3537
}
3638

@@ -51,6 +53,7 @@ function InputField({ onSend, disabled }: InputFieldProps) {
5153
e.preventDefault()
5254

5355
if (!sendDisabled) {
56+
amplitude.meldingSendt("enter")
5457
sendMessage()
5558
setInputValue("")
5659
setIsSensitiveInfoAlert(false)
@@ -61,13 +64,19 @@ function InputField({ onSend, disabled }: InputFieldProps) {
6164

6265
function handleButtonClick() {
6366
if (inputValue.trim() !== "") {
67+
amplitude.meldingSendt("knapp")
6468
sendMessage()
6569
setInputValue("")
6670
}
6771
}
6872

6973
useEffect(() => {
7074
const inputContainsFnr = checkContainsFnr(inputValue)
75+
76+
if (inputContainsFnr) {
77+
amplitude.tekstInneholderFnr()
78+
}
79+
7180
setContainsFnr(inputContainsFnr)
7281
setSendDisabled(disabled || inputContainsFnr)
7382
}, [inputValue, disabled])

src/components/menu/darkmode/DarkModeToggle.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useEffect, useState } from "react"
22
import "./DarkModeToggle.css"
3+
import amplitude from "../../../utils/amplitude"
34

45
const DarkModeToggle = () => {
56
const [dark, setDark] = useState(() => {
@@ -10,8 +11,10 @@ const DarkModeToggle = () => {
1011
useEffect(() => {
1112
if (dark) {
1213
document.body.classList.add("dark")
14+
amplitude.mørkModusByttet("mørk")
1315
} else {
1416
document.body.classList.remove("dark")
17+
amplitude.mørkModusByttet("lys")
1518
}
1619
}, [dark])
1720

src/utils/amplitude.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const createAmpltiudeInstance = (): AmplitudeInstance => {
2828
return amplitude;
2929
};
3030

31+
/*
3132
const mockedAmplitude = (): AmplitudeInstance => ({
3233
logEvent: (eventInput: Types.BaseEvent | string, eventProperties?: Record<string, any>) => {
3334
console.group('Mocked amplitude-event');
@@ -61,6 +62,7 @@ const mockedAmplitude = (): AmplitudeInstance => ({
6162
};
6263
},
6364
});
65+
*/
6466

6567
const instance = createAmpltiudeInstance()
6668

0 commit comments

Comments
 (0)