analytics

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bucket

func Bucket(n int) string

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

func GetAnonymousTrackingId() (string, error)

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

func KnownEvent(event EventType) bool

KnownEvent reports whether an event name is in the catalogue.

func NormalizeExtension

func NormalizeExtension(name string) string

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

func NormalizeLanguage(kernelName string) string

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

func Track(event EventType, props map[string]interface{})

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.

func TrackServerStart

func TrackServerStart()

TrackServerStart records the start of a session.

func Validate

func Validate(event EventType, props map[string]interface{}) error

Validate checks an event against the catalogue. It rejects rather than sanitises: a property that does not fit is a bug or an attempt to smuggle something out, and quietly dropping the key would hide both while still sending the event.

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"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL