Documentation
¶
Index ¶
- Constants
- Variables
- func SendEvent(payloadJSON string)
- func TrackCheckpointPolicyBlocked(event CheckpointPolicyBlockedEvent, version string)
- func TrackCommandDetached(cmd *cobra.Command, agent string, isEntireEnabled bool, version string)
- func TrackPluginDetached(pluginName string, isEntireEnabled bool, version string)
- type CheckpointPolicyBlockedEvent
- type EventPayload
- func BuildCheckpointPolicyBlockedPayload(event CheckpointPolicyBlockedEvent, version string) *EventPayload
- func BuildEventPayload(cmd *cobra.Command, agent string, isEntireEnabled bool, version string) *EventPayload
- func BuildPluginEventPayload(pluginName string, isEntireEnabled bool, version string) *EventPayload
Constants ¶
const ( PolicyBlockedHookTypeGit = "git" PolicyBlockedHookTypeAgent = "agent" PolicyBlockedReasonUnsupported = "policy_unsupported" PolicyBlockedReasonUnreadable = "policy_unreadable" PolicyBlockedOutcomeSkipped = "skipped" PolicyBlockedOutcomeBlocked = "blocked" )
Property values for the checkpoint_policy_blocked event.
Variables ¶
var ( // PostHogAPIKey is set at build time for production PostHogAPIKey = "phc_development_key" // PostHogEndpoint is set at build time for production PostHogEndpoint = "https://eu.i.posthog.com" )
Functions ¶
func SendEvent ¶
func SendEvent(payloadJSON string)
SendEvent processes an event payload in the detached subprocess. This is called by the hidden __send_analytics command.
func TrackCheckpointPolicyBlocked ¶ added in v0.8.0
func TrackCheckpointPolicyBlocked(event CheckpointPolicyBlockedEvent, version string)
TrackCheckpointPolicyBlocked sends a checkpoint_policy_blocked event by spawning a detached subprocess. Best-effort and non-blocking; callers are responsible for the settings.Telemetry opt-in check. Honors ENTIRE_TELEMETRY_OPTOUT like the other trackers.
func TrackCommandDetached ¶
TrackCommandDetached tracks a command execution by spawning a detached subprocess. This returns immediately without blocking the CLI.
func TrackPluginDetached ¶ added in v0.6.1
TrackPluginDetached records a plugin invocation. Call sites must gate on the plugin allowlist — this function does no name filtering itself.
Types ¶
type CheckpointPolicyBlockedEvent ¶ added in v0.8.0
type CheckpointPolicyBlockedEvent struct {
Hook string
HookType string
Reason string
Outcome string
Agent string
CheckpointVersion string
CheckpointMinVersion string
}
CheckpointPolicyBlockedEvent carries the gate-derived fields for a checkpoint_policy_blocked telemetry event. Agent, CheckpointVersion, and CheckpointMinVersion are optional and omitted from the payload when empty.
type EventPayload ¶
type EventPayload struct {
Event string `json:"event"`
DistinctID string `json:"distinct_id"`
Properties map[string]any `json:"properties"`
Timestamp time.Time `json:"timestamp"`
}
EventPayload represents the data passed to the detached subprocess. Note: APIKey and Endpoint are intentionally excluded to avoid exposing them in process listings (ps/top). SendEvent reads them from package-level vars.
func BuildCheckpointPolicyBlockedPayload ¶ added in v0.8.0
func BuildCheckpointPolicyBlockedPayload(event CheckpointPolicyBlockedEvent, version string) *EventPayload
BuildCheckpointPolicyBlockedPayload constructs the event payload. Exported for testing. Returns nil if the machine ID cannot be resolved.
func BuildEventPayload ¶
func BuildEventPayload(cmd *cobra.Command, agent string, isEntireEnabled bool, version string) *EventPayload
BuildEventPayload constructs the event payload for tracking. Exported for testing. Returns nil if the payload cannot be built.
func BuildPluginEventPayload ¶ added in v0.6.1
func BuildPluginEventPayload(pluginName string, isEntireEnabled bool, version string) *EventPayload
BuildPluginEventPayload deliberately omits plugin args/flags — only the allowlisted plugin name is recorded. Returns nil on failure.