Skip to content

Commit

Permalink
feat(sanity): add telemetry when creating a draft (#7459)
Browse files Browse the repository at this point in the history
  • Loading branch information
RitaDias authored and ricokahler committed Sep 6, 2024
1 parent ef7fff8 commit e6b0614
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import {usePaneRouter} from '../../components'
import {structureLocaleNamespace} from '../../i18n'
import {type PaneMenuItem} from '../../types'
import {useStructureTool} from '../../useStructureTool'
import {DocumentURLCopied} from './__telemetry__'
import {CreatedDraft, DocumentURLCopied} from './__telemetry__'
import {
DEFAULT_MENU_ITEM_GROUPS,
EMPTY_PARAMS,
Expand Down Expand Up @@ -294,6 +294,10 @@ export const DocumentPaneProvider = memo((props: DocumentPaneProviderProps) => {
})

patchRef.current = (event: PatchEvent) => {
// when creating a new draft
if (!editState.draft && !editState.published) {
telemetry.log(CreatedDraft)
}
patch.execute(toMutationPatches(event.patches), initialValue.value)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,13 @@ export const DocumentURLCopied = defineEvent({
version: 1,
description: 'User copied document URL to clipboard',
})

/**
* When a draft is successfully created
* @internal
*/
export const CreatedDraft = defineEvent({
name: 'Create a new draft',
version: 1,
description: 'User created a new draft',
})

0 comments on commit e6b0614

Please sign in to comment.