Skip to content

Instantly share code, notes, and snippets.

@fmedlin
Last active November 1, 2021 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmedlin/69b442c90db4e928cf105b95e04154eb to your computer and use it in GitHub Desktop.
Save fmedlin/69b442c90db4e928cf105b95e04154eb to your computer and use it in GitHub Desktop.
@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