Skip to content

Commit

Permalink
refactor(structure): update telemetry names and event properties
Browse files Browse the repository at this point in the history
  • Loading branch information
RitaDias committed Sep 23, 2024
1 parent 3b777cd commit d06029a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ import {

import {Button} from '../../../../../ui-components'
import {structureLocaleNamespace} from '../../../../i18n'
import {
DiscardedLiveEditDraft,
PublishedLiveEditDraft,
} from './__telemetry__/DraftLiveEditBanner.telemetry'
import {ResolvedLiveEdit} from './__telemetry__/DraftLiveEditBanner.telemetry'
import {Banner} from './Banner'

interface DraftLiveEditBannerProps {
Expand All @@ -40,13 +37,13 @@ export function DraftLiveEditBanner({
const handlePublish = useCallback(() => {
publish.execute()
setPublishing(true)
telemetry.log(PublishedLiveEditDraft)
telemetry.log(ResolvedLiveEdit, {liveEditResolveType: 'publish'})
}, [publish, telemetry])

const handleDiscard = useCallback(() => {
discardChanges.execute()
setDiscarding(true)
telemetry.log(DiscardedLiveEditDraft)
telemetry.log(ResolvedLiveEdit, {liveEditResolveType: 'discard'})
}, [discardChanges, telemetry])

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
import {defineEvent} from '@sanity/telemetry'

interface TypeInfo {
liveEditResolveType: 'publish' | 'discard'
}

/**
* When a draft in a live edit document is published
* @internal
*/
export const PublishedLiveEditDraft = defineEvent({
name: 'Resolve liveEdit by publishing draft',
version: 1,
description: 'User published a draft when a draft of a live edit document to continue editing',
})

/*
* When a draft in a live edit document is discarded
* @internal
*/
export const DiscardedLiveEditDraft = defineEvent({
name: 'Resolve liveEdit by discarding draftt',
export const ResolvedLiveEdit = defineEvent<TypeInfo>({
name: 'Resolved LiveEdit Draft',
version: 1,
description: 'User discarded a draft when a draft of a live edit document to continue editing',
description: 'User resolved a draft of a live edit document to continue editing',
})

0 comments on commit d06029a

Please sign in to comment.