Anon metrics transfer
Saving my initial noodling Saving my initial noodling Filtering working much better, data collection working better Added jsonrpc call params Added transformations ns and funcs whitelisting the new rpc method Addressed PR feedback Minor fix for the on-failure log/error lint fix manual lint fix Signed-off-by: Shivek Khurana <shivek@status.im>
This commit is contained in:
parent
937efc9f4f
commit
be0ad943ea
|
@ -0,0 +1,27 @@
|
||||||
|
(ns status-im.anon-metrics.interceptors
|
||||||
|
(:require [status-im.ethereum.json-rpc :as json-rpc]
|
||||||
|
[taoensso.timbre :as log]
|
||||||
|
[re-frame.interceptor :refer [->interceptor]]
|
||||||
|
[status-im.utils.platform :as platform]
|
||||||
|
[status-im.utils.build :as build]
|
||||||
|
[status-im.anon-metrics.transformers :as txf]))
|
||||||
|
|
||||||
|
(defn transform-and-log [context]
|
||||||
|
(log/info :catch-event-fn (get-in context [:coeffects :event]))
|
||||||
|
(when-let [transformed-payload (txf/transform context)]
|
||||||
|
(json-rpc/call {:method "appmetrics_saveAppMetrics"
|
||||||
|
:params [[{:event (-> context :coeffects :event first)
|
||||||
|
:value transformed-payload
|
||||||
|
:app_version build/version
|
||||||
|
:os platform/os}]]
|
||||||
|
:on-failure #(log/error)})))
|
||||||
|
|
||||||
|
(defn catch-events-before [context]
|
||||||
|
(log/info "catch-events/interceptor fired")
|
||||||
|
(transform-and-log context)
|
||||||
|
context)
|
||||||
|
|
||||||
|
(def catch-events
|
||||||
|
(->interceptor
|
||||||
|
:id :catch-events
|
||||||
|
:before catch-events-before))
|
|
@ -0,0 +1,14 @@
|
||||||
|
(ns status-im.anon-metrics.transformers)
|
||||||
|
|
||||||
|
(defn navigate-to-txf [context]
|
||||||
|
{:view-id (second context)
|
||||||
|
:params (-> context
|
||||||
|
(nth 2)
|
||||||
|
(select-keys [:screen]))})
|
||||||
|
|
||||||
|
(def transformations
|
||||||
|
{:navigate-to navigate-to-txf})
|
||||||
|
|
||||||
|
(defn transform [ctx]
|
||||||
|
(when-let [txf (-> ctx first transformations)]
|
||||||
|
(txf ctx)))
|
|
@ -179,7 +179,8 @@
|
||||||
"mailservers_addChatRequestRange" {}
|
"mailservers_addChatRequestRange" {}
|
||||||
"mailservers_addChatRequestRanges" {}
|
"mailservers_addChatRequestRanges" {}
|
||||||
"mailservers_getChatRequestRanges" {}
|
"mailservers_getChatRequestRanges" {}
|
||||||
"mailservers_deleteChatRequestRange" {}})
|
"mailservers_deleteChatRequestRange" {}
|
||||||
|
"appmetrics_saveAppMetrics" {}})
|
||||||
|
|
||||||
(defn on-error-retry
|
(defn on-error-retry
|
||||||
[call-method {:keys [method number-of-retries delay on-error] :as arg}]
|
[call-method {:keys [method number-of-retries delay on-error] :as arg}]
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
(:require [re-frame.core :as re-frame]
|
(:require [re-frame.core :as re-frame]
|
||||||
[status-im.ui.screens.routing.core :as navigation]
|
[status-im.ui.screens.routing.core :as navigation]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[status-im.utils.fx :as fx]))
|
[status-im.utils.fx :as fx]
|
||||||
|
[status-im.anon-metrics.interceptors :as anon-metrics]))
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
::navigate-to
|
::navigate-to
|
||||||
|
@ -44,7 +45,8 @@
|
||||||
::navigate-to [go-to-view-id screen-params]})
|
::navigate-to [go-to-view-id screen-params]})
|
||||||
|
|
||||||
(fx/defn navigate-to
|
(fx/defn navigate-to
|
||||||
{:events [:navigate-to]}
|
{:events [:navigate-to]
|
||||||
|
:interceptors [anon-metrics/catch-events]}
|
||||||
[cofx go-to-view-id screen-params]
|
[cofx go-to-view-id screen-params]
|
||||||
(navigate-to-cofx cofx go-to-view-id screen-params))
|
(navigate-to-cofx cofx go-to-view-id screen-params))
|
||||||
|
|
||||||
|
@ -59,7 +61,8 @@
|
||||||
{::navigate-reset config})
|
{::navigate-reset config})
|
||||||
|
|
||||||
(fx/defn navigate-replace
|
(fx/defn navigate-replace
|
||||||
{:events [:navigate-replace]}
|
{:events [:navigate-replace]
|
||||||
|
:interceptors [anon-metrics/catch-events]}
|
||||||
[{:keys [db]} go-to-view-id screen-params]
|
[{:keys [db]} go-to-view-id screen-params]
|
||||||
(let [db (cond-> (assoc db :view-id go-to-view-id)
|
(let [db (cond-> (assoc db :view-id go-to-view-id)
|
||||||
(seq screen-params)
|
(seq screen-params)
|
||||||
|
|
Loading…
Reference in New Issue