Created
June 2, 2016 20:38
-
-
Save anonymous/4d6d38240aa2aeeefb0d0274b6f08969 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
class MixpanelService { | |
static transactional = false | |
void createOrUpdateUserProfile(User user) { | |
if(Environment.current != Environment.TEST) { | |
Executors.newFixedThreadPool(1).execute({ | |
User.withNewSession { | |
user = User.get(user.id) | |
MessageBuilder messageBuilder = new MessageBuilder(MIXPANEL_TOKEN) | |
JSONObject props = new JSONObject() | |
props.put('$name', user.username) | |
props.put('$email', user.email) | |
props.put('$distinct_id', user.id) | |
props.put('Date created', user.dateCreated) | |
props.put('Role', user.authorities*.authority?.join(',')) | |
new MixpanelAPI().sendMessage(messageBuilder.set(user.id.toString(), props)) | |
} | |
}) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment