-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathevents.go
More file actions
516 lines (450 loc) · 19.4 KB
/
Copy pathevents.go
File metadata and controls
516 lines (450 loc) · 19.4 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
package telemetry
import (
"runtime"
"strings"
"github.com/asteroid-belt/skulto/pkg/version"
)
// Event names - CLI
const (
EventAppStarted = "app_started"
EventAppExited = "app_exited"
EventCLICommandExecuted = "cli_command_executed"
EventRepoAdded = "repo_added"
EventRepoRemoved = "repo_removed"
EventRepoSynced = "repo_synced"
EventRepoListed = "repo_listed"
EventConfigChanged = "config_changed"
EventCLIErrorOccurred = "cli_error_occurred"
EventCLIHelpViewed = "cli_help_viewed"
EventFavoriteAdded = "favorite_added"
EventFavoriteRemoved = "favorite_removed"
EventFavoritesListed = "favorites_listed"
)
// Event names - TUI
const (
EventViewNavigated = "view_navigated"
EventSkillInstalled = "skill_installed"
EventSkillUninstalled = "skill_uninstalled"
EventNewSkillCreatedSuccess = "new_skill_created_successfully"
EventNewSkillCreatedFailure = "new_skill_created_failure"
EventSearchPerformed = "search_performed"
EventFilterApplied = "filter_applied"
EventSortChanged = "sort_changed"
EventSkillCopied = "skill_copied"
EventOnboardingCompleted = "onboarding_completed"
EventOnboardingSkipped = "onboarding_skipped"
EventSettingsChanged = "settings_changed"
EventKeyboardShortcut = "keyboard_shortcut_used"
EventHelpViewed = "help_viewed"
EventPaginationUsed = "pagination_used"
EventTagBrowsingEntered = "tag_browsing_entered"
EventTagSelected = "tag_selected"
EventErrorDisplayed = "error_displayed"
EventSourceSelected = "source_selected"
EventListRefreshed = "list_refreshed"
)
// Event names - Session
const (
EventSessionSummary = "session_summary"
)
// Event names - Shared (all interfaces should track these)
const (
EventSkillViewed = "skill_viewed" // Unified: replaces skill_info_viewed and skill_previewed
EventSkillsListed = "skills_listed" // List/browse skills
EventStatsViewed = "stats_viewed" // View database stats
EventRecentSkillsViewed = "recent_skills_viewed" // View recent skills
EventInstalledSkillsChecked = "installed_skills_checked" // Check installed skills
)
// Event names - CLI specific
const (
EventSkillsDiscovered = "skills_discovered" // Discover unmanaged skills
EventSkillIngested = "skill_ingested" // Import a discovered skill
)
// Event names - MCP specific
const (
EventMCPToolCalled = "mcp_tool_called" // Track each MCP tool invocation
)
// Event names - Manifest
const (
EventManifestSaved = "manifest_saved"
EventManifestSynced = "manifest_synced"
)
// Version is set at compile time via ldflags.
var Version string
// baseProperties returns common properties for all events.
func baseProperties() map[string]interface{} {
return map[string]interface{}{
"os": runtime.GOOS,
"arch": runtime.GOARCH,
"version": Version,
"prerelease": version.IsPrerelease(),
"dev_build": version.IsDevBuild(),
}
}
// --- CLI Tracking Methods ---
// TrackAppStarted tracks application startup.
func (c *posthogClient) TrackAppStarted(mode string, hasSources bool, sourceCount int) {
props := baseProperties()
props["mode"] = mode
props["has_sources"] = hasSources
props["source_count"] = sourceCount
c.Track(EventAppStarted, props)
}
// TrackAppExited tracks application exit.
func (c *posthogClient) TrackAppExited(mode string, sessionDurationMs int64, commandsRun int) {
props := baseProperties()
props["mode"] = mode
props["session_duration_ms"] = sessionDurationMs
props["commands_run"] = commandsRun
c.Track(EventAppExited, props)
}
// TrackCLICommandExecuted tracks CLI command execution.
func (c *posthogClient) TrackCLICommandExecuted(commandName string, hasFlags bool, durationMs int64) {
props := baseProperties()
props["command_name"] = commandName
props["has_flags"] = hasFlags
props["execution_duration_ms"] = durationMs
c.Track(EventCLICommandExecuted, props)
}
// TrackRepoAdded tracks when a repository is added.
func (c *posthogClient) TrackRepoAdded(sourceID string, skillCount int) {
props := baseProperties()
props["source_id"] = sourceID
props["skill_count"] = skillCount
c.Track(EventRepoAdded, props)
}
// TrackRepoRemoved tracks when a repository is removed.
func (c *posthogClient) TrackRepoRemoved(sourceID string, skillCount int) {
props := baseProperties()
props["source_id"] = sourceID
props["skill_count"] = skillCount
c.Track(EventRepoRemoved, props)
}
// TrackRepoSynced tracks repository sync operations.
func (c *posthogClient) TrackRepoSynced(sourceID string, added, removed, updated int) {
props := baseProperties()
props["source_id"] = sourceID
props["skills_added"] = added
props["skills_removed"] = removed
props["skills_updated"] = updated
c.Track(EventRepoSynced, props)
}
// TrackRepoListed tracks repo list command.
func (c *posthogClient) TrackRepoListed(sourceCount, totalSkillCount int) {
props := baseProperties()
props["source_count"] = sourceCount
props["total_skill_count"] = totalSkillCount
c.Track(EventRepoListed, props)
}
// TrackConfigChanged tracks config changes.
func (c *posthogClient) TrackConfigChanged(settingName string, isDefault bool) {
props := baseProperties()
props["setting_name"] = settingName
props["is_default"] = isDefault
c.Track(EventConfigChanged, props)
}
// TrackCLIError tracks CLI errors.
func (c *posthogClient) TrackCLIError(commandName, errorType string) {
props := baseProperties()
props["command_name"] = commandName
props["error_type"] = errorType
c.Track(EventCLIErrorOccurred, props)
}
// TrackCLIHelpViewed tracks help command usage.
func (c *posthogClient) TrackCLIHelpViewed(commandName string, cliArgs []string) {
props := baseProperties()
props["command_name"] = commandName
props["cli_args"] = strings.Join(cliArgs, " ")
c.Track(EventCLIHelpViewed, props)
}
// TrackFavoriteAdded tracks when a skill is added to favorites.
func (c *posthogClient) TrackFavoriteAdded(slug string) {
props := baseProperties()
props["skill_slug"] = slug
c.Track(EventFavoriteAdded, props)
}
// TrackFavoriteRemoved tracks when a skill is removed from favorites.
func (c *posthogClient) TrackFavoriteRemoved(slug string) {
props := baseProperties()
props["skill_slug"] = slug
c.Track(EventFavoriteRemoved, props)
}
// TrackFavoritesListed tracks when favorites are listed.
func (c *posthogClient) TrackFavoritesListed(count int) {
props := baseProperties()
props["favorites_count"] = count
c.Track(EventFavoritesListed, props)
}
// --- TUI Tracking Methods ---
// TrackViewNavigated tracks view navigation.
func (c *posthogClient) TrackViewNavigated(viewName, previousView string) {
props := baseProperties()
props["view_name"] = viewName
props["previous_view"] = previousView
c.Track(EventViewNavigated, props)
}
// TrackSkillInstalled tracks skill installation.
func (c *posthogClient) TrackSkillInstalled(skillName, category string, isLocal bool, platformCount int) {
props := baseProperties()
props["skill_name"] = skillName
props["skill_category"] = category
props["is_local"] = isLocal
props["platform_count"] = platformCount
c.Track(EventSkillInstalled, props)
}
// TrackSkillUninstalled tracks skill uninstallation.
func (c *posthogClient) TrackSkillUninstalled(skillName, category string, isLocal bool) {
props := baseProperties()
props["skill_name"] = skillName
props["skill_category"] = category
props["is_local"] = isLocal
c.Track(EventSkillUninstalled, props)
}
// TrackNewSkillCreatedSuccess tracks successful skill creation.
func (c *posthogClient) TrackNewSkillCreatedSuccess(skillName string) {
props := baseProperties()
props["skill_name"] = skillName
c.Track(EventNewSkillCreatedSuccess, props)
}
// TrackNewSkillCreatedFailure tracks unsuccessful skill creation.
func (c *posthogClient) TrackNewSkillCreatedFailure(errorMessage string) {
props := baseProperties()
props["reason"] = errorMessage
c.Track(EventNewSkillCreatedFailure, props)
}
// TrackSearchPerformed tracks search operations.
func (c *posthogClient) TrackSearchPerformed(query string, resultCount int, searchType string) {
props := baseProperties()
props["query"] = query
props["query_length"] = len(query)
props["result_count"] = resultCount
props["search_type"] = searchType
c.Track(EventSearchPerformed, props)
}
// TrackFilterApplied tracks filter application.
func (c *posthogClient) TrackFilterApplied(filterType string, filterCount int) {
props := baseProperties()
props["filter_type"] = filterType
props["filter_count"] = filterCount
c.Track(EventFilterApplied, props)
}
// TrackSortChanged tracks sort changes.
func (c *posthogClient) TrackSortChanged(sortField, sortDirection string) {
props := baseProperties()
props["sort_field"] = sortField
props["sort_direction"] = sortDirection
c.Track(EventSortChanged, props)
}
// TrackSkillCopied tracks clipboard copy.
func (c *posthogClient) TrackSkillCopied(skillName string) {
props := baseProperties()
props["skill_name"] = skillName
c.Track(EventSkillCopied, props)
}
// TrackOnboardingCompleted tracks onboarding completion.
func (c *posthogClient) TrackOnboardingCompleted(stepsViewed int, skipped bool) {
props := baseProperties()
props["steps_viewed"] = stepsViewed
props["skipped"] = skipped
c.Track(EventOnboardingCompleted, props)
}
// TrackOnboardingSkipped tracks onboarding skip.
func (c *posthogClient) TrackOnboardingSkipped(stepName string) {
props := baseProperties()
props["step_name"] = stepName
c.Track(EventOnboardingSkipped, props)
}
// TrackSettingsChanged tracks settings changes.
func (c *posthogClient) TrackSettingsChanged(settingName string) {
props := baseProperties()
props["setting_name"] = settingName
c.Track(EventSettingsChanged, props)
}
// TrackKeyboardShortcut tracks keyboard shortcut usage.
func (c *posthogClient) TrackKeyboardShortcut(shortcutKey, contextView string) {
props := baseProperties()
props["shortcut_key"] = shortcutKey
props["context_view"] = contextView
c.Track(EventKeyboardShortcut, props)
}
// TrackHelpViewed tracks help modal views.
func (c *posthogClient) TrackHelpViewed(contextView string) {
props := baseProperties()
props["context_view"] = contextView
c.Track(EventHelpViewed, props)
}
// TrackPaginationUsed tracks pagination navigation.
func (c *posthogClient) TrackPaginationUsed(direction string, pageNumber int) {
props := baseProperties()
props["direction"] = direction
props["page_number"] = pageNumber
c.Track(EventPaginationUsed, props)
}
// TrackTagBrowsingEntered tracks tag browsing mode entry.
func (c *posthogClient) TrackTagBrowsingEntered(tagCount int) {
props := baseProperties()
props["tag_count"] = tagCount
c.Track(EventTagBrowsingEntered, props)
}
// TrackTagSelected tracks tag selection.
func (c *posthogClient) TrackTagSelected(tagName string) {
props := baseProperties()
props["tag_name"] = tagName
c.Track(EventTagSelected, props)
}
// TrackErrorDisplayed tracks error display.
func (c *posthogClient) TrackErrorDisplayed(errorType, contextView string) {
props := baseProperties()
props["error_type"] = errorType
props["context_view"] = contextView
c.Track(EventErrorDisplayed, props)
}
// TrackSourceSelected tracks source selection.
func (c *posthogClient) TrackSourceSelected(sourceIndex, skillCount int) {
props := baseProperties()
props["source_index"] = sourceIndex
props["skill_count"] = skillCount
c.Track(EventSourceSelected, props)
}
// TrackListRefreshed tracks list refresh.
func (c *posthogClient) TrackListRefreshed(trigger string, skillCount int) {
props := baseProperties()
props["trigger"] = trigger
props["skill_count"] = skillCount
c.Track(EventListRefreshed, props)
}
// --- Session Tracking Methods ---
// TrackSessionSummary tracks session summary on exit.
func (c *posthogClient) TrackSessionSummary(durationMs int64, viewsVisited, searchesPerformed, skillsInstalled, skillsUninstalled, reposAdded, reposRemoved int) {
props := baseProperties()
props["duration_ms"] = durationMs
props["views_visited"] = viewsVisited
props["searches_performed"] = searchesPerformed
props["skills_installed"] = skillsInstalled
props["skills_uninstalled"] = skillsUninstalled
props["repos_added"] = reposAdded
props["repos_removed"] = reposRemoved
c.Track(EventSessionSummary, props)
}
// --- noopClient implementations (no-ops) ---
func (c *noopClient) TrackAppStarted(mode string, hasSources bool, sourceCount int) {}
func (c *noopClient) TrackAppExited(mode string, sessionDurationMs int64, commandsRun int) {}
func (c *noopClient) TrackCLICommandExecuted(commandName string, hasFlags bool, durationMs int64) {}
func (c *noopClient) TrackRepoAdded(sourceID string, skillCount int) {}
func (c *noopClient) TrackRepoRemoved(sourceID string, skillCount int) {}
func (c *noopClient) TrackRepoSynced(sourceID string, added, removed, updated int) {}
func (c *noopClient) TrackRepoListed(sourceCount, totalSkillCount int) {}
func (c *noopClient) TrackConfigChanged(settingName string, isDefault bool) {}
func (c *noopClient) TrackCLIError(commandName, errorType string) {}
func (c *noopClient) TrackCLIHelpViewed(commandName string, cliArgs []string) {}
func (c *noopClient) TrackFavoriteAdded(slug string) {}
func (c *noopClient) TrackFavoriteRemoved(slug string) {}
func (c *noopClient) TrackFavoritesListed(count int) {}
func (c *noopClient) TrackViewNavigated(viewName, previousView string) {}
func (c *noopClient) TrackSkillInstalled(skillName, category string, isLocal bool, platformCount int) {
}
func (c *noopClient) TrackSkillUninstalled(skillName, category string, isLocal bool) {}
func (c *noopClient) TrackNewSkillCreatedSuccess(skillName string) {}
func (c *noopClient) TrackNewSkillCreatedFailure(errorMessage string) {}
func (c *noopClient) TrackSearchPerformed(query string, resultCount int, searchType string) {}
func (c *noopClient) TrackFilterApplied(filterType string, filterCount int) {}
func (c *noopClient) TrackSortChanged(sortField, sortDirection string) {}
func (c *noopClient) TrackSkillCopied(skillName string) {}
func (c *noopClient) TrackOnboardingCompleted(stepsViewed int, skipped bool) {}
func (c *noopClient) TrackOnboardingSkipped(stepName string) {}
func (c *noopClient) TrackSettingsChanged(settingName string) {}
func (c *noopClient) TrackKeyboardShortcut(shortcutKey, contextView string) {}
func (c *noopClient) TrackHelpViewed(contextView string) {}
func (c *noopClient) TrackPaginationUsed(direction string, pageNumber int) {}
func (c *noopClient) TrackTagBrowsingEntered(tagCount int) {}
func (c *noopClient) TrackTagSelected(tagName string) {}
func (c *noopClient) TrackErrorDisplayed(errorType, contextView string) {}
func (c *noopClient) TrackSourceSelected(sourceIndex, skillCount int) {}
func (c *noopClient) TrackListRefreshed(trigger string, skillCount int) {}
func (c *noopClient) TrackSessionSummary(durationMs int64, viewsVisited, searchesPerformed, skillsInstalled, skillsUninstalled, reposAdded, reposRemoved int) {
}
// TrackSkillsDiscovered tracks when unmanaged skills are discovered.
func (c *posthogClient) TrackSkillsDiscovered(count int, scopeGlobal, scopeProject bool) {
props := baseProperties()
props["discovered_count"] = count
props["scope_global"] = scopeGlobal
props["scope_project"] = scopeProject
c.Track(EventSkillsDiscovered, props)
}
// TrackSkillIngested tracks when a discovered skill is imported into skulto management.
func (c *posthogClient) TrackSkillIngested(skillName, scope string) {
props := baseProperties()
props["skill_name"] = skillName
props["scope"] = scope
c.Track(EventSkillIngested, props)
}
// --- Shared Tracking Methods (all interfaces) ---
// TrackSkillViewed tracks when a skill's details are viewed.
// Replaces TrackSkillInfoViewed (CLI) and TrackSkillPreviewed (TUI).
func (c *posthogClient) TrackSkillViewed(slug, category string, isLocal bool) {
props := baseProperties()
props["skill_slug"] = slug
props["skill_category"] = category
props["is_local"] = isLocal
c.Track(EventSkillViewed, props)
}
// TrackSkillsListed tracks when skills are listed/browsed.
func (c *posthogClient) TrackSkillsListed(count int, source string) {
props := baseProperties()
props["result_count"] = count
props["source"] = source // "search", "browse", "tag", "mcp"
c.Track(EventSkillsListed, props)
}
// TrackStatsViewed tracks when database stats are viewed.
func (c *posthogClient) TrackStatsViewed() {
props := baseProperties()
c.Track(EventStatsViewed, props)
}
// TrackRecentSkillsViewed tracks when recent skills are viewed.
func (c *posthogClient) TrackRecentSkillsViewed(count int) {
props := baseProperties()
props["result_count"] = count
c.Track(EventRecentSkillsViewed, props)
}
// TrackInstalledSkillsChecked tracks when installed skills are checked.
func (c *posthogClient) TrackInstalledSkillsChecked(count int) {
props := baseProperties()
props["installed_count"] = count
c.Track(EventInstalledSkillsChecked, props)
}
// --- MCP Tracking Methods ---
// TrackMCPToolCalled tracks MCP tool invocations.
func (c *posthogClient) TrackMCPToolCalled(toolName string, durationMs int64, success bool) {
props := baseProperties()
props["tool_name"] = toolName
props["duration_ms"] = durationMs
props["success"] = success
c.Track(EventMCPToolCalled, props)
}
// --- Manifest Tracking Methods ---
// TrackManifestSaved tracks when a manifest file is saved.
func (c *posthogClient) TrackManifestSaved(skillCount int, source string) {
props := baseProperties()
props["skill_count"] = skillCount
props["source"] = source // "cli" or "tui"
c.Track(EventManifestSaved, props)
}
// TrackManifestSynced tracks when skills are synced from a manifest.
func (c *posthogClient) TrackManifestSynced(totalSkills, installedCount, skippedCount int) {
props := baseProperties()
props["total_skills"] = totalSkills
props["installed_count"] = installedCount
props["skipped_count"] = skippedCount
c.Track(EventManifestSynced, props)
}
func (c *noopClient) TrackSkillsDiscovered(count int, scopeGlobal, scopeProject bool) {}
func (c *noopClient) TrackSkillIngested(skillName, scope string) {}
// --- noopClient implementations for Shared and MCP events ---
func (c *noopClient) TrackSkillViewed(slug, category string, isLocal bool) {}
func (c *noopClient) TrackSkillsListed(count int, source string) {}
func (c *noopClient) TrackStatsViewed() {}
func (c *noopClient) TrackRecentSkillsViewed(count int) {}
func (c *noopClient) TrackInstalledSkillsChecked(count int) {}
func (c *noopClient) TrackMCPToolCalled(toolName string, durationMs int64, success bool) {}
func (c *noopClient) TrackManifestSaved(skillCount int, source string) {}
func (c *noopClient) TrackManifestSynced(totalSkills, installedCount, skippedCount int) {}