@tanagram/cli 0.1.32 → 0.1.33

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/install.js CHANGED
@@ -79,15 +79,8 @@ function buildBinary(goCommand) {
79
79
 
80
80
  console.log('🔧 Building Tanagram CLI...');
81
81
 
82
- // Build ldflags to inject PostHog key at build time
83
- let ldflags = '';
84
- if (process.env.POSTHOG_WRITE_KEY) {
85
- ldflags = `-ldflags="-X 'github.com/tanagram/cli/metrics.posthogWriteKey=${process.env.POSTHOG_WRITE_KEY}'"`;
86
- console.log(' 📊 Injecting PostHog metrics key...');
87
- }
88
-
89
82
  try {
90
- execSync(`"${goCommand}" build ${ldflags} -o "${binaryPath}" .`, {
83
+ execSync(`"${goCommand}" build -o "${binaryPath}" .`, {
91
84
  cwd: __dirname,
92
85
  stdio: 'inherit',
93
86
  env: {
package/main.go CHANGED
@@ -10,9 +10,18 @@ import (
10
10
  )
11
11
 
12
12
  func main() {
13
- // Initialize metrics (similar to PosthogService initialization)
14
13
  metrics.Init()
15
- defer metrics.Close()
14
+
15
+ exitCode := 0
16
+ defer func() {
17
+ metrics.Track("cli.exit", map[string]interface{}{
18
+ "exit_code": exitCode,
19
+ })
20
+ metrics.Close()
21
+ // os.Exit immediately exits without calling other `defer`s, so we need to group these two statements
22
+ // and call them in the right order.
23
+ os.Exit(exitCode)
24
+ }()
16
25
 
17
26
  // Get subcommand (default to "run" if none provided)
18
27
  subcommand := "run"
@@ -20,20 +29,24 @@ func main() {
20
29
  subcommand = os.Args[1]
21
30
  }
22
31
 
32
+ metrics.Track("cli.start", map[string]interface{}{
33
+ "subcommand": subcommand,
34
+ })
35
+
23
36
  var err error
24
37
  switch subcommand {
25
38
  case "run":
26
- metrics.Track("command.execute", map[string]interface{}{
39
+ metrics.Track("cli.command.execute", map[string]interface{}{
27
40
  "command": "run",
28
41
  })
29
42
  err = commands.Run()
30
43
  case "sync":
31
- metrics.Track("command.execute", map[string]interface{}{
44
+ metrics.Track("cli.command.execute", map[string]interface{}{
32
45
  "command": "sync",
33
46
  })
34
47
  err = commands.Sync()
35
48
  case "list":
36
- metrics.Track("command.execute", map[string]interface{}{
49
+ metrics.Track("cli.command.execute", map[string]interface{}{
37
50
  "command": "list",
38
51
  })
39
52
  err = commands.List()
@@ -44,32 +57,35 @@ func main() {
44
57
  fmt.Fprintf(os.Stderr, "\nAvailable subcommands:\n")
45
58
  fmt.Fprintf(os.Stderr, " claude Setup Claude Code hook\n")
46
59
  fmt.Fprintf(os.Stderr, " list Show hook installation status\n")
47
- os.Exit(1)
60
+ exitCode = 1
61
+ return
48
62
  }
49
63
  subCmd := os.Args[2]
50
64
  switch subCmd {
51
65
  case "claude":
52
- metrics.Track("command.execute", map[string]interface{}{
66
+ metrics.Track("cli.command.execute", map[string]interface{}{
53
67
  "command": "config.claude",
54
68
  })
55
69
  err = commands.ConfigClaude()
56
70
  case "list":
57
- metrics.Track("command.execute", map[string]interface{}{
71
+ metrics.Track("cli.command.execute", map[string]interface{}{
58
72
  "command": "config.list",
59
73
  })
60
74
  err = commands.ConfigList()
61
75
  default:
62
76
  fmt.Fprintf(os.Stderr, "Unknown config subcommand: %s\n", subCmd)
63
- os.Exit(1)
77
+ exitCode = 1
78
+ return
64
79
  }
65
80
  case "welcome":
66
- metrics.Track("command.execute", map[string]interface{}{
81
+ metrics.Track("cli.command.execute", map[string]interface{}{
67
82
  "command": "welcome",
68
83
  })
69
84
  choice, err := tui.RunWelcomeScreen()
70
85
  if err != nil {
71
86
  fmt.Fprintf(os.Stderr, "Error: %v\n", err)
72
- os.Exit(1)
87
+ exitCode = 1
88
+ return
73
89
  }
74
90
  switch choice {
75
91
  case tui.ChoiceImportPolicies:
@@ -83,13 +99,14 @@ func main() {
83
99
  }
84
100
  return
85
101
  case "puzzle":
86
- metrics.Track("command.execute", map[string]interface{}{
102
+ metrics.Track("cli.command.execute", map[string]interface{}{
87
103
  "command": "puzzle",
88
104
  })
89
105
  err := tui.RunPuzzleEditor()
90
106
  if err != nil {
91
107
  fmt.Fprintf(os.Stderr, "Error: %v\n", err)
92
- os.Exit(1)
108
+ exitCode = 1
109
+ return
93
110
  }
94
111
  return
95
112
  case "help", "-h", "--help":
@@ -98,16 +115,18 @@ func main() {
98
115
  default:
99
116
  fmt.Fprintf(os.Stderr, "Unknown command: %s\n\n", subcommand)
100
117
  printHelp()
101
- os.Exit(1)
118
+ exitCode = 1
119
+ return
102
120
  }
103
121
 
104
122
  if err != nil {
105
- metrics.Track("command.error", map[string]interface{}{
123
+ metrics.Track("cli.command.error", map[string]interface{}{
106
124
  "command": subcommand,
107
125
  "error": err.Error(),
108
126
  })
109
127
  fmt.Fprintf(os.Stderr, "Error: %v\n", err)
110
- os.Exit(1)
128
+ exitCode = 1
129
+ return
111
130
  }
112
131
  }
113
132
 
@@ -12,7 +12,7 @@ var (
12
12
  client posthog.Client
13
13
 
14
14
  // Injected at build time via -ldflags
15
- posthogWriteKey = ""
15
+ posthogWriteKey = "phc_sMsUvf0nK50rZdztSlX9rDJqIreLcXj4dyGS0tORQpQ"
16
16
  posthogHost = "https://us.i.posthog.com"
17
17
  )
18
18
 
@@ -76,10 +76,16 @@ func Track(event string, properties map[string]interface{}) {
76
76
  properties["arch"] = runtime.GOARCH
77
77
  properties["cli_version"] = getVersion()
78
78
 
79
+ // Build properties - include all custom properties from the caller
80
+ props := posthog.NewProperties()
81
+ for key, value := range properties {
82
+ props.Set(key, value)
83
+ }
84
+
79
85
  err := client.Enqueue(posthog.Capture{
80
86
  DistinctId: getDistinctId(),
81
87
  Event: event,
82
- Properties: properties,
88
+ Properties: props,
83
89
  Timestamp: time.Now(),
84
90
  })
85
91
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanagram/cli",
3
- "version": "0.1.32",
3
+ "version": "0.1.33",
4
4
  "description": "Tanagram - Catch sloppy code before it ships",
5
5
  "main": "index.js",
6
6
  "bin": {