feat: add prompt and brain change tracking (#1058)

This commit is contained in:
Mamadou DICKO 2023-08-30 11:28:15 +02:00 committed by GitHub
parent 04e9f572a4
commit 1b63141b26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -13,9 +13,9 @@ import {
MentionTriggerType, MentionTriggerType,
} from "@/app/chat/[chatId]/components/ActionsBar/types"; } from "@/app/chat/[chatId]/components/ActionsBar/types";
import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext"; import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext";
import "@draft-js-plugins/mention/lib/plugin.css"; import "@draft-js-plugins/mention/lib/plugin.css";
import "draft-js/dist/Draft.css"; import "draft-js/dist/Draft.css";
import { useJune } from "@/services/analytics/useJune";
import { useMentionPlugin } from "./helpers/MentionPlugin"; import { useMentionPlugin } from "./helpers/MentionPlugin";
import { useMentionState } from "./helpers/MentionState"; import { useMentionState } from "./helpers/MentionState";
@ -41,6 +41,7 @@ export const useMentionInput = ({
setCurrentPromptId, setCurrentPromptId,
} = useBrainContext(); } = useBrainContext();
const analytics = useJune();
const { const {
editorState, editorState,
setEditorState, setEditorState,
@ -65,10 +66,12 @@ export const useMentionInput = ({
const onAddMention = (mention: MentionData) => { const onAddMention = (mention: MentionData) => {
if (mention.trigger === "#") { if (mention.trigger === "#") {
void analytics?.track("CHANGE_PROMPT");
setCurrentPromptId(mention.id as UUID); setCurrentPromptId(mention.id as UUID);
} }
if (mention.trigger === "@") { if (mention.trigger === "@") {
void analytics?.track("CHANGE_BRAIN");
setCurrentBrainId(mention.id as UUID); setCurrentBrainId(mention.id as UUID);
} }

View File

@ -81,9 +81,8 @@ export const useBrainProvider = () => {
const newActiveBrain = { id, name }; const newActiveBrain = { id, name };
saveBrainInLocalStorage(newActiveBrain); saveBrainInLocalStorage(newActiveBrain);
setCurrentBrainId(id); setCurrentBrainId(id);
void track("CHANGE_BRAIN");
}, },
[track] []
); );
const setDefaultBrain = useCallback(async () => { const setDefaultBrain = useCallback(async () => {