Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Finish adding smol dev analytics

Tomas Valenta84d95cab7db8
diff --git a/components/AgentInstructions.tsx b/components/AgentInstructions.tsx
index a86db5e2d..e404b0849 100644
--- a/components/AgentInstructions.tsx
+++ b/components/AgentInstructions.tsx
@@ -1,4 +1,5 @@
import {
+ useCallback,
useRef,
useState,
} from 'react'
@@ -11,6 +12,7 @@ import smolTemplates from 'utils/smolTemplates'
import InstructionsEditor, { InstructionsEditorRef } from 'components/Editor/Template/NodeJSExpressTemplate/InstructionsEditor'
import InstructionsTemplateButton from 'components/InstructionsTemplateButton'
import AlertError from 'components/AlertError'
+import { usePostHog } from 'posthog-js/react'
export interface Props {
value: string
@@ -29,9 +31,13 @@ function AgentInstructions({
}: Props) {
const [error, setError] = useState<{ title: string, infoItems: string[] }>()
const editorRef = useRef<InstructionsEditorRef>(null)
+ const posthog = usePostHog()
function handleContinue() {
setError(undefined)
+ posthog?.capture('confirmed instructions', {
+ instructions: value,
+ })
if (!value) {
setError({
title: 'No instructions provided',
@@ -44,9 +50,16 @@ function AgentInstructions({
onNext()
}
+ const onFocus = useCallback(() => {
+ posthog?.capture('focused instructions editor')
+ }, [posthog])
+
function handleTemplateClick(template: string) {
editorRef.current?.setContent(template)
onTemplateSelect(template)
+ posthog?.capture('selected instructions template', {
+ template: template,
+ })
}
return (
@@ -70,6 +83,7 @@ function AgentInstructions({
<div className="relative bg-gray-950 flex flex-col p-2 w-full flex-1 overflow-auto border border-gray-700 rounded-md">
<InstructionsEditor
ref={editorRef}
+ onFocus={onFocus}
className="absolute inset-0 bg-gray-950 p-4 text-gray-100"
placeholder="Create a website using Nextjs..."
content={value}
diff --git a/components/Editor/Template/NodeJSExpressTemplate/InstructionsEditor/index.tsx b/components/Editor/Template/NodeJSExpressTemplate/InstructionsEditor/index.tsx
index 74dabdfb3..b5133a386 100644
--- a/components/Editor/Template/NodeJSExpressTemplate/InstructionsEditor/index.tsx
+++ b/components/Editor/Template/NodeJSExpressTemplate/InstructionsEditor/index.tsx
@@ -17,6 +17,7 @@ export interface Props {
onChange: (value: string) => void
content: string
referenceSearch?: Fuse<Reference>
+ onFocus?: () => void
}
export interface InstructionsEditorRef {
@@ -28,6 +29,7 @@ const InstructionsEditor = forwardRef<InstructionsEditorRef, Props>(function Ins
title,
onChange,
content,
+ onFocus,
placeholder,
referenceSearch,
}: Props, ref) {
@@ -35,6 +37,7 @@ const InstructionsEditor = forwardRef<InstructionsEditorRef, Props>(function Ins
initialContent: content,
onContentChange: onChange,
placeholder,
+ onFocus,
})
useImperativeHandle(ref, () => {
diff --git a/components/SelectRepository/index.tsx b/components/SelectRepository/index.tsx
index 678fbed4d..80bb59913 100644
--- a/components/SelectRepository/index.tsx
+++ b/components/SelectRepository/index.tsx
@@ -38,14 +38,21 @@ function SelectRepository({
const posthog = usePostHog()
function configure() {
- posthog?.capture('configured github app')
+ posthog?.capture('started github app configuration')
configureGitHubApp()
}
function selectRepo(repo: RepoSetup) {
- posthog?.capture('selected repository', {
- repository: repo.fullName,
- })
+ if (selected === 'new') {
+ posthog?.capture('created new repository', {
+ repository: repo.fullName,
+ })
+ } else if (selected === 'existing') {
+ posthog?.capture('selected existing repository', {
+ repository: repo.fullName,
+ })
+ }
+
onRepoSelection(repo)
}
@@ -71,7 +78,10 @@ function SelectRepository({
<>
<RepoSwitch
value={selected}
- onChange={setSelected}
+ onChange={v => {
+ setSelected(v)
+ posthog?.capture(`selected ${v} repository tab`)
+ }}
/>
{selected === 'existing' && (
<ExistingRepositories
diff --git a/hooks/useDocEditor.ts b/hooks/useDocEditor.ts
index b5583960a..93fb335ec 100644
--- a/hooks/useDocEditor.ts
+++ b/hooks/useDocEditor.ts
@@ -8,7 +8,9 @@ function useDocEditor({
initialContent,
onContentChange,
placeholder,
+ onFocus,
}: {
+ onFocus?: () => void,
initialContent: string,
/**
* @param content in Markdown format
@@ -39,6 +41,9 @@ function useDocEditor({
}
}),
],
+ onFocus({ editor }) {
+ onFocus?.()
+ },
onCreate({ editor }) {
editor?.commands.setContent(initialContent)
},
@@ -47,7 +52,7 @@ function useDocEditor({
onContentChange(editor.storage.markdown.getMarkdown())
}
},
- }, [onContentChange])
+ }, [onContentChange, onFocus,])
return editor
}
diff --git a/pages/agent/smol-developer/setup.tsx b/pages/agent/smol-developer/setup.tsx
index 526b2f900..4c6e57121 100644
--- a/pages/agent/smol-developer/setup.tsx
+++ b/pages/agent/smol-developer/setup.tsx
@@ -130,7 +130,6 @@ function Setup() {
const {
trigger: createAgent,
- data,
} = useSWRMutation('/api/agent', handlePostAgent)
async function deployAgent() {
@@ -160,6 +159,12 @@ function Setup() {
commitMessage: 'Initial commit',
modelConfig,
})
+
+ posthog?.capture('clicked on deploy agent', {
+ repository: `${selectedRepository.owner}/${selectedRepository.repo}`,
+ instructions,
+ })
+
// Redirect to the dashboard.
if (response) {
router.push(response.pullURL)
@@ -177,6 +182,9 @@ function Setup() {
function previousStep() {
setCurrentStepIdx(currentStepIdx - 1)
+ posthog?.capture('clicked previous step', {
+ step: currentStepIdx - 1,
+ })
}
function handleRepoSelection(repo: any) {
@@ -248,8 +256,14 @@ function Setup() {
selectedRepo={selectedRepository!}
instructions={instructions}
onInstructionsChange={setInstructions}
- onChangeRepo={() => setCurrentStepIdx(0)}
- onChangeTemplate={() => setCurrentStepIdx(1)}
+ onChangeRepo={() => {
+ setCurrentStepIdx(0)
+ posthog?.capture('returned to repository selection step')
+ }}
+ onChangeTemplate={() => {
+ setCurrentStepIdx(1)
+ posthog?.capture('returned to the instructions step')
+ }}
onBack={previousStep}
onDeploy={deployAgent}
isDeploying={isDeploying}