瀏覽代碼

chore(build): use token from ci env for sentry and posthog (#7777)

Andelf 2 年之前
父節點
當前提交
86b9cdfce7

+ 3 - 0
.github/workflows/build-android.yml

@@ -109,6 +109,9 @@ jobs:
 
       - name: Compile CLJS - app variant, use es6 instead of es-next
         run: yarn install && yarn release-app
+        env:
+          LOGSEQ_SENTRY_DSN: ${{ secrets.LOGSEQ_SENTRY_DSN }}
+          LOGSEQ_POSTHOG_TOKEN: ${{ secrets.LOGSEQ_POSTHOG_TOKEN }}
 
       - name: Upload Sentry Sourcemaps (beta only)
         if: ${{ github.repository == 'logseq/logseq' && (inputs.build-target == 'beta' || github.event.inputs.build-target == 'beta') }}

+ 3 - 0
.github/workflows/build-desktop-release.yml

@@ -129,6 +129,9 @@ jobs:
 
       - name: Compile CLJS
         run: yarn install && gulp build && yarn cljs:release-electron
+        env:
+          LOGSEQ_SENTRY_DSN: ${{ secrets.LOGSEQ_SENTRY_DSN }}
+          LOGSEQ_POSTHOG_TOKEN: ${{ secrets.LOGSEQ_POSTHOG_TOKEN }}
 
       - name: Update APP Version
         run: |

+ 3 - 0
.github/workflows/build-ios-release.yml

@@ -57,6 +57,9 @@ jobs:
 
       - name: Compile CLJS
         run: yarn install && yarn release-app
+        env:
+          LOGSEQ_SENTRY_DSN: ${{ secrets.LOGSEQ_SENTRY_DSN }}
+          LOGSEQ_POSTHOG_TOKEN: ${{ secrets.LOGSEQ_POSTHOG_TOKEN }}
 
       - name: Sync static build files
         run: rsync -avz --exclude node_modules --exclude '*.js.map' --exclude android ./static/ ./public/static/

+ 3 - 1
shadow-cljs.edn

@@ -35,7 +35,9 @@
                                                 :redef false}}
         :build-hooks      [(shadow.hooks/git-revision-hook "--long --always --dirty")]
         :closure-defines  {goog.debug.LOGGING_ENABLED       true
-                           frontend.config/ENABLE-PLUGINS #shadow/env ["ENABLE_PLUGINS"   :as :bool :default true]
+                           frontend.modules.instrumentation.sentry/SENTRY-DSN #shadow/env "LOGSEQ_SENTRY_DSN"
+                           frontend.modules.instrumentation.posthog/POSTHOG-TOKEN #shadow/env "LOGSEQ_POSTHOG_TOKEN"
+                           frontend.config/ENABLE-PLUGINS #shadow/env ["ENABLE_PLUGINS" :as :bool :default true]
                            frontend.config/ENABLE-FILE-SYNC-PRODUCTION #shadow/env ["ENABLE_FILE_SYNC_PRODUCTION" :as :bool :default true]
                            frontend.config/TEST #shadow/env ["LOGSEQ_CI" :as :bool :default false]
                            frontend.config/REVISION #shadow/env ["LOGSEQ_REVISION" :default "dev"]} ;; set by git-revision-hook

+ 3 - 3
src/main/frontend/modules/instrumentation/posthog.cljs

@@ -6,7 +6,7 @@
             ["posthog-js" :as posthog]
             [cljs-bean.core :as bean]))
 
-(def ^:const token "qUumrWobEk2dKiKt1b32CMEZy8fgNS94rb_Bq4WutPA")
+(goog-define POSTHOG-TOKEN "")
 (def ^:const masked "masked")
 
 (defn register []
@@ -39,8 +39,8 @@
    :loaded (fn [_] (register))})
 
 (defn init []
-  (when-not config/dev?
-  (posthog/init token (clj->js config))))
+  (when (and (not config/dev?) (not-empty POSTHOG-TOKEN))
+    (posthog/init POSTHOG-TOKEN (clj->js config))))
 
 (defn opt-out [opt-out?]
   (if opt-out?

+ 4 - 2
src/main/frontend/modules/instrumentation/sentry.cljs

@@ -5,8 +5,10 @@
             ["@sentry/react" :as Sentry]
             [frontend.mobile.util :as mobile-util]))
 
+(goog-define SENTRY-DSN "")
+
 (def config
-  {:dsn "https://[email protected]/5311485"
+  {:dsn SENTRY-DSN
    :release (util/format "logseq%s@%s" (cond
                                          (mobile-util/native-android?) "-android"
                                          (mobile-util/native-ios?) "-ios"
@@ -44,7 +46,7 @@
                  event)})
 
 (defn init []
-  (when-not config/dev?
+  (when (and (not config/dev?) (not-empty SENTRY-DSN))
     (let [config (clj->js config)]
       (Sentry/init config))))