From bb96b68058ef9b547d679587ef3cae76c0331def Mon Sep 17 00:00:00 2001 From: Pedro Bonamin Date: Mon, 8 Apr 2024 14:42:59 +0200 Subject: [PATCH] fix(tasks): remove comment added event from tasks.telemetry --- .../tasks/__telemetry__/tasks.telemetry.ts | 9 --- .../components/activity/TasksActivityLog.tsx | 71 ++++++++----------- 2 files changed, 29 insertions(+), 51 deletions(-) diff --git a/packages/sanity/src/tasks/__telemetry__/tasks.telemetry.ts b/packages/sanity/src/tasks/__telemetry__/tasks.telemetry.ts index 7edb7750c671..1ddaf5d52807 100644 --- a/packages/sanity/src/tasks/__telemetry__/tasks.telemetry.ts +++ b/packages/sanity/src/tasks/__telemetry__/tasks.telemetry.ts @@ -17,15 +17,6 @@ export const TaskStatusChanged = defineEvent<{ description: 'Task status changed', }) -// A comment is added in a task -export const TaskCommentAdded = defineEvent<{ - is_reply: boolean -}>({ - name: 'Task Comment Added', - version: 1, - description: 'A comment was added in a task', -}) - // A task is duplicated export const TaskDuplicated = defineEvent({ name: 'Task Duplicated', diff --git a/packages/sanity/src/tasks/src/tasks/components/activity/TasksActivityLog.tsx b/packages/sanity/src/tasks/src/tasks/components/activity/TasksActivityLog.tsx index d172976e96eb..190675cd0647 100644 --- a/packages/sanity/src/tasks/src/tasks/components/activity/TasksActivityLog.tsx +++ b/packages/sanity/src/tasks/src/tasks/components/activity/TasksActivityLog.tsx @@ -25,7 +25,6 @@ import { type CommentUpdatePayload, useComments, } from '../../../../../structure/comments' -import {TaskCommentAdded} from '../../../../__telemetry__/tasks.telemetry' import {tasksLocaleNamespace} from '../../../../i18n' import {type TaskDocument} from '../../types' import {getMentionedUsers} from '../form/utils' @@ -93,6 +92,7 @@ export function TasksActivityLog(props: TasksActivityLogProps) { url: studioUrl.toString(), workspaceTitle: workspaceTitle, subscribers: subscribers, + type: 'task', } }, [basePath, value?._id, value.title, workspaceTitle, value.subscribers], @@ -118,12 +118,9 @@ export function TasksActivityLog(props: TasksActivityLogProps) { onChange(set(notification.subscribers, ['subscribers'])) - operation.create(nextComment).then(() => { - // eslint-disable-next-line camelcase - telemetry.log(TaskCommentAdded, {is_reply: false}) - }) + operation.create(nextComment) }, - [handleGetNotificationValue, onChange, operation, telemetry], + [handleGetNotificationValue, onChange, operation], ) const handleCommentReply = useCallback( @@ -134,25 +131,20 @@ export function TasksActivityLog(props: TasksActivityLogProps) { onChange(set(notification.subscribers, ['subscribers'])) - operation - .create({ - id: commentId, - type: 'task', - message: nextComment.message, - parentCommentId: nextComment.parentCommentId, - reactions: EMPTY_ARRAY, - status: 'open', - threadId: nextComment.threadId, - context: { - notification, - }, - }) - .then(() => { - // eslint-disable-next-line camelcase - telemetry.log(TaskCommentAdded, {is_reply: true}) - }) + operation.create({ + id: commentId, + type: 'task', + message: nextComment.message, + parentCommentId: nextComment.parentCommentId, + reactions: EMPTY_ARRAY, + status: 'open', + threadId: nextComment.threadId, + context: { + notification, + }, + }) }, - [handleGetNotificationValue, onChange, operation, telemetry], + [handleGetNotificationValue, onChange, operation], ) const handleCommentCreateRetry = useCallback( @@ -166,25 +158,20 @@ export function TasksActivityLog(props: TasksActivityLogProps) { onChange(set(notification.subscribers, ['subscribers'])) - operation - .create({ - type: 'task', - id: comment._id, - message: comment.message, - parentCommentId: comment.parentCommentId, - reactions: comment.reactions || EMPTY_ARRAY, - status: comment.status, - threadId: comment.threadId, - context: { - notification, - }, - }) - .then(() => { - // eslint-disable-next-line camelcase - telemetry.log(TaskCommentAdded, {is_reply: !!comment.parentCommentId}) - }) + operation.create({ + type: 'task', + id: comment._id, + message: comment.message, + parentCommentId: comment.parentCommentId, + reactions: comment.reactions || EMPTY_ARRAY, + status: comment.status, + threadId: comment.threadId, + context: { + notification, + }, + }) }, - [getComment, handleGetNotificationValue, onChange, operation, telemetry], + [getComment, handleGetNotificationValue, onChange, operation], ) const handleCommentReact = useCallback(