Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

add post hog api to go releaser and update cli telemetry

Maidul Islam4586656b856f
diff --git a/.github/workflows/release_build.yml b/.github/workflows/release_build.yml
index f728d52bd9..9840e2d3e4 100644
--- a/.github/workflows/release_build.yml
+++ b/.github/workflows/release_build.yml
@@ -46,6 +46,7 @@ jobs:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GO_RELEASER_GITHUB_TOKEN }}
+ POSTHOG_API_KEY_FOR_CLI: ${{ secrets.POSTHOG_API_KEY_FOR_CLI }}
FURY_TOKEN: ${{ secrets.FURYPUSHTOKEN }}
AUR_KEY: ${{ secrets.AUR_KEY }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
diff --git a/.goreleaser.yaml b/.goreleaser.yaml
index 99291bde7e..12fb34dbab 100644
--- a/.goreleaser.yaml
+++ b/.goreleaser.yaml
@@ -15,6 +15,9 @@ monorepo:
tag_prefix: infisical-cli/
dir: cli
+env:
+ - POSTHOG_API_KEY_FOR_CLI={{ .Env.POSTHOG_API_KEY_FOR_CLI }}
+
builds:
- id: darwin-build
binary: infisical
diff --git a/cli/packages/telemetry/telemetry.go b/cli/packages/telemetry/telemetry.go
index 4a6cc69b4c..166b002e17 100644
--- a/cli/packages/telemetry/telemetry.go
+++ b/cli/packages/telemetry/telemetry.go
@@ -14,11 +14,17 @@ type Telemetry struct {
}
func NewTelemetry(telemetryIsEnabled bool) *Telemetry {
- client, _ := posthog.NewWithConfig(
- os.Getenv("POSTHOG_API_KEY_FOR_CLI"),
- posthog.Config{},
- )
- return &Telemetry{isEnabled: telemetryIsEnabled, posthogClient: client}
+ posthogAPIKey := os.Getenv("POSTHOG_API_KEY_FOR_CLI")
+ if posthogAPIKey != "" {
+ client, _ := posthog.NewWithConfig(
+ posthogAPIKey,
+ posthog.Config{},
+ )
+
+ return &Telemetry{isEnabled: telemetryIsEnabled, posthogClient: client}
+ } else {
+ return &Telemetry{isEnabled: false}
+ }
}
func (t *Telemetry) CaptureEvent(eventName string, properties posthog.Properties) {
@@ -33,9 +39,9 @@ func (t *Telemetry) CaptureEvent(eventName string, properties posthog.Properties
Event: eventName,
Properties: properties,
})
- }
- defer t.posthogClient.Close()
+ defer t.posthogClient.Close()
+ }
}
func (t *Telemetry) GetDistinctId() (string, error) {
@@ -55,7 +61,7 @@ func (t *Telemetry) GetDistinctId() (string, error) {
if userDetails.IsUserLoggedIn && userDetails.UserCredentials.Email != "" {
distinctId = userDetails.UserCredentials.Email
} else if machineId != "" {
- distinctId = "anonymous_cli" + machineId
+ distinctId = "anonymous_cli_" + machineId
} else {
distinctId = ""
}