@@ -107,13 +107,16 @@ func sessionSetup(cmd *cobra.Command) (context.Context, *sessionServices, func()
107 dataDir, _ := cmd.Flags().GetString("data-dir")
107 dataDir, _ := cmd.Flags().GetString("data-dir")
108 ctx := cmd.Context()
108 ctx := cmd.Context()
110+ cfg, err := config.Init("", dataDir, false)
112+ return nil, nil, nil, fmt.Errorf("failed to initialize config: %w", err)
110 if dataDir == "" {
114 if dataDir == "" {
111− cfg, err := config.Init("", "", false)
113− return nil, nil, nil, fmt.Errorf("failed to initialize config: %w", err)
115 dataDir = cfg.Config().Options.DataDirectory
115 dataDir = cfg.Config().Options.DataDirectory
117+ if shouldEnableMetrics(cfg.Config()) {
118 conn, err := db.Connect(ctx, dataDir)
121 conn, err := db.Connect(ctx, dataDir)
119 if err != nil {
122 if err != nil {
@@ -130,7 +133,6 @@ func sessionSetup(cmd *cobra.Command) (context.Context, *sessionServices, func()
131func runSessionList(cmd *cobra.Command, _ []string) error {
134func runSessionList(cmd *cobra.Command, _ []string) error {
132 event.SetNonInteractive(true)
135 event.SetNonInteractive(true)
133− event.SessionListed(sessionListJSON)
135 ctx, svc, cleanup, err := sessionSetup(cmd)
137 ctx, svc, cleanup, err := sessionSetup(cmd)
136 if err != nil {
138 if err != nil {
@@ -138,6 +140,8 @@ func runSessionList(cmd *cobra.Command, _ []string) error {
139 defer cleanup()
141 defer cleanup()
143+ event.SessionListed(sessionListJSON)
141 list, err := svc.sessions.List(ctx)
145 list, err := svc.sessions.List(ctx)
142 if err != nil {
146 if err != nil {
143 return fmt.Errorf("failed to list sessions: %w", err)
147 return fmt.Errorf("failed to list sessions: %w", err)
@@ -253,7 +257,6 @@ func resolveSessionID(ctx context.Context, svc session.Service, id string) (sess
254func runSessionShow(cmd *cobra.Command, args []string) error {
258func runSessionShow(cmd *cobra.Command, args []string) error {
255 event.SetNonInteractive(true)
259 event.SetNonInteractive(true)
256− event.SessionShown(sessionShowJSON)
258 ctx, svc, cleanup, err := sessionSetup(cmd)
261 ctx, svc, cleanup, err := sessionSetup(cmd)
259 if err != nil {
262 if err != nil {
@@ -261,6 +264,8 @@ func runSessionShow(cmd *cobra.Command, args []string) error {
262 defer cleanup()
265 defer cleanup()
267+ event.SessionShown(sessionShowJSON)
264 sess, err := resolveSessionID(ctx, svc.sessions, args[0])
269 sess, err := resolveSessionID(ctx, svc.sessions, args[0])
265 if err != nil {
270 if err != nil {
266 return err
271 return err
@@ -280,7 +285,6 @@ func runSessionShow(cmd *cobra.Command, args []string) error {
281func runSessionDelete(cmd *cobra.Command, args []string) error {
286func runSessionDelete(cmd *cobra.Command, args []string) error {
282 event.SetNonInteractive(true)
287 event.SetNonInteractive(true)
283− event.SessionDeletedCommand(sessionDeleteJSON)
285 ctx, svc, cleanup, err := sessionSetup(cmd)
289 ctx, svc, cleanup, err := sessionSetup(cmd)
286 if err != nil {
290 if err != nil {
@@ -288,6 +292,8 @@ func runSessionDelete(cmd *cobra.Command, args []string) error {
289 defer cleanup()
293 defer cleanup()
295+ event.SessionDeletedCommand(sessionDeleteJSON)
291 sess, err := resolveSessionID(ctx, svc.sessions, args[0])
297 sess, err := resolveSessionID(ctx, svc.sessions, args[0])
292 if err != nil {
298 if err != nil {
293 return err
299 return err
@@ -315,7 +321,6 @@ func runSessionDelete(cmd *cobra.Command, args []string) error {
316func runSessionRename(cmd *cobra.Command, args []string) error {
322func runSessionRename(cmd *cobra.Command, args []string) error {
317 event.SetNonInteractive(true)
323 event.SetNonInteractive(true)
318− event.SessionRenamed(sessionRenameJSON)
320 ctx, svc, cleanup, err := sessionSetup(cmd)
325 ctx, svc, cleanup, err := sessionSetup(cmd)
321 if err != nil {
326 if err != nil {
@@ -323,6 +328,8 @@ func runSessionRename(cmd *cobra.Command, args []string) error {
324 defer cleanup()
329 defer cleanup()
331+ event.SessionRenamed(sessionRenameJSON)
326 sess, err := resolveSessionID(ctx, svc.sessions, args[0])
333 sess, err := resolveSessionID(ctx, svc.sessions, args[0])
327 if err != nil {
334 if err != nil {
328 return err
335 return err
@@ -351,7 +358,6 @@ func runSessionRename(cmd *cobra.Command, args []string) error {
352func runSessionLast(cmd *cobra.Command, _ []string) error {
359func runSessionLast(cmd *cobra.Command, _ []string) error {
353 event.SetNonInteractive(true)
360 event.SetNonInteractive(true)
354− event.SessionLastShown(sessionLastJSON)
356 ctx, svc, cleanup, err := sessionSetup(cmd)
362 ctx, svc, cleanup, err := sessionSetup(cmd)
357 if err != nil {
363 if err != nil {
@@ -359,6 +365,8 @@ func runSessionLast(cmd *cobra.Command, _ []string) error {
360 defer cleanup()
366 defer cleanup()
368+ event.SessionLastShown(sessionLastJSON)
362 list, err := svc.sessions.List(ctx)
370 list, err := svc.sessions.List(ctx)
363 if err != nil {
371 if err != nil {
364 return fmt.Errorf("failed to list sessions: %w", err)
372 return fmt.Errorf("failed to list sessions: %w", err)