Skip to content

Commit

Permalink
Merge pull request #587 from subquery/feat/add-trigger
Browse files Browse the repository at this point in the history
feat: add trigger
  • Loading branch information
HuberTRoy authored Jan 13, 2025
2 parents 4c5c8d3 + e56a74b commit 94bca88
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
23 changes: 22 additions & 1 deletion docs/.vuepress/components/Chatbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@

<script setup lang="ts">
import { Popover, Icon, Field } from "vant";
import { ref } from "vue";
import { ref, watchEffect } from "vue";
import ChatCloseIcon from "./icons/ChatCloseIcon.vue";
import Typography from "./Typography.vue";
import SubmitIcon from "./icons/SubmitIcon.vue";
Expand Down Expand Up @@ -187,6 +187,14 @@ const sendMessage = async () => {
inputValue.value = "";
await pushNewMsgToChat(newChat, robotAnswer);
messageRef.value?.scrollDown();
try {
window.gtag("event", "send_message_ai-asisstant", {
address: `from doc`,
});
} catch (e) {
//
}
// set user's message first, then get the response
const res = await chatWithStream(newChat.chatUrl, {
messages: newChat.prompt
Expand Down Expand Up @@ -271,6 +279,19 @@ const sendMessage = async () => {
answerStatus.value = ChatBotAnswerStatus.Error;
}
};
watchEffect(() => {
if (showPopover.value) {
try {
window.gtag("event", "open_chatbox", {
event_category: "chatbox",
event_label: "open_chatbox",
});
} catch (e) {
//
}
}
});
</script>

<style lang="scss">
Expand Down
2 changes: 1 addition & 1 deletion docs/.vuepress/components/ConversationMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}">
<img v-if="message.role === 'assistant'" src="https://static.subquery.network/logo-with-bg.svg" width="40"
height="40"></img>
<div class="conversation-message-item-span" v-html="md.render(message.content)">
<div class="conversation-message-item-span" v-html="md.render(message.content as string)">
</div>
</div>
</div>
Expand Down
6 changes: 6 additions & 0 deletions docs/.vuepress/window.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare interface Window {
config: {
apiUrl: string;
};
gtag: (event: string, type: string, options?: object) => void;
}

0 comments on commit 94bca88

Please sign in to comment.