Skip to content

Commit 4bfde69

Browse files
[inspector] Introduce analytics feature
1 parent 35cacc7 commit 4bfde69

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

cider-inspector.el

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ by clicking or navigating to them by other means."
9191
:type 'boolean
9292
:package-version '(cider . "0.27.0"))
9393

94+
(defcustom cider-inspector-display-analytics-hint t
95+
"When true, display hint about analytics feature for eligible objects.
96+
Can be turned to nil once the user sees and acknowledges the feature."
97+
:type 'boolean
98+
:package-version '(cider . "1.18.0"))
99+
94100
(defvar cider-inspector-uninteresting-regexp
95101
(concat "nil" ; nils are not interesting
96102
"\\|:" clojure--sym-regexp ; nor keywords
@@ -125,6 +131,7 @@ by clicking or navigating to them by other means."
125131
(define-key map "c" #'cider-inspector-set-max-coll-size)
126132
(define-key map "C" #'cider-inspector-set-max-nested-depth)
127133
(define-key map "v" #'cider-inspector-toggle-view-mode)
134+
(define-key map "y" #'cider-inspector-display-analytics)
128135
(define-key map "d" #'cider-inspector-def-current-val)
129136
(define-key map "t" #'cider-inspector-tap-current-val)
130137
(define-key map "1" #'cider-inspector-tap-at-point)
@@ -325,6 +332,17 @@ MAX-NESTED-DEPTH is the new value."
325332
(interactive (list (read-number "Max nested depth: " cider-inspector-max-nested-depth)))
326333
(cider-inspector--refresh-with-opts "max-nested-depth" max-nested-depth))
327334

335+
(defun cider-inspector-display-analytics ()
336+
"Toggle the display of analytics for the inspected object."
337+
(interactive)
338+
;; Disable hint about analytics feature so that it is never displayed again.
339+
(when cider-inspector-display-analytics-hint
340+
(customize-set-variable 'cider-inspector-display-analytics-hint nil))
341+
(let ((result (cider-nrepl-send-sync-request `("op" "inspect-display-analytics")
342+
(cider-current-repl))))
343+
(when (nrepl-dict-get result "value")
344+
(cider-inspector--render-value result :next-inspectable))))
345+
328346
(defun cider-inspector-toggle-view-mode ()
329347
"Toggle the view mode of the inspector between normal and object view mode."
330348
(interactive)
@@ -490,7 +508,9 @@ MAX-COLL-SIZE if non nil."
490508
,@(when cider-inspector-max-coll-size
491509
`("max-coll-size" ,cider-inspector-max-coll-size))
492510
,@(when cider-inspector-max-nested-depth
493-
`("max-nested-depth" ,cider-inspector-max-nested-depth))))
511+
`("max-nested-depth" ,cider-inspector-max-nested-depth))
512+
,@(when cider-inspector-display-analytics-hint
513+
`("display-analytics-hint" "true"))))
494514
(cider-nrepl-send-sync-request (cider-current-repl))))
495515

496516
(declare-function cider-set-buffer-ns "cider-mode")

0 commit comments

Comments
 (0)