Skip to content

Commit

Permalink
chore(build): use token from ci env for sentry and posthog (logseq#7777)
Browse files Browse the repository at this point in the history
  • Loading branch information
andelf authored Dec 19, 2022
1 parent effe00f commit 86b9cdf
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/build-desktop-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/build-ios-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
4 changes: 3 additions & 1 deletion shadow-cljs.edn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/main/frontend/modules/instrumentation/posthog.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
Expand Down Expand Up @@ -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?
Expand Down
6 changes: 4 additions & 2 deletions src/main/frontend/modules/instrumentation/sentry.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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))))

Expand Down

0 comments on commit 86b9cdf

Please sign in to comment.