forked from madcitymultimediap2-wordpress-com/stripe-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
32 lines (26 loc) · 826 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import (
"context"
"net/http"
"os"
"time"
"github.com/stripe/stripe-cli/pkg/cmd"
"github.com/stripe/stripe-cli/pkg/stripe"
)
func main() {
ctx := context.Background()
if stripe.TelemetryOptedOut(os.Getenv("STRIPE_CLI_TELEMETRY_OPTOUT")) || stripe.TelemetryOptedOut(os.Getenv("DO_NOT_TRACK")) {
// Proceed without the telemetry client if client opted out.
cmd.Execute(ctx)
} else {
// Set up the telemetry client and add it to the context
httpClient := &http.Client{
Timeout: time.Second * 3,
}
telemetryClient := &stripe.AnalyticsTelemetryClient{HTTPClient: httpClient}
contextWithTelemetry := stripe.WithTelemetryClient(ctx, telemetryClient)
cmd.Execute(contextWithTelemetry)
// Wait for all telemetry calls to finish before existing the process
telemetryClient.Wait()
}
}