@tanagram/cli 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/metrics/metrics.go +25 -9
- package/package.json +1 -1
package/metrics/metrics.go
CHANGED
|
@@ -2,6 +2,7 @@ package metrics
|
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
4
|
"os"
|
|
5
|
+
"os/user"
|
|
5
6
|
"runtime"
|
|
6
7
|
"time"
|
|
7
8
|
|
|
@@ -77,10 +78,12 @@ func Track(event string, properties map[string]interface{}) {
|
|
|
77
78
|
|
|
78
79
|
// Add context dimensions similar to MetricsService
|
|
79
80
|
properties["$process_person_profile"] = false // Match Python implementation
|
|
80
|
-
properties["_deployment_env"] = getDeploymentEnv()
|
|
81
81
|
properties["os"] = runtime.GOOS
|
|
82
82
|
properties["arch"] = runtime.GOARCH
|
|
83
83
|
properties["cli_version"] = getVersion()
|
|
84
|
+
properties["os_user"] = getUser()
|
|
85
|
+
properties["hostname"] = getHostname()
|
|
86
|
+
properties["cwd"] = getCwd()
|
|
84
87
|
|
|
85
88
|
// Build properties - include all custom properties from the caller
|
|
86
89
|
props := posthog.NewProperties()
|
|
@@ -104,21 +107,34 @@ func Track(event string, properties map[string]interface{}) {
|
|
|
104
107
|
// getDistinctId returns a stable anonymous identifier
|
|
105
108
|
// Similar to user_id_for_github_dot_com() pattern
|
|
106
109
|
func getDistinctId() string {
|
|
107
|
-
|
|
110
|
+
return "cli_" + getHostname()
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// getHostname returns the computer's hostname
|
|
114
|
+
func getHostname() string {
|
|
108
115
|
hostname, err := os.Hostname()
|
|
109
116
|
if err != nil {
|
|
110
117
|
return "unknown"
|
|
111
118
|
}
|
|
112
|
-
return
|
|
119
|
+
return hostname
|
|
113
120
|
}
|
|
114
121
|
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if
|
|
119
|
-
return
|
|
122
|
+
// getUser returns the current OS user's login name
|
|
123
|
+
func getUser() string {
|
|
124
|
+
u, err := user.Current()
|
|
125
|
+
if err != nil {
|
|
126
|
+
return "unknown"
|
|
127
|
+
}
|
|
128
|
+
return u.Username
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// getCwd returns the current working directory
|
|
132
|
+
func getCwd() string {
|
|
133
|
+
cwd, err := os.Getwd()
|
|
134
|
+
if err != nil {
|
|
135
|
+
return "unknown"
|
|
120
136
|
}
|
|
121
|
-
return
|
|
137
|
+
return cwd
|
|
122
138
|
}
|
|
123
139
|
|
|
124
140
|
// getVersion returns the CLI version
|