[#4006] anonymous uuid for mixpanel
This commit is contained in:
parent
5d5444e3de
commit
00b8ae311d
|
@ -1,6 +1,8 @@
|
||||||
package im.status.ethereum.module;
|
package im.status.ethereum.module;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.*;
|
import android.os.*;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
@ -728,4 +730,23 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
||||||
Log.d(TAG, "AppStateChange: " + type);
|
Log.d(TAG, "AppStateChange: " + type);
|
||||||
Statusgo.AppStateChange(type);
|
Statusgo.AppStateChange(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String uniqueID = null;
|
||||||
|
private static final String PREF_UNIQUE_ID = "PREF_UNIQUE_ID";
|
||||||
|
|
||||||
|
@ReactMethod
|
||||||
|
public void getDeviceUUID(final Callback callback) {
|
||||||
|
if (uniqueID == null) {
|
||||||
|
SharedPreferences sharedPrefs = this.getReactApplicationContext().getSharedPreferences(
|
||||||
|
PREF_UNIQUE_ID, Context.MODE_PRIVATE);
|
||||||
|
uniqueID = sharedPrefs.getString(PREF_UNIQUE_ID, null);
|
||||||
|
if (uniqueID == null) {
|
||||||
|
uniqueID = UUID.randomUUID().toString();
|
||||||
|
SharedPreferences.Editor editor = sharedPrefs.edit();
|
||||||
|
editor.putString(PREF_UNIQUE_ID, uniqueID);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
callback.invoke(uniqueID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -426,6 +426,15 @@ RCT_EXPORT_METHOD(appStateChange:(NSString *)type) {
|
||||||
AppStateChange((char *) [type UTF8String]);
|
AppStateChange((char *) [type UTF8String]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RCT_EXPORT_METHOD(getDeviceUUID:(RCTResponseSenderBlock)callback) {
|
||||||
|
#if DEBUG
|
||||||
|
NSLog(@"getDeviceUUID() method called");
|
||||||
|
#endif
|
||||||
|
NSString* Identifier = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
|
||||||
|
|
||||||
|
callback(@[Identifier]);
|
||||||
|
}
|
||||||
|
|
||||||
+ (void)signalEvent:(const char *) signal
|
+ (void)signalEvent:(const char *) signal
|
||||||
{
|
{
|
||||||
if(!signal){
|
if(!signal){
|
||||||
|
|
|
@ -100,3 +100,6 @@
|
||||||
|
|
||||||
(defn app-state-change [state]
|
(defn app-state-change [state]
|
||||||
(module-interface/-app-state-change rns-module state))
|
(module-interface/-app-state-change rns-module state))
|
||||||
|
|
||||||
|
(defn get-device-UUID [callback]
|
||||||
|
(module-interface/-get-device-UUID rns-module callback))
|
||||||
|
|
|
@ -12,7 +12,8 @@
|
||||||
[status-im.utils.async :as async-util :refer [timeout]]
|
[status-im.utils.async :as async-util :refer [timeout]]
|
||||||
[status-im.react-native.js-dependencies :as rn-dependencies]
|
[status-im.react-native.js-dependencies :as rn-dependencies]
|
||||||
[status-im.native-module.module :as module]
|
[status-im.native-module.module :as module]
|
||||||
[status-im.utils.config :as config]))
|
[status-im.utils.config :as config]
|
||||||
|
[clojure.string :as string]))
|
||||||
|
|
||||||
;; if StatusModule is not initialized better to store
|
;; if StatusModule is not initialized better to store
|
||||||
;; calls and make them only when StatusModule is ready
|
;; calls and make them only when StatusModule is ready
|
||||||
|
@ -243,6 +244,13 @@
|
||||||
(defn app-state-change [state]
|
(defn app-state-change [state]
|
||||||
(.appStateChange status state))
|
(.appStateChange status state))
|
||||||
|
|
||||||
|
(defn get-device-UUID [callback]
|
||||||
|
(call-module
|
||||||
|
#(.getDeviceUUID
|
||||||
|
status
|
||||||
|
(fn [UUID]
|
||||||
|
(callback (string/upper-case UUID))))))
|
||||||
|
|
||||||
(defrecord ReactNativeStatus []
|
(defrecord ReactNativeStatus []
|
||||||
module/IReactNativeStatus
|
module/IReactNativeStatus
|
||||||
;; status-go calls
|
;; status-go calls
|
||||||
|
@ -293,4 +301,6 @@
|
||||||
(-connection-change [this data]
|
(-connection-change [this data]
|
||||||
(connection-change data))
|
(connection-change data))
|
||||||
(-app-state-change [this state]
|
(-app-state-change [this state]
|
||||||
(app-state-change state)))
|
(app-state-change state))
|
||||||
|
(-get-device-UUID [this callback]
|
||||||
|
(get-device-UUID callback)))
|
||||||
|
|
|
@ -23,5 +23,6 @@
|
||||||
(-add-peer [this enode callback])
|
(-add-peer [this enode callback])
|
||||||
(-close-application [this])
|
(-close-application [this])
|
||||||
(-connection-change [this data])
|
(-connection-change [this data])
|
||||||
(-app-state-change [this state]))
|
(-app-state-change [this state])
|
||||||
|
(-get-device-UUID [this callback]))
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,10 @@
|
||||||
|
|
||||||
(spec/def ::message-envelopes (spec/nilable map?))
|
(spec/def ::message-envelopes (spec/nilable map?))
|
||||||
|
|
||||||
|
;;;;UUID
|
||||||
|
|
||||||
|
(spec/def ::device-UUID (spec/nilable string?))
|
||||||
|
|
||||||
(spec/def ::db (allowed-keys
|
(spec/def ::db (allowed-keys
|
||||||
:opt
|
:opt
|
||||||
[:contacts/contacts
|
[:contacts/contacts
|
||||||
|
@ -235,4 +239,5 @@
|
||||||
:wallet/wallet-selected-asset
|
:wallet/wallet-selected-asset
|
||||||
:prices/prices
|
:prices/prices
|
||||||
:prices/prices-loading?
|
:prices/prices-loading?
|
||||||
:notifications/notifications]))
|
:notifications/notifications
|
||||||
|
::device-UUID]))
|
||||||
|
|
|
@ -180,6 +180,11 @@
|
||||||
(i18n/label :testfairy-title)
|
(i18n/label :testfairy-title)
|
||||||
(i18n/label :testfairy-message)))))
|
(i18n/label :testfairy-message)))))
|
||||||
|
|
||||||
|
(re-frame/reg-fx
|
||||||
|
::init-device-UUID
|
||||||
|
(fn []
|
||||||
|
(status/get-device-UUID #(re-frame/dispatch [:set :device-UUID %]))))
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
::get-fcm-token-fx
|
::get-fcm-token-fx
|
||||||
(fn [_]
|
(fn [_]
|
||||||
|
@ -224,14 +229,15 @@
|
||||||
{::got-encryption-key-fx opts}))
|
{::got-encryption-key-fx opts}))
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:initialize-app
|
:initialize-app
|
||||||
(fn [_ [_ encryption-key]]
|
(fn [_ [_ encryption-key]]
|
||||||
{::testfairy-alert nil
|
{::init-device-UUID nil
|
||||||
:dispatch-n [[:initialize-db encryption-key]
|
::testfairy-alert nil
|
||||||
[:load-accounts]
|
:dispatch-n [[:initialize-db encryption-key]
|
||||||
[:initialize-views]
|
[:load-accounts]
|
||||||
[:listen-to-network-status]
|
[:initialize-views]
|
||||||
[:initialize-geth]]}))
|
[:listen-to-network-status]
|
||||||
|
[:initialize-geth]]}))
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:logout
|
:logout
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
[re-frame.core :refer [reg-event-db reg-event-fx] :as re-frame]
|
[re-frame.core :refer [reg-event-db reg-event-fx] :as re-frame]
|
||||||
[re-frame.interceptor :refer [->interceptor get-coeffect get-effect]]
|
[re-frame.interceptor :refer [->interceptor get-coeffect get-effect]]
|
||||||
[status-im.utils.ethereum.core :as ethereum]
|
|
||||||
[status-im.utils.instabug :as instabug]
|
[status-im.utils.instabug :as instabug]
|
||||||
[status-im.utils.mixpanel :as mixpanel]
|
[status-im.utils.mixpanel :as mixpanel]
|
||||||
[cljs.core.async :as async]
|
[cljs.core.async :as async]
|
||||||
|
@ -92,7 +91,6 @@
|
||||||
(fn track-handler
|
(fn track-handler
|
||||||
[context]
|
[context]
|
||||||
(let [new-db (get-coeffect context :db)
|
(let [new-db (get-coeffect context :db)
|
||||||
current-account-id (get-in new-db [:account/account :address])
|
|
||||||
[event-name] (get-coeffect context :event)]
|
[event-name] (get-coeffect context :event)]
|
||||||
(when (or
|
(when (or
|
||||||
(mixpanel/force-tracking? event-name)
|
(mixpanel/force-tracking? event-name)
|
||||||
|
@ -100,7 +98,7 @@
|
||||||
(let [event (get-coeffect context :event)
|
(let [event (get-coeffect context :event)
|
||||||
offline? (or (= :offline (:network-status new-db))
|
offline? (or (= :offline (:network-status new-db))
|
||||||
(= :offline (:sync-state new-db)))
|
(= :offline (:sync-state new-db)))
|
||||||
anon-id (ethereum/sha3 current-account-id)]
|
anon-id (:device-UUID new-db)]
|
||||||
(doseq [{:keys [label properties]}
|
(doseq [{:keys [label properties]}
|
||||||
(mixpanel/matching-events new-db event mixpanel/event-by-trigger)]
|
(mixpanel/matching-events new-db event mixpanel/event-by-trigger)]
|
||||||
(mixpanel/track anon-id label properties offline?))
|
(mixpanel/track anon-id label properties offline?))
|
||||||
|
|
Loading…
Reference in New Issue