summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNate Sesti <sestinj@gmail.com>2023-06-02 00:51:01 -0400
committerNate Sesti <sestinj@gmail.com>2023-06-02 00:51:01 -0400
commit7bab929db01c0e585297c88747ef0f7620620343 (patch)
tree96d7a3b36cc3a283f4b40b67bf325b0a8a9d8d56
parentad76b18ef2489cfec9929c8127704122a66809be (diff)
downloadsncontinue-7bab929db01c0e585297c88747ef0f7620620343.tar.gz
sncontinue-7bab929db01c0e585297c88747ef0f7620620343.tar.bz2
sncontinue-7bab929db01c0e585297c88747ef0f7620620343.zip
posthog telemetry
-rw-r--r--continuedev/poetry.lock50
-rw-r--r--continuedev/pyproject.toml1
-rw-r--r--continuedev/src/continuedev/core/agent.py4
-rw-r--r--continuedev/src/continuedev/core/config.py4
-rw-r--r--continuedev/src/continuedev/libs/util/telemetry.py12
5 files changed, 70 insertions, 1 deletions
diff --git a/continuedev/poetry.lock b/continuedev/poetry.lock
index 810560b6..857a7c99 100644
--- a/continuedev/poetry.lock
+++ b/continuedev/poetry.lock
@@ -177,6 +177,18 @@ tests = ["attrs[tests-no-zope]", "zope-interface"]
tests-no-zope = ["cloudpickle", "hypothesis", "mypy (>=1.1.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"]
[[package]]
+name = "backoff"
+version = "2.2.1"
+description = "Function decoration for backoff and retry"
+category = "main"
+optional = false
+python-versions = ">=3.7,<4.0"
+files = [
+ {file = "backoff-2.2.1-py3-none-any.whl", hash = "sha256:63579f9a0628e06278f7e47b7d7d5b6ce20dc65c5e96a6f3ca99a6adca0396e8"},
+ {file = "backoff-2.2.1.tar.gz", hash = "sha256:03f829f5bb1923180821643f8753b0502c3b682293992485b0eef2807afa5cba"},
+]
+
+[[package]]
name = "boltons"
version = "23.0.0"
description = "When they're not builtins, they're boltons."
@@ -632,6 +644,18 @@ files = [
marshmallow = ">=2.0.0"
[[package]]
+name = "monotonic"
+version = "1.6"
+description = "An implementation of time.monotonic() for Python 2 & < 3.3"
+category = "main"
+optional = false
+python-versions = "*"
+files = [
+ {file = "monotonic-1.6-py2.py3-none-any.whl", hash = "sha256:68687e19a14f11f26d140dd5c86f3dba4bf5df58003000ed467e0e2a69bca96c"},
+ {file = "monotonic-1.6.tar.gz", hash = "sha256:3a55207bcfed53ddd5c5bae174524062935efed17792e9de2ad0205ce9ad63f7"},
+]
+
+[[package]]
name = "multidict"
version = "6.0.4"
description = "multidict implementation"
@@ -939,6 +963,30 @@ test = ["hypothesis (>=6.34.2)", "pytest (>=7.0.0)", "pytest-asyncio (>=0.17.0)"
xml = ["lxml (>=4.6.3)"]
[[package]]
+name = "posthog"
+version = "3.0.1"
+description = "Integrate PostHog into any python application."
+category = "main"
+optional = false
+python-versions = "*"
+files = [
+ {file = "posthog-3.0.1-py2.py3-none-any.whl", hash = "sha256:9c7f92fecc713257d4b2710d05b456569c9156fbdd3e85655ba7ba5ba6c7b3ae"},
+ {file = "posthog-3.0.1.tar.gz", hash = "sha256:57d2791ff5752ce56ba0f9bb8876faf3ca9208f1c2c6ceaeb5a2504c34493767"},
+]
+
+[package.dependencies]
+backoff = ">=1.10.0"
+monotonic = ">=1.5"
+python-dateutil = ">2.1"
+requests = ">=2.7,<3.0"
+six = ">=1.5"
+
+[package.extras]
+dev = ["black", "flake8", "flake8-print", "isort", "pre-commit"]
+sentry = ["django", "sentry-sdk"]
+test = ["coverage", "flake8", "freezegun (==0.3.15)", "mock (>=2.0.0)", "pylint", "pytest"]
+
+[[package]]
name = "pydantic"
version = "1.10.7"
description = "Data validation and settings management using python type hints"
@@ -1691,4 +1739,4 @@ multidict = ">=4.0"
[metadata]
lock-version = "2.0"
python-versions = "^3.9"
-content-hash = "2eb1f7b5bda2352b6b96ff4e139c0c92694b6f16d4c2fffc0e89c5c098396884"
+content-hash = "9f9254c954b7948c49debba86bc81a4a9c3f50694424f5940d0058725b1bf0fb"
diff --git a/continuedev/pyproject.toml b/continuedev/pyproject.toml
index 8ed8f268..0dc4d267 100644
--- a/continuedev/pyproject.toml
+++ b/continuedev/pyproject.toml
@@ -19,6 +19,7 @@ websockets = "^11.0.2"
urllib3 = "1.26.15"
gpt-index = "^0.6.8"
setuptools = "^67.7.2"
+posthog = "^3.0.1"
[tool.poetry.scripts]
typegen = "src.continuedev.models.generate_json_schema:main"
diff --git a/continuedev/src/continuedev/core/agent.py b/continuedev/src/continuedev/core/agent.py
index cf5c9781..29c695af 100644
--- a/continuedev/src/continuedev/core/agent.py
+++ b/continuedev/src/continuedev/core/agent.py
@@ -9,6 +9,7 @@ from ..libs.util.queue import AsyncSubscriptionQueue
from ..models.main import ContinueBaseModel
from .main import Policy, History, FullState, Step, HistoryNode
from ..libs.steps.core.core import ReversibleStep, ManualEditStep, UserInputStep
+from ..libs.util.telemetry import capture_event
from .sdk import ContinueSDK
import asyncio
@@ -77,6 +78,9 @@ class Agent(ContinueBaseModel):
_step_depth: int = 0
async def _run_singular_step(self, step: "Step", is_future_step: bool = False) -> Coroutine[Observation, None, None]:
+ capture_event(
+ 'step run', {'step_name': step.name, 'params': step.dict()})
+
if not is_future_step:
# Check manual edits buffer, clear out if needed by creating a ManualEditStep
if len(self._manual_edits_buffer) > 0:
diff --git a/continuedev/src/continuedev/core/config.py b/continuedev/src/continuedev/core/config.py
index e62f0e4f..8ed41a82 100644
--- a/continuedev/src/continuedev/core/config.py
+++ b/continuedev/src/continuedev/core/config.py
@@ -11,12 +11,16 @@ class ContinueConfig(BaseModel):
"""
steps_on_startup: Optional[Dict[str, Dict]] = {}
server_url: Optional[str] = None
+ allow_anonymous_telemetry: Optional[bool] = True
def load_config(config_file: str) -> ContinueConfig:
"""
Load the config file and return a ContinueConfig object.
"""
+ if not os.path.exists(config_file):
+ return ContinueConfig()
+
_, ext = os.path.splitext(config_file)
if ext == '.yaml':
with open(config_file, 'r') as f:
diff --git a/continuedev/src/continuedev/libs/util/telemetry.py b/continuedev/src/continuedev/libs/util/telemetry.py
new file mode 100644
index 00000000..4bff3970
--- /dev/null
+++ b/continuedev/src/continuedev/libs/util/telemetry.py
@@ -0,0 +1,12 @@
+from posthog import Posthog
+from ...core.config import load_config
+
+# The personal API key is necessary only if you want to use local evaluation of feature flags.
+posthog = Posthog('phc_JS6XFROuNbhJtVCEdTSYk6gl5ArRrTNMpCcguAXlSPs',
+ host='https://app.posthog.com')
+
+
+def capture_event(event_name, event_properties):
+ config = load_config('~/.continue/continue.json')
+ if config.allow_anonymous_telemetry:
+ posthog.capture("not distinct :(", event_name, event_properties)