Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Validator/ExecutionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function ExecutionDetails({
})
}, [])

const handleCopy = useTrackScriptCopy(script)
const handleCopy = useTrackScriptCopy(script, 'validator')
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Perhaps this is confusing when a debug run is started from the validator dialog?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I want to start calling it debugger in the code. We mention debugging in the Home-page, so I feel its a good fit.


return (
<Tabs.Root
Expand Down
8 changes: 6 additions & 2 deletions src/hooks/useTrackScriptCopy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@ import { useCallback } from 'react'

import { UsageEventName } from '@/services/usageTracking/types'

export function useTrackScriptCopy(script: string) {
export function useTrackScriptCopy(
script: string,
source: 'generator' | 'validator'
) {
return useCallback(
(event: ClipboardEvent) => {
const copiedText = event.clipboardData?.getData('text/plain')

if (copiedText?.trim() === script.trim()) {
window.studio.app.trackEvent({
event: UsageEventName.ScriptCopied,
payload: { source },
})
}
},
[script]
[script, source]
)
}
3 changes: 3 additions & 0 deletions src/services/usageTracking/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ interface GeneratorUpdatedEvent {

interface ScriptCopiedEvent {
event: UsageEventName.ScriptCopied
payload: {
source: 'generator' | 'validator'
}
}

interface ScriptExportedEvent {
Expand Down
2 changes: 1 addition & 1 deletion src/views/Generator/GeneratorTabs/ScriptPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function ScriptPreview({ fileName }: ScriptPreviewProps) {
const isScriptExportable = !error && !!preview

const handleExportScript = useScriptExport(fileName)
const handleCopy = useTrackScriptCopy(preview)
const handleCopy = useTrackScriptCopy(preview, 'generator')

return (
<Flex direction="column" height="100%" position="relative">
Expand Down