Skip to content

Commit

Permalink
fix(tasks): remove comment added event from tasks.telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobonamin committed Apr 8, 2024
1 parent 1e0304d commit bb96b68
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 51 deletions.
9 changes: 0 additions & 9 deletions packages/sanity/src/tasks/__telemetry__/tasks.telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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],
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down

0 comments on commit bb96b68

Please sign in to comment.