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 3c1a870 commit c19ec06
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 53 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
@@ -1,4 +1,3 @@
import {useTelemetry} from '@sanity/telemetry/react'
import {Box, Flex, Stack, Text} from '@sanity/ui'
import {uuid} from '@sanity/uuid'
import {AnimatePresence, motion, type Variants} from 'framer-motion'
Expand All @@ -25,7 +24,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 @@ -67,7 +65,6 @@ type Activity =
export function TasksActivityLog(props: TasksActivityLogProps) {
const {value, onChange, path, activityData = []} = props
const currentUser = useCurrentUser()
const telemetry = useTelemetry()
const {title: workspaceTitle, basePath} = useWorkspace()
const {comments, mentionOptions, operation, getComment} = useComments()
const [commentToDeleteId, setCommentToDeleteId] = useState<string | null>(null)
Expand Down Expand Up @@ -118,12 +115,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 +128,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 +155,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 c19ec06

Please sign in to comment.