Skip to content

Commit

Permalink
feat(sanity): add telemetry when creating a draft
Browse files Browse the repository at this point in the history
  • Loading branch information
RitaDias committed Sep 3, 2024
1 parent 8bc721b commit 7041026
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.version && !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 7041026

Please sign in to comment.