mirror of https://github.com/logseq/logseq
feat: posthog instrument module
parent
94bead6455
commit
87b65ec220
|
@ -76,6 +76,7 @@
|
||||||
"jszip": "^3.5.0",
|
"jszip": "^3.5.0",
|
||||||
"mldoc": "0.6.18",
|
"mldoc": "0.6.18",
|
||||||
"path": "^0.12.7",
|
"path": "^0.12.7",
|
||||||
|
"posthog-js": "^1.10.2",
|
||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-dom": "^17.0.2",
|
"react-dom": "^17.0.2",
|
||||||
"react-resize-context": "^3.0.0",
|
"react-resize-context": "^3.0.0",
|
||||||
|
|
|
@ -53,9 +53,5 @@ const portal = new MagicPortal(worker);
|
||||||
<script defer src="./js/code-editor.js"></script>
|
<script defer src="./js/code-editor.js"></script>
|
||||||
<script defer src="./js/age-encryption.js"></script>
|
<script defer src="./js/age-encryption.js"></script>
|
||||||
<script defer src="./js/excalidraw.js"></script>
|
<script defer src="./js/excalidraw.js"></script>
|
||||||
<script>
|
|
||||||
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
|
|
||||||
posthog.init('qUumrWobEk2dKiKt1b32CMEZy8fgNS94rb_Bq4WutPA',{api_host:'https://app.posthog.com', persistence:'localStorage'})
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
:release {:asset-path "https://asset.logseq.com/static/js"}
|
:release {:asset-path "https://asset.logseq.com/static/js"}
|
||||||
:compiler-options {:infer-externs :auto
|
:compiler-options {:infer-externs :auto
|
||||||
:output-feature-set :es-next
|
:output-feature-set :es-next
|
||||||
|
;; this cross-chunk-method-motion is needed
|
||||||
|
;; idue to ssue related with
|
||||||
|
;; https://github.com/thheller/shadow-cljs/issues/611
|
||||||
|
:cross-chunk-method-motion false
|
||||||
:source-map true
|
:source-map true
|
||||||
:externs ["datascript/externs.js"
|
:externs ["datascript/externs.js"
|
||||||
"externs.js"]
|
"externs.js"]
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
(ns frontend.components.settings
|
(ns frontend.components.settings
|
||||||
(:require [rum.core :as rum]
|
(:require [clojure.string :as string]
|
||||||
[frontend.ui :as ui]
|
|
||||||
[frontend.components.svg :as svg]
|
[frontend.components.svg :as svg]
|
||||||
[frontend.handler.notification :as notification]
|
[frontend.config :as config]
|
||||||
[frontend.handler.user :as user-handler]
|
[frontend.context.i18n :as i18n]
|
||||||
[frontend.handler.ui :as ui-handler]
|
[frontend.date :as date]
|
||||||
[frontend.handler.repo :as repo-handler]
|
[frontend.dicts :as dicts]
|
||||||
|
[frontend.handler :as handler]
|
||||||
[frontend.handler.config :as config-handler]
|
[frontend.handler.config :as config-handler]
|
||||||
|
[frontend.handler.notification :as notification]
|
||||||
[frontend.handler.page :as page-handler]
|
[frontend.handler.page :as page-handler]
|
||||||
[frontend.handler.route :as route-handler]
|
[frontend.handler.route :as route-handler]
|
||||||
[frontend.handler :as handler]
|
[frontend.handler.ui :as ui-handler]
|
||||||
|
[frontend.handler.user :as user-handler]
|
||||||
|
[frontend.modules.instrumentation.posthog :as posthog]
|
||||||
[frontend.state :as state]
|
[frontend.state :as state]
|
||||||
[frontend.version :refer [version]]
|
[frontend.ui :as ui]
|
||||||
[frontend.util :as util]
|
[frontend.util :as util]
|
||||||
[frontend.config :as config]
|
[frontend.version :refer [version]]
|
||||||
[frontend.dicts :as dicts]
|
|
||||||
[clojure.string :as string]
|
|
||||||
[goog.object :as gobj]
|
[goog.object :as gobj]
|
||||||
[frontend.context.i18n :as i18n]
|
|
||||||
[reitit.frontend.easy :as rfe]
|
[reitit.frontend.easy :as rfe]
|
||||||
[frontend.date :as date]))
|
[rum.core :as rum]))
|
||||||
|
|
||||||
(rum/defcs set-email < (rum/local "" ::email)
|
(rum/defcs set-email < (rum/local "" ::email)
|
||||||
[state]
|
[state]
|
||||||
|
@ -145,15 +145,9 @@
|
||||||
:width 500
|
:width 500
|
||||||
:height 500}]])
|
:height 500}]])
|
||||||
|
|
||||||
(defn monitoring-opted-out
|
|
||||||
[]
|
|
||||||
(.. js/window -posthog has_opted_out_capturing))
|
|
||||||
|
|
||||||
(defn set-sentry-disabled!
|
(defn set-sentry-disabled!
|
||||||
[value]
|
[value]
|
||||||
(if value
|
(posthog/opt-out value)
|
||||||
(.. js/window -posthog opt_out_capturing)
|
|
||||||
(.. js/window -posthog opt_in_capturing))
|
|
||||||
(state/set-sentry-disabled! value))
|
(state/set-sentry-disabled! value))
|
||||||
|
|
||||||
(rum/defcs settings < rum/reactive
|
(rum/defcs settings < rum/reactive
|
||||||
|
|
|
@ -1,36 +1,31 @@
|
||||||
(ns frontend.handler
|
(ns frontend.handler
|
||||||
(:require [frontend.state :as state]
|
(:require [cljs-bean.core :as bean]
|
||||||
|
[electron.ipc :as ipc]
|
||||||
|
[electron.listener :as el]
|
||||||
|
[frontend.components.editor :as editor]
|
||||||
|
[frontend.components.page :as page]
|
||||||
|
[frontend.config :as config]
|
||||||
[frontend.db :as db]
|
[frontend.db :as db]
|
||||||
[frontend.db-schema :as db-schema]
|
[frontend.db-schema :as db-schema]
|
||||||
[frontend.util :as util :refer-macros [profile]]
|
[frontend.handler.common :as common-handler]
|
||||||
[frontend.config :as config]
|
[frontend.handler.events :as events]
|
||||||
[frontend.storage :as storage]
|
[frontend.handler.file :as file-handler]
|
||||||
[clojure.string :as string]
|
|
||||||
[promesa.core :as p]
|
|
||||||
[cljs-bean.core :as bean]
|
|
||||||
[frontend.date :as date]
|
|
||||||
[frontend.search :as search]
|
|
||||||
[frontend.search.db :as search-db]
|
|
||||||
[frontend.handler.notification :as notification]
|
[frontend.handler.notification :as notification]
|
||||||
[frontend.handler.page :as page-handler]
|
[frontend.handler.page :as page-handler]
|
||||||
[frontend.handler.repo :as repo-handler]
|
[frontend.handler.repo :as repo-handler]
|
||||||
[frontend.handler.file :as file-handler]
|
|
||||||
[frontend.handler.editor :as editor-handler]
|
|
||||||
[frontend.handler.ui :as ui-handler]
|
[frontend.handler.ui :as ui-handler]
|
||||||
[frontend.handler.web.nfs :as nfs]
|
|
||||||
[frontend.modules.shortcut.core :as shortcut]
|
|
||||||
[frontend.handler.events :as events]
|
|
||||||
[frontend.fs.watcher-handler :as fs-watcher-handler]
|
|
||||||
[frontend.ui :as ui]
|
|
||||||
[goog.object :as gobj]
|
|
||||||
[frontend.idb :as idb]
|
[frontend.idb :as idb]
|
||||||
[lambdaisland.glogi :as log]
|
[frontend.modules.instrumentation.posthog :as posthog]
|
||||||
[frontend.handler.common :as common-handler]
|
[frontend.modules.shortcut.core :as shortcut]
|
||||||
[electron.listener :as el]
|
[frontend.search :as search]
|
||||||
[electron.ipc :as ipc]
|
[frontend.search.db :as search-db]
|
||||||
|
[frontend.state :as state]
|
||||||
|
[frontend.storage :as storage]
|
||||||
|
[frontend.util :as util]
|
||||||
[frontend.version :as version]
|
[frontend.version :as version]
|
||||||
[frontend.components.page :as page]
|
[goog.object :as gobj]
|
||||||
[frontend.components.editor :as editor]))
|
[lambdaisland.glogi :as log]
|
||||||
|
[promesa.core :as p]))
|
||||||
|
|
||||||
(defn set-global-error-notification!
|
(defn set-global-error-notification!
|
||||||
[]
|
[]
|
||||||
|
@ -203,7 +198,8 @@
|
||||||
(file-handler/run-writes-chan!)
|
(file-handler/run-writes-chan!)
|
||||||
(shortcut/install-shortcuts!)
|
(shortcut/install-shortcuts!)
|
||||||
(when (util/electron?)
|
(when (util/electron?)
|
||||||
(el/listen!))))
|
(el/listen!))
|
||||||
|
(posthog/init)))
|
||||||
|
|
||||||
(defn stop! []
|
(defn stop! []
|
||||||
(prn "stop!"))
|
(prn "stop!"))
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
(ns frontend.modules.instrumentation.posthog
|
||||||
|
(:require [frontend.config :as cfg]
|
||||||
|
[frontend.util :as util]
|
||||||
|
[frontend.version :refer [version]]
|
||||||
|
["posthog-js" :as posthog]))
|
||||||
|
|
||||||
|
(def ^:const token "qUumrWobEk2dKiKt1b32CMEZy8fgNS94rb_Bq4WutPA")
|
||||||
|
(def ^:const masked "masked")
|
||||||
|
|
||||||
|
(defn register []
|
||||||
|
(posthog/register
|
||||||
|
(clj->js
|
||||||
|
(cond->
|
||||||
|
{:app_type (if (util/electron?) "electron" "web")
|
||||||
|
:app_env (if cfg/dev? "development" "production")
|
||||||
|
:app_ver version
|
||||||
|
:schema_ver 0
|
||||||
|
;; hack, did not find ways to hack data on-the-fly with posthog-js
|
||||||
|
:$ip masked
|
||||||
|
:$current_url masked}))))
|
||||||
|
|
||||||
|
(def config
|
||||||
|
{:api_host "https://app.posthog.com"
|
||||||
|
:persistence "localStorage"
|
||||||
|
:mask_all_text true
|
||||||
|
:mask_all_element_attributes true
|
||||||
|
:loaded (fn [_] (register))})
|
||||||
|
|
||||||
|
(defn init []
|
||||||
|
(posthog/init token (clj->js config))
|
||||||
|
(when cfg/dev?
|
||||||
|
(posthog/debug)))
|
||||||
|
|
||||||
|
(defn opt-out [opt-out?]
|
||||||
|
(if opt-out?
|
||||||
|
(posthog/opt_out_capturing)
|
||||||
|
(posthog/opt_in_capturing)))
|
12
yarn.lock
12
yarn.lock
|
@ -2203,6 +2203,11 @@ fd-slicer@~1.1.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
pend "~1.2.0"
|
pend "~1.2.0"
|
||||||
|
|
||||||
|
fflate@^0.4.1:
|
||||||
|
version "0.4.8"
|
||||||
|
resolved "https://registry.yarnpkg.com/fflate/-/fflate-0.4.8.tgz#f90b82aefbd8ac174213abb338bd7ef848f0f5ae"
|
||||||
|
integrity sha512-FJqqoDBR00Mdj9ppamLa/Y7vxm+PRmNWA67N846RvsoYVMKB4q3y/de5PA7gUmRMYK/8CMz2GDZQmCRN1wBcWA==
|
||||||
|
|
||||||
file-entry-cache@^6.0.0:
|
file-entry-cache@^6.0.0:
|
||||||
version "6.0.0"
|
version "6.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-6.0.0.tgz"
|
resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-6.0.0.tgz"
|
||||||
|
@ -4939,6 +4944,13 @@ postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.2, postcss@^7.0.21
|
||||||
source-map "^0.6.1"
|
source-map "^0.6.1"
|
||||||
supports-color "^6.1.0"
|
supports-color "^6.1.0"
|
||||||
|
|
||||||
|
posthog-js@^1.10.2:
|
||||||
|
version "1.10.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/posthog-js/-/posthog-js-1.10.2.tgz#74d6c84f9675b65dfd4ff6f4051ed8d3cb974076"
|
||||||
|
integrity sha512-JNjWstHEexhj5CEKldSeYNyPJbtOvZQ3ZPL55fxU7+f+gTBL8RlOb8eFohCPYIk0VhMf2UM1rXxwVBOeMQQQFw==
|
||||||
|
dependencies:
|
||||||
|
fflate "^0.4.1"
|
||||||
|
|
||||||
prepend-http@^2.0.0:
|
prepend-http@^2.0.0:
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz"
|
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz"
|
||||||
|
|
Loading…
Reference in New Issue