<commit_before>(ns frontend.utils.launchdarkly
    (:refer-clojure :exclude [exists?]))

(defn feature-on?
  ([feature-name default]
   (when (and (aget js/window "ldclient") js/ldclient.toggle)
    (.toggle js/ldclient feature-name default)))
  ([feature-name]
   (feature-on? feature-name nil)))

(defn identify [user]
  (when (and (aget js/window "ldclient") js/ldclient.identify)
   (.identify js/ldclient (clj->js (merge {:key (aget js/ldUser "key")} user)))))

(def local-lduser-state (atom nil))

(defn load-lduser! []
  (swap! local-lduser-state
         (fn [v]
           (when-not v
             (or (js->clj js/ldUser) {})))))

(defn reidentify! [f]
  (load-lduser!)
  (swap! local-lduser-state f)
  (identify @local-lduser-state))

(defn merge-custom-properties! [m]
  (reidentify! #(update-in % [:custom] merge m)))

(defn exists? [feature-name]
  (not (nil? (feature-on? feature-name nil))))<commit_msg>Fix Launch Darkly reident<commit_after>(ns frontend.utils.launchdarkly
    (:refer-clojure :exclude [exists?]))

(defn feature-on?
  ([feature-name default]
   (when (and (aget js/window "ldclient") js/ldclient.toggle)
    (.toggle js/ldclient feature-name default)))
  ([feature-name]
   (feature-on? feature-name nil)))

(defn identify [user]
  (when (and (aget js/window "ldclient") js/ldclient.identify)
   (.identify js/ldclient (clj->js (merge {:key (aget js/ldUser "key")} user)))))

(def local-lduser-state (atom nil))

(defn load-lduser! []
  (swap! local-lduser-state
         (fn [v]
           (if v
             v
             (or (js->clj js/ldUser) {})))))

(defn reidentify! [f]
  (load-lduser!)
  (swap! local-lduser-state f)
  (identify @local-lduser-state))

(defn merge-custom-properties! [m]
  (reidentify! #(update-in % ["custom"] merge m)))

(defn exists? [feature-name]
  (not (nil? (feature-on? feature-name nil))))
{'fraction_non_alphanumeric': 0.18191603875134554, 'fraction_numerical': 0.0, 'mean_word_length': 3.5012106537530268, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4542770', 'n_tokens_mistral': 711, 'n_tokens_neox': 695, 'n_words': 165}