Documentation
¶
Index ¶
- Constants
- func TelemetryOptedOut(optoutVar string) bool
- func ValidateAPIBaseURL(apiBaseURL string) error
- func ValidateDashboardBaseURL(dashboardBaseURL string) error
- func WithEventMetadata(ctx context.Context, metadata *CLIAnalyticsEventMetadata) context.Context
- func WithTelemetryClient(ctx context.Context, client TelemetryClient) context.Context
- type AnalyticsTelemetryClient
- type CLIAnalyticsEventMetadata
- func (e *CLIAnalyticsEventMetadata) SetCobraCommandContext(cmd *cobra.Command)
- func (e *CLIAnalyticsEventMetadata) SetCommandFlags(commandFlags string)
- func (e *CLIAnalyticsEventMetadata) SetCommandPath(commandPath string)
- func (e *CLIAnalyticsEventMetadata) SetMerchant(merchant string)
- func (e *CLIAnalyticsEventMetadata) SetUserAgent(userAgent string)
- type Client
- type NoOpTelemetryClient
- type RequestPerformer
- type TelemetryClient
Constants ¶
const ( // DefaultAPIBaseURL is the default base URL for API requests DefaultAPIBaseURL = "https://api.stripe.com" // DefaultFilesAPIBaseURL is the default base URL for Files API requsts DefaultFilesAPIBaseURL = "https://files.stripe.com" // DefaultDashboardBaseURL is the default base URL for dashboard requests DefaultDashboardBaseURL = "https://dashboard.stripe.com" )
const APIVersion = "2019-03-14"
APIVersion is API version used in CLI
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 ValidateAPIBaseURL ¶ added in v1.21.10
ValidateAPIBaseURL returns an error if apiBaseURL isn't allowed
func ValidateDashboardBaseURL ¶ added in v1.21.10
ValidateDashboardBaseURL returns an error if dashboardBaseURL isn't allowed
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 CommandFlags string `url:"command_flags"` // Comma-separated list of flags that were passed to the command (only includes flag names, not their values) 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) SetCommandFlags ¶ added in v1.21.9
func (e *CLIAnalyticsEventMetadata) SetCommandFlags(commandFlags string)
SetCommandFlags sets the flags on the CLIAnalyticsEventContext object
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 // List of request and response headers that should be printed when Verbose is true. // Defaults to the standard set of relevant for Stripe headers. VerbosePrintableHeaders []string // 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 RequestPerformer ¶ added in v1.14.1
type RequestPerformer interface {
PerformRequest(ctx context.Context, method, path string, params string, configure func(*http.Request) error) (*http.Response, error)
}
RequestPerformer is an interface for executing requests against the Stripe API, usually satisfied by providing a stripe.Client.
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