Last active
November 1, 2021 12:59
-
-
Save fmedlin/69b442c90db4e928cf105b95e04154eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void track(AnalyticsTracker.Stat stat, String category, String label, Map<String, ?> properties) { | |
if (mNosaraClient == null) { | |
return; | |
} | |
String eventName = stat.name().toLowerCase(); | |
final String user; | |
final TracksClient.NosaraUserType userType; | |
if (mUserName != null) { | |
user = mUserName; | |
userType = TracksClient.NosaraUserType.SIMPLENOTE; | |
} else { | |
// This is just a security checks since the anonID is already available here. | |
// refresh metadata is called on login/logout/startup and it loads/generates the anonId when necessary. | |
if (getAnonID() == null) { | |
user = generateNewAnonID(); | |
} else { | |
user = getAnonID(); | |
} | |
userType = TracksClient.NosaraUserType.ANON; | |
} | |
if (properties != null) { | |
JSONObject propertiesJson = new JSONObject(properties); | |
mNosaraClient.track(EVENTS_PREFIX + eventName, propertiesJson, user, userType); | |
} else { | |
mNosaraClient.track(EVENTS_PREFIX + eventName, user, userType); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment