From 5f49744bd02834349535729595a6525192bd4554 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 16 Aug 2024 18:54:49 +0530 Subject: [PATCH] fix: capture email/comment events --- frontend/src/components/CommentBox.vue | 2 ++ frontend/src/components/CommunicationArea.vue | 8 ++++++++ frontend/src/components/EmailEditor.vue | 3 +++ 3 files changed, 13 insertions(+) diff --git a/frontend/src/components/CommentBox.vue b/frontend/src/components/CommentBox.vue index ebdf00c9..8b61d09b 100644 --- a/frontend/src/components/CommentBox.vue +++ b/frontend/src/components/CommentBox.vue @@ -92,6 +92,7 @@ import AttachmentIcon from '@/components/Icons/AttachmentIcon.vue' import AttachmentItem from '@/components/AttachmentItem.vue' import { usersStore } from '@/stores/users' import { TextEditorBubbleMenu, TextEditor, FileUploader } from 'frappe-ui' +import { capture } from '@/telemetry' import { EditorContent } from '@tiptap/vue-3' import { ref, computed, defineModel } from 'vue' @@ -139,6 +140,7 @@ function appendEmoji() { editor.value.commands.insertContent(emoji.value) editor.value.commands.focus() emoji.value = '' + capture('emoji_inserted_in_comment', { emoji: emoji.value }) } function removeAttachment(attachment) { diff --git a/frontend/src/components/CommunicationArea.vue b/frontend/src/components/CommunicationArea.vue index 3bab4737..d2411a99 100644 --- a/frontend/src/components/CommunicationArea.vue +++ b/frontend/src/components/CommunicationArea.vue @@ -88,6 +88,7 @@ import EmailEditor from '@/components/EmailEditor.vue' import CommentBox from '@/components/CommentBox.vue' import CommentIcon from '@/components/Icons/CommentIcon.vue' import Email2Icon from '@/components/Icons/Email2Icon.vue' +import { capture } from '@/telemetry' import { usersStore } from '@/stores/users' import { useStorage } from '@vueuse/core' import { call, createResource } from 'frappe-ui' @@ -176,6 +177,10 @@ async function sendMail() { let subject = newEmailEditor.value.subject let cc = newEmailEditor.value.ccEmails || [] let bcc = newEmailEditor.value.bccEmails || [] + + if (attachments.value.length) { + capture('email_attachments_added') + } await call('frappe.core.doctype.communication.email.make', { recipients: recipients.join(', '), attachments: attachments.value.map((x) => x.name), @@ -200,6 +205,7 @@ async function sendComment() { comment_by: getUser()?.full_name || undefined, }) if (comment && attachments.value.length) { + capture('comment_attachments_added') await call('crm.api.comment.add_attachments', { name: comment.name, attachments: attachments.value.map((x) => x.name), @@ -214,6 +220,7 @@ async function submitEmail() { newEmail.value = '' reload.value = true emit('scroll') + capture('email_sent', { doctype: props.doctype, name: doc.value.data.name }) } async function submitComment() { @@ -223,6 +230,7 @@ async function submitComment() { newComment.value = '' reload.value = true emit('scroll') + capture('comment_sent', { doctype: props.doctype, name: doc.value.data.name }) } function toggleEmailBox() { diff --git a/frontend/src/components/EmailEditor.vue b/frontend/src/components/EmailEditor.vue index 4e7cc5aa..8d0154cd 100644 --- a/frontend/src/components/EmailEditor.vue +++ b/frontend/src/components/EmailEditor.vue @@ -175,6 +175,7 @@ import AttachmentItem from '@/components/AttachmentItem.vue' import MultiselectInput from '@/components/Controls/MultiselectInput.vue' import EmailTemplateSelectorModal from '@/components/Modals/EmailTemplateSelectorModal.vue' import { TextEditorBubbleMenu, TextEditor, FileUploader, call } from 'frappe-ui' +import { capture } from '@/telemetry' import { validateEmail } from '@/utils' import Paragraph from '@tiptap/extension-paragraph' import { EditorContent } from '@tiptap/vue-3' @@ -273,12 +274,14 @@ async function applyEmailTemplate(template) { editor.value.commands.setContent(data.message) } showEmailTemplateSelectorModal.value = false + capture('email_template_applied', { email_template: template.name }) } function appendEmoji() { editor.value.commands.insertContent(emoji.value) editor.value.commands.focus() emoji.value = '' + capture('emoji_inserted_in_email', { emoji: emoji.value }) } function toggleCC() {