-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
108 additions
and
8 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
packages/sanity/src/core/create/__telemetry__/create.telemetry.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import {defineEvent} from '@sanity/telemetry' | ||
|
||
export const StartInCreateClicked = defineEvent({ | ||
name: 'Start in Create clicked', | ||
version: 1, | ||
description: 'The "Start in Sanity Create" button is clicked.', | ||
}) | ||
|
||
export const StartInCreateAccepted = defineEvent({ | ||
name: 'Start in Create accepted', | ||
version: 1, | ||
description: | ||
'Continue in the "Start in Sanity Create" dialog was pressed, or auto-confirm was enabled.', | ||
}) | ||
|
||
export const CreateUnlinkClicked = defineEvent({ | ||
name: 'Create Unlink clicked', | ||
version: 1, | ||
description: 'The Unlink action was clicked', | ||
}) | ||
|
||
export const CreateUnlinkAccepted = defineEvent({ | ||
name: 'Create Unlink accepted', | ||
version: 1, | ||
description: 'User confirmed that they want the Studio document unlinked', | ||
}) | ||
|
||
export const EditInCreateClicked = defineEvent({ | ||
name: 'Edit in Create clicked', | ||
version: 1, | ||
description: 'User clicked "Edit in Create"', | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
packages/sanity/src/core/create/useSanityCreateTelemetry.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import {useTelemetry} from '@sanity/telemetry/react' | ||
import {useCallback, useMemo} from 'react' | ||
|
||
import { | ||
CreateUnlinkAccepted, | ||
CreateUnlinkClicked, | ||
EditInCreateClicked, | ||
StartInCreateAccepted, | ||
StartInCreateClicked, | ||
} from './__telemetry__/create.telemetry' | ||
|
||
interface SanityCreateTelemetryHookValue { | ||
startInCreateClicked: () => void | ||
startInCreateAccepted: () => void | ||
unlinkClicked: () => void | ||
unlinkAccepted: () => void | ||
editInCreateClicked: () => void | ||
} | ||
|
||
/** @internal */ | ||
export function useSanityCreateTelemetry(): SanityCreateTelemetryHookValue { | ||
const telemetry = useTelemetry() | ||
|
||
const startInCreateClicked = useCallback(() => telemetry.log(StartInCreateClicked), [telemetry]) | ||
const startInCreateAccepted = useCallback(() => telemetry.log(StartInCreateAccepted), [telemetry]) | ||
const unlinkClicked = useCallback(() => telemetry.log(CreateUnlinkClicked), [telemetry]) | ||
const unlinkAccepted = useCallback(() => telemetry.log(CreateUnlinkAccepted), [telemetry]) | ||
const editInCreateClicked = useCallback(() => telemetry.log(EditInCreateClicked), [telemetry]) | ||
|
||
return useMemo( | ||
(): SanityCreateTelemetryHookValue => ({ | ||
startInCreateClicked, | ||
startInCreateAccepted, | ||
unlinkClicked, | ||
unlinkAccepted, | ||
editInCreateClicked, | ||
}), | ||
[ | ||
startInCreateClicked, | ||
startInCreateAccepted, | ||
unlinkClicked, | ||
unlinkAccepted, | ||
editInCreateClicked, | ||
], | ||
) | ||
} |