From b0af94415fbdb2b5d27748663d74c9078e6c0c41 Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Fri, 16 Aug 2024 10:28:01 +0200 Subject: [PATCH] :tada: Test A/B for starting with light theme --- backend/src/app/rpc/commands/auth.clj | 13 +++++++++---- frontend/src/app/main/data/users.cljs | 4 +++- frontend/src/app/main/ui/auth.cljs | 7 ++++++- frontend/src/app/main/ui/auth/register.cljs | 4 +++- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/backend/src/app/rpc/commands/auth.clj b/backend/src/app/rpc/commands/auth.clj index 268588a0f..abb0fcf26 100644 --- a/backend/src/app/rpc/commands/auth.clj +++ b/backend/src/app/rpc/commands/auth.clj @@ -282,6 +282,7 @@ is-demo (:is-demo params false) is-muted (:is-muted params false) is-active (:is-active params false) + theme (:theme params nil) email (str/lower email) params {:id id @@ -292,6 +293,7 @@ :password password :deleted-at (:deleted-at params) :props props + :theme theme :is-active is-active :is-muted is-muted :is-demo is-demo}] @@ -347,11 +349,13 @@ :extra-data ptoken}))) (defn register-profile - [{:keys [::db/conn] :as cfg} {:keys [token fullname] :as params}] - (let [claims (tokens/verify (::setup/props cfg) {:token token :iss :prepared-register}) + [{:keys [::db/conn] :as cfg} {:keys [token fullname theme] :as params}] + (let [theme (when (= theme "light") theme) + claims (tokens/verify (::setup/props cfg) {:token token :iss :prepared-register}) params (-> claims (into params) - (assoc :fullname fullname)) + (assoc :fullname fullname) + (assoc :theme theme)) profile (if-let [profile-id (:profile-id claims)] (profile/get-profile conn profile-id) @@ -456,7 +460,8 @@ (def schema:register-profile [:map {:title "register-profile"} [:token schema:token] - [:fullname [::sm/word-string {:max 100}]]]) + [:fullname [::sm/word-string {:max 100}]] + [:theme {:optional true} [:string {:max 10}]]]) (sv/defmethod ::register-profile {::rpc/auth false diff --git a/frontend/src/app/main/data/users.cljs b/frontend/src/app/main/data/users.cljs index 375119931..fe5f12aba 100644 --- a/frontend/src/app/main/data/users.cljs +++ b/frontend/src/app/main/data/users.cljs @@ -19,6 +19,7 @@ [app.main.data.websocket :as ws] [app.main.features :as features] [app.main.repo :as rp] + [app.util.dom :as dom] [app.util.i18n :as i18n :refer [tr]] [app.util.router :as rt] [app.util.storage :refer [storage]] @@ -135,7 +136,8 @@ (swap! storage assoc :profile profile) (i18n/set-locale! (:lang profile)) (when (not= previous-email email) - (set-current-team! nil))))))) + (set-current-team! nil)) + (dom/set-html-theme-color (or (:theme profile) "default"))))))) (defn fetch-profile [] diff --git a/frontend/src/app/main/ui/auth.cljs b/frontend/src/app/main/ui/auth.cljs index 4d24070cc..a47ecd150 100644 --- a/frontend/src/app/main/ui/auth.cljs +++ b/frontend/src/app/main/ui/auth.cljs @@ -49,11 +49,16 @@ (not= section :auth-register-success)) params (:query-params route) error (:error params) - hide-image-auth? (cf/external-feature-flag "signup-01" "test")] + hide-image-auth? (cf/external-feature-flag "signup-01" "test") + default-light? (cf/external-feature-flag "onboarding-02" "test")] (mf/with-effect [] (dom/set-html-title (tr "title.default"))) + (mf/with-effect [default-light?] + (when default-light? + (dom/set-html-theme-color "light"))) + (mf/with-effect [error] (when error (st/emit! (du/show-redirect-error error)))) diff --git a/frontend/src/app/main/ui/auth/register.cljs b/frontend/src/app/main/ui/auth/register.cljs index f7625c55e..dff7daa6a 100644 --- a/frontend/src/app/main/ui/auth/register.cljs +++ b/frontend/src/app/main/ui/auth/register.cljs @@ -227,6 +227,7 @@ :initial params) submitted? (mf/use-state false) + theme (when (cf/external-feature-flag "onboarding-02" "test") "light") on-success (mf/use-fn @@ -245,7 +246,8 @@ (mf/use-fn (fn [form _] (reset! submitted? true) - (let [params (:clean-data @form)] + (let [params (cond-> (:clean-data @form) + (some? theme) (assoc :theme theme))] (->> (rp/cmd! :register-profile params) (rx/finalize #(reset! submitted? false)) (rx/subs! on-success on-error)))))]