Skip to content

Commit

Permalink
fix: matomo error affects normal operations
Browse files Browse the repository at this point in the history
fix #128
  • Loading branch information
sunner committed Jun 2, 2023
1 parent 28bea10 commit 62fef6d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,12 @@ function sendPromptToBots() {
// Clear the textarea after sending the prompt
prompt.value = "";
matomo.value.trackEvent("prompt", "send", "Active bots count", toBots.length);
matomo.value?.trackEvent(
"prompt",
"send",
"Active bots count",
toBots.length,
);
}
function toggleSelected(bot) {
Expand Down
6 changes: 3 additions & 3 deletions src/components/Messages/ChatMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ onMounted(() => {
function copyToClipboard() {
navigator.clipboard.writeText(props.message.content);
matomo.value.trackEvent("vote", "copy", props.message.className, 1);
matomo.value?.trackEvent("vote", "copy", props.message.className, 1);
}
function toggleHighlight() {
emits("update-message", props.message.index, {
highlight: !props.message.highlight,
});
matomo.value.trackEvent(
matomo.value?.trackEvent(
"vote",
"highlight",
props.message.className,
Expand All @@ -112,7 +112,7 @@ async function hide() {
);
if (result) {
emits("update-message", props.message.index, { hide: true });
matomo.value.trackEvent("vote", "hide", props.message.className, 1);
matomo.value?.trackEvent("vote", "hide", props.message.className, 1);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ export default createStore({
hide: false,
});

const $matomo = getMatomo();
for (const bot of bots) {
const message = {
type: "response",
Expand All @@ -171,7 +170,7 @@ export default createStore({
{ chatIndex: state.currentChatIndex, messageIndex: message.index },
);

$matomo.trackEvent(
getMatomo().trackEvent(
"prompt",
"sendTo",
bot.getClassname(),
Expand Down

0 comments on commit 62fef6d

Please sign in to comment.