Documentation
¶
Index ¶
- func Bucket(n int) string
- func CloseClient()
- func DisableForSession()
- func Enabled() bool
- func GetAnonymousTrackingId() (string, error)
- func KnownEvent(event EventType) bool
- func NormalizeExtension(name string) string
- func NormalizeLanguage(kernelName string) string
- func ResetTrackingId() error
- func SetEnabled(on bool)
- func SetUpPostHogClient() error
- func TelemetryHandler(w http.ResponseWriter, req *http.Request)
- func TelemetrySettingsHandler(w http.ResponseWriter, req *http.Request)
- func TelemetrySettingsModifyHandler(w http.ResponseWriter, req *http.Request)
- func Track(event EventType, props map[string]interface{})
- func TrackServerStart()
- func Validate(event EventType, props map[string]interface{}) error
- type EventType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bucket ¶
Bucket puts a count or a duration into one of a handful of ranges. Reporting the range rather than the number is what keeps "ran 3 cells" from becoming a fingerprint.
func CloseClient ¶
func CloseClient()
CloseClient reports how long the session lasted and blocks until the queue has drained.
func DisableForSession ¶
func DisableForSession()
DisableForSession records that this run was started with tracking off. Nothing can turn it back on until the process restarts.
func Enabled ¶
func Enabled() bool
Enabled reports whether anything at all will be sent. Every hook checks this first, so that turning tracking off means no work and no network rather than a dropped payload.
func GetAnonymousTrackingId ¶
GetAnonymousTrackingId returns the random per-install id, generating and persisting one on first use. It identifies an installation, never a person: nothing else about the machine goes into it.
func KnownEvent ¶
KnownEvent reports whether an event name is in the catalogue.
func NormalizeExtension ¶
NormalizeExtension maps a file name onto the allowlist. The mapping happens here rather than at the call site so that no caller is ever holding a value it might forget to map.
func NormalizeLanguage ¶
NormalizeLanguage maps a kernelspec name onto the language allowlist. Kernelspec names are user-controlled — a conda environment is named by whoever made it — so an unrecognised one has to collapse to "other" rather than travel.
func ResetTrackingId ¶
func ResetTrackingId() error
ResetTrackingId throws the current id away and starts a new one, so a user can break the link between what they have already sent and what they send next.
func SetEnabled ¶
func SetEnabled(on bool)
SetEnabled applies the settings-panel toggle. Turning it on connects the client if this is the first time in this run; turning it off stops the sending without tearing the client down, so it can be turned back on without another handshake.
func SetUpPostHogClient ¶
func SetUpPostHogClient() error
SetUpPostHogClient connects the client and fixes the properties that ride on every event. It is only called when tracking is on; nothing else in this package works until it has run.
func TelemetryHandler ¶
func TelemetryHandler(w http.ResponseWriter, req *http.Request)
TelemetryHandler takes events the server cannot observe for itself — which tab was opened, which command was run — and puts them through the same catalogue as everything else. The frontend is not trusted here: it names an event and some properties, and events.go decides whether that is a thing Zasper sends.
func TelemetrySettingsHandler ¶
func TelemetrySettingsHandler(w http.ResponseWriter, req *http.Request)
TelemetrySettingsHandler reports whether tracking is on and whether the user has ever been asked.
func TelemetrySettingsModifyHandler ¶
func TelemetrySettingsModifyHandler(w http.ResponseWriter, req *http.Request)
TelemetrySettingsModifyHandler applies a change from the settings panel: turning tracking off, or throwing the anonymous id away and starting a new one.
func Track ¶
Track sends one event, if and only if the catalogue in events.go permits every part of it. A rejected event is logged and dropped whole — never trimmed and sent, which would hide the bug that produced it while still putting something on the wire.
Types ¶
type EventType ¶
type EventType string
const ( EventServerStarted EventType = "server_started" EventServerShutdown EventType = "server_shutdown" EventNotebookOpened EventType = "notebook_opened" EventFileOpened EventType = "file_opened" EventCodeCellExecuted EventType = "code_cell_executed" EventKernelStarted EventType = "kernel_started" EventKernelInterrupted EventType = "kernel_interrupted" EventKernelStartFailed EventType = "kernel_start_failed" EventTerminalOpened EventType = "terminal_opened" EventTerminalClosed EventType = "terminal_closed" EventCommandExecuted EventType = "command_executed" EventGitOperation EventType = "git_operation" EventThemeChanged EventType = "theme_changed" )