Skip to content

Commit

Permalink
Add anonymous telemetry about playground actions (#925)
Browse files Browse the repository at this point in the history
  • Loading branch information
hellovai authored Sep 5, 2024
1 parent 1dfddb5 commit 6f58c9e
Show file tree
Hide file tree
Showing 8 changed files with 7,213 additions and 8,854 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ export const useRunHooks = () => {
set(isRunningAtom, true)
set(showTestsAtom, true)

vscode.postMessage({
command: 'telemetry',
meta: {
action: 'run_tests',
data: {
num_tests: testNames.length,
},
},
})

// First clear any previous test results
testStatusAtom.setShouldRemove(() => true)
// Remove the shouldRemove function so we don't remove future test results
Expand Down
6 changes: 3 additions & 3 deletions typescript/playground-common/src/shared/AppStateContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ interface AppStateContextProps {
showTokens: boolean
setShowTokens: React.Dispatch<React.SetStateAction<boolean>>
showWhitespace: boolean
setShowWhitespace: React.Dispatch<React.SetStateAction<boolean>>
// setShowWhitespace: React.Dispatch<React.SetStateAction<boolean>>
showCurlRequest: boolean
setShowCurl: React.Dispatch<React.SetStateAction<boolean>>
showTestResults: boolean
Expand All @@ -15,7 +15,8 @@ const AppStateContext = createContext<AppStateContextProps | undefined>(undefine

export const AppStateProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
const [showTokens, setShowTokens] = useState(false)
const [showWhitespace, setShowWhitespace] = useState(false)
const showWhitespace = false
// const [showWhitespace, setShowWhitespace] = useState(false)
const [showCurlRequest, setShowCurl] = useState(false)
const [showTestResults, setShowTestResults] = useState(true)

Expand All @@ -25,7 +26,6 @@ export const AppStateProvider: React.FC<{ children: React.ReactNode }> = ({ chil
showTokens,
setShowTokens,
showWhitespace,
setShowWhitespace,
showCurlRequest,
setShowCurl,
showTestResults,
Expand Down
16 changes: 4 additions & 12 deletions typescript/playground-common/src/shared/CheckboxHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react'
import { useAppState } from './AppStateContext'
import { Checkbox } from '../components/ui/checkbox'
import { useAtomValue } from 'jotai'
Expand All @@ -23,25 +24,16 @@ const PromptCheckbox = ({
}

export const CheckboxHeader = () => {
const {
showTokens,
setShowTokens,
showWhitespace,
setShowWhitespace,
showCurlRequest,
setShowCurl,
showTestResults,
setShowTestResults,
} = useAppState()
const { showTokens, setShowTokens, showCurlRequest, setShowCurl, showTestResults, setShowTestResults } = useAppState()

return (
<div className='flex flex-wrap justify-start gap-4 px-2 py-2 text-xs whitespace-nowrap'>
<PromptCheckbox checked={showTokens} onChange={setShowTokens}>
Show Tokens
</PromptCheckbox>
<PromptCheckbox checked={showWhitespace} onChange={setShowWhitespace}>
{/* <PromptCheckbox checked={showWhitespace} onChange={setShowWhitespace}>
Whitespace
</PromptCheckbox>
</PromptCheckbox> */}
<PromptCheckbox checked={showCurlRequest} onChange={setShowCurl}>
Raw cURL
</PromptCheckbox>
Expand Down
2 changes: 1 addition & 1 deletion typescript/playground-common/src/shared/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Link: React.FC<{ item: StringSpan; display?: string; className?: string }>
<VSCodeLink
className={cn(className, 'font-medium underline underline-offset-2 hover:text-vscode-textLink-activeForeground')}
onClick={() => {
vscode.postMessage({ command: 'jumpToFile', data: item })
vscode.postMessage({ command: 'jumpToFile', span: item })
}}
>
<div className='flex flex-row items-center gap-0.5'>
Expand Down
Loading

0 comments on commit 6f58c9e

Please sign in to comment.