Documentation
¶
Index ¶
- Constants
- func TelemetryOptedOut(optoutVar string) bool
- func WithEventMetadata(ctx context.Context, metadata *CLIAnalyticsEventMetadata) context.Context
- func WithTelemetryClient(ctx context.Context, client TelemetryClient) context.Context
- type AnalyticsTelemetryClient
- type CLIAnalyticsEventMetadata
- type Client
- type NoOpTelemetryClient
- type TelemetryClient
Constants ¶
const DefaultAPIBaseURL = "https://api.stripe.com"
DefaultAPIBaseURL is the default base URL for API requests
const DefaultDashboardBaseURL = "https://dashboard.stripe.com"
DefaultDashboardBaseURL is the default base URL for dashboard requests
const DefaultTelemetryEndpoint = "https://r.stripe.com/0"
DefaultTelemetryEndpoint is the default URL for the telemetry destination
Variables ¶
This section is empty.
Functions ¶
func TelemetryOptedOut ¶ added in v1.7.4
TelemetryOptedOut returns true if the user has opted out of telemetry, false otherwise.
func WithEventMetadata ¶ added in v1.7.4
func WithEventMetadata(ctx context.Context, metadata *CLIAnalyticsEventMetadata) context.Context
WithEventMetadata returns a new copy of context.Context with the provided CLIAnalyticsEventMetadata
func WithTelemetryClient ¶ added in v1.7.4
func WithTelemetryClient(ctx context.Context, client TelemetryClient) context.Context
WithTelemetryClient returns a new copy of context.Context with the provided telemetryClient
Types ¶
type AnalyticsTelemetryClient ¶ added in v1.7.4
type AnalyticsTelemetryClient struct {
BaseURL *url.URL
HTTPClient *http.Client
// contains filtered or unexported fields
}
AnalyticsTelemetryClient sends event information to r.stripe.com
func (*AnalyticsTelemetryClient) SendAPIRequestEvent ¶ added in v1.7.4
func (a *AnalyticsTelemetryClient) SendAPIRequestEvent(ctx context.Context, requestID string, livemode bool) (*http.Response, error)
SendAPIRequestEvent is a special function for API requests
func (*AnalyticsTelemetryClient) SendEvent ¶ added in v1.7.4
func (a *AnalyticsTelemetryClient) SendEvent(ctx context.Context, eventName string, eventValue string)
SendEvent sends a telemetry event to r.stripe.com
func (*AnalyticsTelemetryClient) Wait ¶ added in v1.7.4
func (a *AnalyticsTelemetryClient) Wait()
Wait will return when all in-flight telemetry requests are complete.
type CLIAnalyticsEventMetadata ¶ added in v1.7.4
type CLIAnalyticsEventMetadata struct {
InvocationID string `url:"invocation_id"` // The invocation id is unique to each context object and represents all events coming from one command / gRPC method call
UserAgent string `url:"user_agent"` // the application that is used to create this request
CommandPath string `url:"command_path"` // the command or gRPC method that initiated this request
Merchant string `url:"merchant"` // the merchant ID: ex. acct_xxxx
CLIVersion string `url:"cli_version"` // the version of the CLI
OS string `url:"os"` // the OS of the system
GeneratedResource bool `url:"generated_resource"` // whether or not this was a generated resource
}
CLIAnalyticsEventMetadata is the structure that holds telemetry data context that is ultimately sent to the Stripe Analytics Service.
func GetEventMetadata ¶ added in v1.7.4
func GetEventMetadata(ctx context.Context) *CLIAnalyticsEventMetadata
GetEventMetadata returns the CLIAnalyticsEventMetadata from the provided context
func NewEventMetadata ¶ added in v1.7.4
func NewEventMetadata() *CLIAnalyticsEventMetadata
NewEventMetadata initializes an instance of CLIAnalyticsEventContext
func (*CLIAnalyticsEventMetadata) SetCobraCommandContext ¶ added in v1.7.4
func (e *CLIAnalyticsEventMetadata) SetCobraCommandContext(cmd *cobra.Command)
SetCobraCommandContext sets the telemetry values for the command being executed.
func (*CLIAnalyticsEventMetadata) SetCommandPath ¶ added in v1.7.4
func (e *CLIAnalyticsEventMetadata) SetCommandPath(commandPath string)
SetCommandPath sets the commandPath on the CLIAnalyticsEventContext object
func (*CLIAnalyticsEventMetadata) SetMerchant ¶ added in v1.7.4
func (e *CLIAnalyticsEventMetadata) SetMerchant(merchant string)
SetMerchant sets the merchant on the CLIAnalyticsEventContext object
func (*CLIAnalyticsEventMetadata) SetUserAgent ¶ added in v1.7.4
func (e *CLIAnalyticsEventMetadata) SetUserAgent(userAgent string)
SetUserAgent sets the userAgent on the CLIAnalyticsEventContext object
type Client ¶
type Client struct {
// The base URL (protocol + hostname) used for all requests sent by this
// client.
BaseURL *url.URL
// API key used to authenticate requests sent by this client. If left
// empty, the `Authorization` header will be omitted.
APIKey string
// When this is enabled, request and response headers will be printed to
// stdout.
Verbose bool
// contains filtered or unexported fields
}
Client is the API client used to sent requests to Stripe.
type NoOpTelemetryClient ¶ added in v1.7.4
type NoOpTelemetryClient struct {
}
NoOpTelemetryClient does not call any endpoint and returns an empty response
func (*NoOpTelemetryClient) SendAPIRequestEvent ¶ added in v1.7.4
func (a *NoOpTelemetryClient) SendAPIRequestEvent(ctx context.Context, requestID string, livemode bool) (*http.Response, error)
SendAPIRequestEvent does nothing
type TelemetryClient ¶ added in v1.7.4
type TelemetryClient interface {
SendAPIRequestEvent(ctx context.Context, requestID string, livemode bool) (*http.Response, error)
SendEvent(ctx context.Context, eventName string, eventValue string)
}
TelemetryClient is an interface that can send two types of events: an API request, and just general events.
func GetTelemetryClient ¶ added in v1.7.4
func GetTelemetryClient(ctx context.Context) TelemetryClient
GetTelemetryClient returns the CLIAnalyticsEventMetadata from the provided context