Skip to content

Commit

Permalink
feat: add prompt and brain change tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
mamadoudicko committed Aug 29, 2023
1 parent 93b3fb3 commit 79937b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import {
MentionTriggerType,
} from "@/app/chat/[chatId]/components/ActionsBar/types";
import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext";

import "@draft-js-plugins/mention/lib/plugin.css";
import "draft-js/dist/Draft.css";
import { useJune } from "@/services/analytics/useJune";

import { useMentionPlugin } from "./helpers/MentionPlugin";
import { useMentionState } from "./helpers/MentionState";
Expand All @@ -41,6 +41,7 @@ export const useMentionInput = ({
setCurrentPromptId,
} = useBrainContext();

const analytics = useJune();
const {
editorState,
setEditorState,
Expand All @@ -65,10 +66,12 @@ export const useMentionInput = ({

const onAddMention = (mention: MentionData) => {
if (mention.trigger === "#") {
void analytics?.track("CHANGE_PROMPT");
setCurrentPromptId(mention.id as UUID);
}

if (mention.trigger === "@") {
void analytics?.track("CHANGE_BRAIN");
setCurrentBrainId(mention.id as UUID);
}

Expand Down
3 changes: 1 addition & 2 deletions frontend/lib/context/BrainProvider/hooks/useBrainProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ export const useBrainProvider = () => {
const newActiveBrain = { id, name };
saveBrainInLocalStorage(newActiveBrain);
setCurrentBrainId(id);
void track("CHANGE_BRAIN");
},
[track]
[]
);

const setDefaultBrain = useCallback(async () => {
Expand Down

0 comments on commit 79937b7

Please sign in to comment.