Skip to content

Commit

Permalink
ready for review
Browse files Browse the repository at this point in the history
  • Loading branch information
caumond committed Oct 24, 2023
1 parent a096b08 commit b308300
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 174 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/commit_validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set ownership
run: |
# this is to fix GIT not liking owner of the checkout dir, See https://github.com/actions/runner/issues/2033
chown -R $(id -u):$(id -g) $PWD
- name: Base image
uses: docker://hephaistox/gha_runner:latest
uses: docker://hephaistox/gha-automaton-core:latest
2 changes: 1 addition & 1 deletion bb.edn
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
'automaton-build-app.tasks.code-helpers/lconnect)},
ltest {:doc "Local test",
:task (execute-task 'automaton-build-app.tasks.test/ltest)},
publish
publish-gha-container
{:doc "Publish the container, useful to push the github container itself",
:task
(execute-task
Expand Down
10 changes: 5 additions & 5 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
babashka/process #:mvn{:version "0.5.21"},
danlentz/clj-uuid #:mvn{:version "0.1.9"},
metosin/malli #:mvn{:version "0.13.0"},
lambdaisland/uri {:mvn/version "1.15.125"}
lambdaisland/uri {:mvn/version "1.16.134"}
mount/mount #:mvn{:version "0.1.17"},
com.clojure-goes-fast/clj-memory-meter #:mvn{:version "0.3.0"},
org.apache.logging.log4j/log4j-api #:mvn{:version "2.20.0"},
org.apache.logging.log4j/log4j-core #:mvn{:version "2.20.0"},
org.apache.logging.log4j/log4j-slf4j2-impl #:mvn{:version "2.20.0"},
io.sentry/sentry {:mvn/version "6.29.0"},
io.sentry/sentry {:mvn/version "6.32.0"},
io.sentry/sentry-clj #:mvn{:version "6.28.200"},
com.taoensso/tempura #:mvn{:version "1.5.3"},
com.taoensso/encore #:mvn{:version "3.62.1"}
Expand All @@ -29,8 +29,8 @@
:jvm-opts ["-Dheph-conf=env/test/config.edn"
"-Dheph-common-conf=env/common_config.edn"]}

:build {:extra-deps {hephaistox/automaton-build-app {:git/url "git@github.com:hephaistox/automaton-build-app.git"
:sha "33c8941cb6df63006bafaaf1d5e7f0383b10468a"}}}
:build {:extra-deps {hephaistox/automaton-build-app {:git/url "https://github.com/hephaistox/automaton-core.git"
:sha "9729eb2e4698bad758b24d24d236064e436342c5"}}}

:env-development-repl {:extra-paths ["env/development/resources"
"env/development/src/clj"
Expand All @@ -50,7 +50,7 @@
"-d" "test/cljc"]}

:cljs-deps {:extra-paths ["src/cljs" "src/cljc" "resources" "test/cljs" "test/cljc"]
:extra-deps {thheller/shadow-cljs {:mvn/version "2.25.8"}
:extra-deps {thheller/shadow-cljs {:mvn/version "2.25.9"}
cider/cider-nrepl {:mvn/version "0.21.1"}
binaryage/devtools {:mvn/version "1.0.7"}}}

Expand Down
2 changes: 1 addition & 1 deletion docs/code/alias.edn
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
;; List of aliases referencing many namespaces Tue Oct 24 19:33:10 CEST 2023
;; List of aliases referencing many namespaces Tue Oct 24 22:21:19 CEST 2023
{}
4 changes: 2 additions & 2 deletions docs/code/deps.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/code/namespace.edn
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
;; List of aliases referencing many namespaces Tue Oct 24 19:33:11 CEST 2023
;; List of aliases referencing many namespaces Tue Oct 24 22:21:19 CEST 2023
{}
2 changes: 1 addition & 1 deletion env/development/config.edn
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{:env :development
:dev {:clj-nrepl-port 8010}}
:dev {:clj-nrepl-port 8012}}
4 changes: 2 additions & 2 deletions env/development/resources/version.edn
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
;; Last generated version, note a failed push consume a number Tue Oct 24
;; 19:32:54 CEST 2023
{:major-version "1.2.%s", :minor-version 3, :version "1.2.3"}
;; 22:20:52 CEST 2023
{:major-version "1.2.%s", :minor-version 5, :version "1.2.5"}
124 changes: 1 addition & 123 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"version": "1.0.0",
"author": "Hephaistox <[email protected]>",
"dependencies": {
"react-router-dom": "^6.16.0",
"@sentry/react": "^7.69.0"
"@sentry/browser": "^7.73.0"
},
"workspaces": [],
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/cljc/automaton_core/log.cljc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(ns automaton-core.log
"Main entrypoint to logging, defines basic levels that we use to log.
"Main entrypoint to automaton core logging, defines basic levels that we use to log.
Logical order of logs is:
trace -> debug -> info -> warn -> error -> fatal"
Expand Down
3 changes: 1 addition & 2 deletions src/cljc/automaton_core/utils/map.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@
[m]
(when (map? m)
(->> (walk/postwalk prefixify-children m)
(map (fn [[k v]]
{k (if (sequential? v) (flatten v) v)}))
(map (fn [[k v]] {k (if (sequential? v) (flatten v) v)}))
(into {}))))

(defn add-ids
Expand Down
11 changes: 4 additions & 7 deletions src/cljs/automaton_core/log/fe_log.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
"Factory generating log function"
(:require [automaton-core.log.strategy]
[automaton-core.log.fe-registry]
[automaton-core.log.strategy.static-ns-level]
#?(:cljs [automaton-core.log.tracking.fe-error-tracking :as exs]))
[automaton-core.log.strategy.static-ns-level])
#?(:cljs (:require-macros [automaton-core.log.fe-log])))

#?(:cljs (defn log-init! [params] (exs/init-error-tracking! params)))

(defn logger-ids-to-logger-fns
[logger-ids]
(reduce (fn [acc logger-id]
Expand All @@ -24,23 +21,23 @@
(let [ns (str *ns*)
log-fns `(automaton-core.log.fe-log/logger-ids-to-logger-fns
~logger-id)]
`((apply juxt ~log-fns) ~ns (str ~level) ~@message)))
`((apply juxt ~log-fns) ~ns ~level ~@message)))

(defmacro log-exception
[logger-id level exception & additional-message]
(when additional-message (log logger-id level additional-message))
(let [ns (str *ns*)
log-fns `(automaton-core.log.fe-log/logger-ids-to-logger-fns
~logger-id)]
`((apply juxt ~log-fns) ~ns (str ~level) ~exception)))
`((apply juxt ~log-fns) ~ns ~level ~exception)))

(defmacro log-data
[logger-id level data & additional-message]
(when additional-message (log logger-id additional-message))
(let [ns (str *ns*)
log-fns `(automaton-core.log.fe-log/logger-ids-to-logger-fns
~logger-id)]
`((apply juxt ~log-fns) ~ns (str ~level) ~data)))
`((apply juxt ~log-fns) ~ns ~level ~data)))

(defmacro log-format
[logger-id level fmt & data]
Expand Down
7 changes: 2 additions & 5 deletions src/cljs/automaton_core/log/tracking/fe_error_tracking.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@
"Automaton web monitoring live exceptions for remote enviroments (e.g. production, local acceptance, global acceptance)."
(:require [automaton-core.log.tracking.fe-sentry :as sentry]))

(defn init-error-tracking!
[{:keys [dsn env traced-website]}]
(sentry/init-sentry! {:dsn dsn, :traced-website traced-website, :env env}))

(defn log-fn
[ns level & message]
(let [context
(if (map? (first message)) (merge (first message) {:ns ns}) {:ns ns})
message (if (map? (first message)) (rest message) message)]
message (apply str (if (map? (first message)) (rest message) message))
level (if (= :trace level) :debug level)]
(if (or (= level :error) (= level :fatal))
(sentry/send-event! {:message message, :level level, :context context})
(sentry/send-breadcrumb!
Expand Down
21 changes: 5 additions & 16 deletions src/cljs/automaton_core/log/tracking/fe_sentry.cljs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
(ns automaton-core.log.tracking.fe-sentry
"Sentry frontend logging."
(:require
[react :as react]
["@sentry/react" :as Sentry]
["react-router-dom" :refer
(useLocation useNavigationType createRoutesFromChildren matchRoutes)]
[automaton-core.log.tracking.sentry :as asentry]))
(:require ["@sentry/browser" :as Sentry]
[automaton-core.log.tracking.sentry :as asentry]))

(defn send-breadcrumb!
"Sends breadcrumb, which will not be shown in sentry untill event is sent.
Expand All @@ -27,16 +23,9 @@
(.init Sentry
#js {:dsn dsn,
:environment env,
:integrations #js [(new (.-BrowserTracing Sentry)
#js {:routingInstrumentation
(.reactRouterV6Instrumentation
Sentry
react/useEffect
useLocation
useNavigationType
createRoutesFromChildren
matchRoutes)})
(new (.-Replay Sentry))],
:integrations #js [(new (.-BrowserTracing Sentry))],
:replaysSessionSampleRate 0,
:replaysOnErrorSampleRate 0,
:tracesSampleRate 1.0,
:tracePropagationTargets #js ["localhost" traced-website],
:beforeSend (fn [event]
Expand Down
2 changes: 1 addition & 1 deletion test/cljs/automaton_core/log/fe_log_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(automaton-core.log.fe-log/logger-ids-to-logger-fns
[:automaton-core.log.registry/print]))
"automaton-core.log.fe-log-test"
(clojure.core/str :fatal)
:fatal
"foo"
"bar")
(macroexpand '(sut/log
Expand Down
Loading

0 comments on commit b308300

Please sign in to comment.