Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tasks): add telemetry events to tasks #6246

Merged
merged 3 commits into from
Apr 9, 2024
Merged

feat(tasks): add telemetry events to tasks #6246

merged 3 commits into from
Apr 9, 2024

Conversation

pedrobonamin
Copy link
Contributor

Description

Adds telemetry tracking to tasks.

What to review

Is there something else worth tracking?
Are the event names correct?

Testing

Notes for release

@pedrobonamin pedrobonamin requested review from a team and hermanwikner and removed request for a team April 8, 2024 09:12
Copy link

vercel bot commented Apr 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview Apr 9, 2024 10:08am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 9, 2024 10:08am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Apr 9, 2024 10:08am

Copy link
Contributor

github-actions bot commented Apr 8, 2024

No changes to documentation

Copy link
Contributor

github-actions bot commented Apr 8, 2024

Component Testing Report Updated Apr 9, 2024 10:13 AM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 31s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 6s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 24s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 12s 4 2 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 12s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 31s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 1s 15 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 0s 18 0 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 11s 6 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 13s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 19s 9 0 0

Copy link
Contributor

@joneidejohnsen joneidejohnsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nitpicks on event naming (title case for all event names) + suggestion on reducing number of events.

@@ -116,9 +118,11 @@ export function TasksActivityLog(props: TasksActivityLogProps) {

onChange(set(notification.subscribers, ['subscribers']))

operation.create(nextComment)
operation.create(nextComment).then(() => {
telemetry.log(TaskCommentAdded)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Suggestion/idea: This is not in scope for this pull request, but maybe we should consider (in the future) to centralize the logging of comment-related telemetry events within the useCommentOperations hook, rather than in the places where those operations are invoked? Currently, we do not log telemetry for comments, so we could consider this as a refactoring effort in the future when we implement telemetry for comments.

Something like this (pseudo code):

import {
  TaskCommentCreated,
  FieldCommentCreated,
  TaskReplyCommentCreated,
  FieldReplyCommentCreated,
} from '../path/to/telemetry'
import {useTelemetry} from '@sanity/telemetry'

function useCommentOperations(props: CommentOperationsHookOptions) {
  const {type} = props
  const telemetry = useTelemetry()

  const handleCreate = useCallback(
    async (nextComment) => {
      await createOperation(nextComment).then(() => {
        const isReply = Boolean(nextComment.parentCommentId)

        if (!isReply) {
          if (type === 'task') {
            telemetry.log(TaskCommentCreated)
          }

          if (type === 'field') {
            telemetry.log(FieldCommentCreated)
          }
        }

        if (isReply) {
          if (type === 'task') {
            telemetry.log(TaskReplyCommentCreated)
          }

          if (type === 'field') {
            telemetry.log(FieldReplyCommentCreated)
          }
        }
      })
    },
    [telemetry, type],
  )

  return {
    create: handleCreate,
    // ... rest of the operations
  }
}

Copy link
Contributor Author

@pedrobonamin pedrobonamin Apr 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hermanwikner this is a great suggestion. I'll create a issue to track that, I think we should be tracking similar events for comments specific changes, but let's raise it with the growth team

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe comments are tracked server-side? We do have events for Comment Posted etc in Amplitude

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, actually I will remove this comments events from the studio and move them to the server, I can add a type property to distinguish normal comment from tasks comments.

@pedrobonamin pedrobonamin added this pull request to the merge queue Apr 9, 2024
Merged via the queue into next with commit 346600c Apr 9, 2024
36 checks passed
@pedrobonamin pedrobonamin deleted the edx-1042 branch April 9, 2024 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants