Documentation
¶
Overview ¶
Package ingest owns the AI-agent telemetry upload path: the stricter enterprise-config gate (this file) and the HTTP client that POSTs events to /v1/{customer_id}/ai-agents/events.
The stricter gate exists because DMG's `config.IsEnterpriseMode()` checks only APIKey — that's the right call for the scan/telemetry paths, but it's too lax for the hook upload path. A missing CustomerID or APIEndpoint here would silently misroute uploads, so we require all three credentials to be present and not bearing build-time `{{...}}` placeholders.
Index ¶
Constants ¶
const DefaultHookUploadTimeout = 5 * time.Second
DefaultHookUploadTimeout caps how long the hot path will wait on the backend per hook invocation. Each hook is a fresh process, so every upload pays a cold TCP+TLS handshake; tighter caps proved fragile under load. Past this, the right answer is an async sidecar approach, not a bigger sync timeout.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client posts events to a single configured endpoint. Safe to share across goroutines; the underlying *http.Client carries connection state.
func New ¶
New returns a client when the supplied Config has all enterprise credentials present and non-placeholder. The bool is false when no upload should be attempted; callers MUST treat that as a no-op rather than an error. The gate matches Snapshot's: trims surrounding whitespace, then rejects empty values and `{{...}}` placeholders. New owns the gate so a caller passing a hand-built Config (not the product of Snapshot) cannot bypass it.
func (*Client) UploadEvents ¶
UploadEvents POSTs events to /v1/{customer_id}/ai-agents/events as a raw JSON array. Each event already carries its own schema_version, identity, and policy fields, so no envelope wraps the array — the backend reads the indexed columns directly from each event.
Statuses 200, 201, 202, and 409 are treated as success. 409 is success because backend ingestion is idempotent on (device_id, event_id); duplicate retries must not become client errors.
type Config ¶
Config is a snapshot of the three credentials required to upload AI-agent events. All fields are TrimSpace'd at read time.
func Snapshot ¶
Snapshot reads the current process-wide DMG config (populated by an earlier call to config.Load) and returns it alongside an "enterprise ready" bool. The bool is true iff every field is non-empty after trimming AND none contain the build-time placeholder marker `{{`.
Env-var overrides (DMG_CUSTOMER_ID, DMG_API_ENDPOINT, DMG_API_KEY) take precedence over the config file when set and non-empty. They exist for local dev where an MDM agent may revert the on-disk file.
The returned Config is always populated for diagnostics — callers should NOT use its values when ok is false.