Versions in this module Expand all Collapse all v0 v0.7.0 May 10, 2026 Changes in this version + const HeaderRequestID + const HeaderSessionID + const HeaderUserID + var ErrClientClosed = errors.New("productgraph: client is closed") + var ErrMissingEndpoint = errors.New("productgraph: missing endpoint") + var ErrMissingProjectID = errors.New("productgraph: missing project_id") + func ChainMiddleware(client *Client) func(http.Handler) http.Handler + func CorrelationMiddleware(next http.Handler) http.Handler + func RequestIDFromContext(ctx context.Context) string + func RequestTrackerMiddleware(client *Client) func(http.Handler) http.Handler + func SessionIDFromContext(ctx context.Context) string + func UserIDFromContext(ctx context.Context) string + func WithRequestID(ctx context.Context, requestID string) context.Context + func WithSessionID(ctx context.Context, sessionID string) context.Context + func WithUserID(ctx context.Context, userID string) context.Context + type Client struct + func MustNew(cfg Config) *Client + func New(cfg Config) (*Client, error) + func (c *Client) Close() error + func (c *Client) Config() Config + func (c *Client) Flush(ctx context.Context) error + func (c *Client) IsEnabled() bool + func (c *Client) SetLogger(logger *slog.Logger) + func (c *Client) Track(ctx context.Context, event Event) error + func (c *Client) TrackAPICall(ctx context.Context, method, path string, statusCode int, ...) error + func (c *Client) TrackError(ctx context.Context, errType, message string) error + func (c *Client) TrackJourneyStep(ctx context.Context, journeyID, stepID, stepName string) error + type Config struct + APIKey string + BatchInterval time.Duration + BatchSize int + Debug bool + Endpoint string + HTTPClient *http.Client + ProjectID string + func ConfigFromEnv() Config + func (c Config) IsEnabled() bool + func (c Config) Validate() error + func (c Config) WithDefaults() Config + type ContextKey string + const RequestIDKey + const SessionIDKey + const UserIDKey + type Event struct + APIDurationMs int + APIMethod string + APIPath string + APIStatusCode int + DurationMs int + ErrorMessage string + ErrorStack string + ErrorType string + EventID string + EventName string + EventType EventType + JourneyID string + JourneyName string + JourneyStep string + Metadata map[string]any + OrgID string + OrgName string + PagePath string + PageReferrer string + PageTitle string + PageURL string + ProjectID string + Sequence int + SessionID string + Timestamp string + UIAction string + UIComponentName string + UIComponentPath string + UIComponentType string + UIElement string + UIElementText string + UIStateAfter string + UIStateBefore string + UIStateKey string + UserID string + func APIResponseEvent(method, path string, statusCode int, durationMs int) Event + func ErrorEvent(errType, message string) Event + func JourneyStepEvent(journeyID, stepID, stepName string) Event + func NewEvent(eventType EventType) Event + type EventType string + const EventTypeAPIRequest + const EventTypeAPIResponse + const EventTypeCustom + const EventTypeError + const EventTypeJourneyStep + const EventTypePageLeave + const EventTypePageView + const EventTypePerformance + const EventTypeStateChange + const EventTypeUIBlur + const EventTypeUIClick + const EventTypeUIFocus + const EventTypeUIInput + const EventTypeUIScroll + const EventTypeUISubmit + type Payload struct + Events []Event + type PayloadError struct + Error string + Index int + type Response struct + Accepted int + Errors []PayloadError + Rejected int