* Initial intelliJ plugin changes to support webview * connect webview websockets * Starting work on downloading server binary from S3 * fix color theme in intellij * refactor name to continuedev * correctly set important variables for onLoad * highlighted code now working * keyboard shortcuts (Actions) * fix: 🐛 hf_tgi fix, proxy support for ggml * fix: 🐛 remove unecessary logging * Sync the changes * Clean up code * updating how continue works * ci: 🏷 Update PyPI version [skip ci] * docs: 📝 docs for customizing chat / edit templates * docs: 📝 headless mode docs (start) * docs: 📝 updated setup docs * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * fix: 🐛 compatibility with python 3.8 * feat: ✨ verify_ssl option for all LLMs * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * fix: 🐛 verify_ssl and ssl_context mutual exclusivity * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * feat: 🩹 ca_bundle_path for maybeproxyopenai * fix: 🐛 a few minor fixes * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * fix: 🐛 custom escaping instead of URI for diff paths * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * fix: 🐛 fix huggingface tgi * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * docs: 📝 small docs update on how continue works * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * Clarifying `logs` instructions in troubleshooting.md (#476) * fix: 🐛 fixes to templating messages * fix: some typos (#478) * fix: 🐛 fix for lmstudio defaults * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * Implement design patterns for better extensibility * Fix: Ensure read operations in ContinuePluginSelectionListener are run within the correct context using runReadAction. * feat: ✨ implement most other ideProtocolClient methods * wait until server is running to connect * remove unnecessary imports, update version * reformat code and optimize the imports * fix: 🐛 fix serialization bug * fix: 🐛 attempt to fix error from jetbrains marketplace * a few updates * fix: 🐛 bringing jetbrains up to par * feat: ✨ highlighted code updates in intellij * fix: 🚑 fix freezing issue * fix: 🐛 fix icons, bump version * feat: ✨ /edit support, other fixes * quick input, keyboard shortcuts * fix: 🐛 fix /edit and keyboard shortcuts and lagging on scroll * feat: 💄 welcome panel * chore: 🔖 update version * ide endpoint for websockets * fix: 🚑 fix freezing problem * quick input * fix: 🐛 small jetbrains fixes * fix: 💄 nicer dropdown that can "drop up" * fix: 🐛 fix font size for dropdown * fix: 💄 fix textarea for quickinput * Preview (#541) * Strong typing (#533) * refactor: ♻️ get rid of continuedev.src.continuedev structure * refactor: ♻️ switching back to server folder * feat: ✨ make config.py imports shorter * feat: 🔖 publish as pre-release vscode extension * refactor: ♻️ refactor and add more completion params to ui * build: 🏗️ download from preview S3 * fix: 🐛 fix paths * fix: 💚 package:pre-release * ci: 💚 more time for tests * fix: 💚 fix build scripts * fix: 🐛 fix import in run.py * fix: 🔖 update version to try again * ci: 💚 Update package.json version [skip ci] * refactor: 🔥 don't check for old extensions version * fix: 🐛 small bug fixes * fix: 🐛 fix config.py import paths * ci: 💚 Update package.json version [skip ci] * ci: 💚 platform-specific builds test #1 * feat: 💚 ship with binary * fix: 💚 fix copy statement to include.exe for windows * fix: 💚 cd extension before packaging * chore: 🔊 count tokens generated * fix: 💚 remove npm_config_arch * fix: 💚 publish as pre-release! * chore: 🔖 update version * perf: 💚 hardcode distro paths * fix: 🐛 fix yaml syntax error * chore: 🔖 update version * fix: 💚 update permissions and version * feat: 🐛 kill old server if needed * feat: 💄 update marketplace icon for pre-release * ci: 💚 Update package.json version [skip ci] * feat: ✨ auto-reload for config.py * feat: 🔧 update default config.py imports * feat: ✨ codelens in config.py * feat: ✨ select model param count from UI * ci: 💚 Update package.json version [skip ci] * feat: ✨ more model options, ollama error handling * perf: ⚡ don't show server loading immediately * fix: 🐛 fixing small UI details * ci: 💚 Update package.json version [skip ci] * feat: 🚀 headers param on LLM class * fix: 🐛 fix headers for openai.;y * feat: ✨ highlight code on cmd+shift+L * ci: 💚 Update package.json version [skip ci] * feat: 💄 sticky top bar in gui.tsx * fix: 🔊 websocket logging and horizontal scrollbar * ci: 💚 Update package.json version [skip ci] * feat: ✨ allow AzureOpenAI Service through GGML * ci: 💚 Update package.json version [skip ci] * fix: 🐛 fix automigration * ci: 💚 Update package.json version [skip ci] * ci: 💚 upload binaries in ci, download apple silicon * chore: 🔥 remove notes * fix: 💚 use curl to download binary * fix: 💚 set permissions on apple silicon binary * fix: 💚 testing * fix: 💚 cleanup file * fix: 💚 fix preview.yaml * fix: 💚 only upload once per binary * fix: 💚 install rosetta * ci: 💚 download binary after tests * ci: 💚 Update package.json version [skip ci] * ci: 💚 prepare ci for merge to main --------- Co-authored-by: GitHub Action <action@github.com> * fix: 📝 fix deployent readme * fix: 🐛 do read operation in readAction * chore: 🔖 update version * 🐛 small jetbrains fixes * ⚡️ exponential backoff jetbrains * 🐛 fix history loading bug * 💄 many small ui fixes * 🐛 fixes freezing problem (actually) * 🥅 catch errors, other stuff * 🐛 many jetbrains fixes * 💄 when no context items found, say in dropdown * 🎉 VS Code tutorial * ✨ jetbrains tutorial file * ⚡️ exponential backoff for ide websockets * 🎉 unused work on intellij editor inlay * ✨ server loading progress messages * ✨ additional progress update * 💄 fix /edit flickering, keyboard interactions --------- Co-authored-by: Nate Sesti <sestinj@gmail.com> Co-authored-by: Ty Dunn <ty@tydunn.com> Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Aaron Mihalik <amihalik@users.noreply.github.com> Co-authored-by: LangLangBart <92653266+LangLangBart@users.noreply.github.com> Co-authored-by: Nate Sesti <33237525+sestinj@users.noreply.github.com>
109 lines
3.8 KiB
Python
109 lines
3.8 KiB
Python
import os
|
|
import socket
|
|
from typing import Any, Dict, Optional
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
from ..constants.main import CONTINUE_SERVER_VERSION_FILE
|
|
from .commonregex import clean_pii_from_any
|
|
from .paths import getServerFolderPath
|
|
|
|
load_dotenv()
|
|
in_codespaces = os.getenv("CODESPACES") == "true"
|
|
# This key is public
|
|
POSTHOG_API_KEY = "phc_JS6XFROuNbhJtVCEdTSYk6gl5ArRrTNMpCcguAXlSPs"
|
|
|
|
|
|
def is_connected():
|
|
try:
|
|
# connect to the host -- tells us if the host is actually reachable
|
|
socket.create_connection(("www.google.com", 80))
|
|
return True
|
|
except OSError:
|
|
pass
|
|
return False
|
|
|
|
|
|
class PostHogLogger:
|
|
unique_id: str = "NO_UNIQUE_ID"
|
|
allow_anonymous_telemetry: bool = False
|
|
ide_info: Optional[Dict] = None
|
|
posthog = None
|
|
|
|
def __init__(self, api_key: str):
|
|
self.api_key = api_key
|
|
|
|
def setup(
|
|
self, unique_id: str, allow_anonymous_telemetry: bool, ide_info: Optional[Dict]
|
|
):
|
|
self.unique_id = unique_id or "NO_UNIQUE_ID"
|
|
self.allow_anonymous_telemetry = allow_anonymous_telemetry or False
|
|
self.ide_info = ide_info
|
|
|
|
# Capture initial event
|
|
self.capture_event("session_start", {"os": os.name})
|
|
|
|
def capture_event(self, event_name: str, event_properties: Any):
|
|
"""Safely capture event. Telemetry should never be the reason Continue doesn't work"""
|
|
try:
|
|
self._capture_event(event_name, event_properties)
|
|
except Exception as e:
|
|
print(f"Failed to capture event: {e}")
|
|
pass
|
|
|
|
_found_disconnected: bool = False
|
|
|
|
def _capture_event(self, event_name: str, event_properties: Any):
|
|
# logger.debug(
|
|
# f"Logging to PostHog: {event_name} ({self.unique_id}, {self.allow_anonymous_telemetry}): {event_properties}")
|
|
telemetry_path = os.path.expanduser("~/.continue/telemetry.log")
|
|
|
|
# Make sure the telemetry file exists
|
|
if not os.path.exists(telemetry_path):
|
|
os.makedirs(os.path.dirname(telemetry_path), exist_ok=True)
|
|
open(telemetry_path, "w").close()
|
|
|
|
with open(telemetry_path, "a") as f:
|
|
str_to_write = f"{event_name}: {event_properties}\n{self.unique_id}\n{self.allow_anonymous_telemetry}\n\n"
|
|
f.write(str_to_write)
|
|
|
|
if not self.allow_anonymous_telemetry:
|
|
return
|
|
|
|
# Clean PII from event properties
|
|
event_properties = clean_pii_from_any(event_properties)
|
|
|
|
# Add additional properties that are on every event
|
|
if in_codespaces:
|
|
event_properties["codespaces"] = True
|
|
|
|
server_version_file = os.path.join(
|
|
getServerFolderPath(), CONTINUE_SERVER_VERSION_FILE
|
|
)
|
|
if os.path.exists(server_version_file):
|
|
with open(server_version_file, "r") as f:
|
|
event_properties["server_version"] = f.read()
|
|
|
|
# Add operating system
|
|
event_properties["os"] = os.name
|
|
if self.ide_info:
|
|
event_properties["ide_name"] = self.ide_info.get("name", None)
|
|
event_properties["ide_version"] = self.ide_info.get("version", None)
|
|
event_properties["ide_remote_name"] = self.ide_info.get("remoteName", None)
|
|
|
|
# Send event to PostHog
|
|
if self.posthog is None:
|
|
from posthog import Posthog
|
|
|
|
# The personal API key is necessary only if you want to use local evaluation of feature flags.
|
|
self.posthog = Posthog(self.api_key, host="https://app.posthog.com")
|
|
|
|
if is_connected():
|
|
self.posthog.capture(self.unique_id, event_name, event_properties)
|
|
else:
|
|
if not self._found_disconnected:
|
|
self._found_disconnected = True
|
|
raise ConnectionError("No internet connection")
|
|
|
|
|
|
posthog_logger = PostHogLogger(api_key=POSTHOG_API_KEY)
|