aboutsummaryrefslogtreecommitdiffstats
path: root/webstats/stats.paren
blob: 04faff7cb89d71bafc7b44117da86b648e2f792e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
;; -*- mode: lisp; -*-
;; (pushnew '(SLYNK:*STRING-ELISION-LENGTH* . nil) slynk:*slynk-pprint-bindings* :test #'equal)

(in-package :webstats-js)

(defun register-visit ()
  (let ((data (create :title (@ document title)
                      :page (@ window location href)
                      :referer (@ document referrer))))
    (chain
     (fetch "http://localhost:4252/visit"
            (create :method "POST"
                    :headers (create "Content-Type" "application/x-www-form-urlencoded")
                    :body (new (-u-r-l-search-params data))
                    ))
     (then (lambda (r)
             ((@ console log) r)
             ((@ r text))))
     (then (@ console log)))))

(add-event-listener "load" register-visit)