Files
zeekayandHanzo Dev 70ff9c7236 tools: drop the PostHog preview harness
tools/hogbox-preview drives posthog-hogland — PostHog's own internal Firecracker
CLI and SDK, the one their engineers install with
`brew install posthog/tap/hogland`. It is not a library we can point somewhere
else: its default host is https://box.mascot-kitefin.ts.net, a machine on
PostHog's tailnet, and that is the only .ts.net address in this entire tree.

So it could never have run here. Nothing outside its own directory imports it —
13 files, 2,867 lines, self-contained and unreachable.

insights-hogland and pixelhog leave pyproject's exclude-newer-package with it,
since nothing asks for either now.

Preview environments belong on our own compute. The Go cloud already serves
/v1/compute/*; a backend against that is a thing to write, not a thing to
rename PostHog's into.

Also finishes the rename in packages/quill, tools and common/scriptvm — 74
files, plus renderHogChart and the scriptvm python objects.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-09 19:26:04 -07:00

85 lines
3.4 KiB
Python

import re
from common.scriptvm.python.objects import is_script_callable, is_script_closure, is_script_date, is_script_datetime, is_script_error
# Copied from datastore_driver.util.escape, adapted only from single quotes to backquotes.
escape_chars_map = {
"\b": "\\b",
"\f": "\\f",
"\r": "\\r",
"\n": "\\n",
"\t": "\\t",
"\0": "\\0",
"\a": "\\a",
"\v": "\\v",
"\\": "\\\\",
}
singlequote_escape_chars_map = {**escape_chars_map, "'": "\\'"}
# The InsightsQL/Script parsers only accept a doubled backtick inside a quoted identifier, not a backslash-escaped one.
backquote_escape_chars_map = {**escape_chars_map, "`": "``"}
# Copied from datastore_driver.util.escape_param
def escape_string(value: str) -> str:
return "'{}'".format("".join(singlequote_escape_chars_map.get(c, c) for c in str(value)))
# Copied from datastore_driver.util.escape, adapted from single quotes to backquotes. Added a $.
def escape_identifier(identifier: str | int) -> str:
if isinstance(identifier, int): # In InsightsQL we allow integers as identifiers to access array elements
return str(identifier)
# InsightsQL allows dollars in the identifier.
if re.match(r"^[A-Za-z_$][A-Za-z0-9_$]*$", identifier):
return identifier
return "`{}`".format("".join(backquote_escape_chars_map.get(c, c) for c in identifier))
def print_script_value(obj, marked: set | None = None):
if marked is None:
marked = set()
if isinstance(obj, dict) and is_script_datetime(obj):
return f"DateTime({float(obj['dt'])}, {escape_string(obj['zone'] or 'UTC')})"
if isinstance(obj, dict) and is_script_date(obj):
return f"Date({obj['year']}, {obj['month']}, {obj['day']})"
if isinstance(obj, dict) and is_script_error(obj):
return (
f"{obj['type']}({print_script_value(obj['message'])}"
+ (f", {print_script_value(obj['payload'])}" if "payload" in obj and obj["payload"] is not None else "")
+ ")"
)
if isinstance(obj, dict) and is_script_closure(obj):
return print_script_value(obj["callable"], marked)
if isinstance(obj, dict) and is_script_callable(obj):
return f"fn<{escape_identifier(obj.get('name', 'lambda'))}({print_script_value(obj['argCount'])})>"
if isinstance(obj, list) or isinstance(obj, dict) or isinstance(obj, tuple):
if id(obj) in marked:
return "null"
marked.add(id(obj))
try:
if isinstance(obj, list):
return f"[{', '.join([print_script_value(o, marked) for o in obj])}]"
if isinstance(obj, dict):
return f"{{{', '.join([f'{print_script_value(key, marked)}: {print_script_value(value, marked)}' for key, value in obj.items()])}}}"
if isinstance(obj, tuple):
if len(obj) < 2:
return f"tuple({', '.join([print_script_value(o, marked) for o in obj])})"
return f"({', '.join([print_script_value(o, marked) for o in obj])})"
finally:
marked.remove(id(obj))
if obj is True:
return "true"
if obj is False:
return "false"
if obj is None:
return "null"
if isinstance(obj, str):
return escape_string(obj)
return str(obj)
def print_script_string_output(obj):
if isinstance(obj, str):
return str(obj)
return print_script_value(obj)